*
* @throws InvalidSshKeyException
*/
public SshDssPrivateKey(byte[] key) throws InvalidSshKeyException {
try {
DSAPrivateKeySpec dsaKey;
// Extract the key information
ByteArrayReader bar = new ByteArrayReader(key);
String header = bar.readString();
if (!header.equals(getAlgorithmName())) {
throw new InvalidSshKeyException();
}
BigInteger p = bar.readBigInteger();
BigInteger q = bar.readBigInteger();
BigInteger g = bar.readBigInteger();
BigInteger x = bar.readBigInteger();
dsaKey = new DSAPrivateKeySpec(x, p, q, g);
KeyFactory kf = KeyFactory.getInstance("DSA");
prvkey = (DSAPrivateKey) kf.generatePrivate(dsaKey);
} catch (Exception e) {
throw new InvalidSshKeyException();