*
* @throws InvalidSshKeyException
*/
public SshDssPublicKey(byte[] key) throws InvalidSshKeyException {
try {
DSAPublicKeySpec 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 y = bar.readBigInteger();
dsaKey = new DSAPublicKeySpec(y, p, q, g);
KeyFactory kf = KeyFactory.getInstance("DSA");
pubkey = (DSAPublicKey) kf.generatePublic(dsaKey);
} catch (Exception e) {
throw new InvalidSshKeyException();