use of com.jn.langx.security.crypto.IllegalKeyException in project agileway by fangjinuo.
the class SshDssPublicKeyCodec method decode.
@Override
public PublicKey decode(byte[] bytes) throws CodecException {
Buffer buf = new Buffer.PlainBuffer(bytes);
BigInteger p, q, g, y;
try {
p = buf.readMPInt();
q = buf.readMPInt();
g = buf.readMPInt();
y = buf.readMPInt();
} catch (Buffer.BufferException be) {
throw new IllegalKeyException(be);
}
try {
return PKIs.getKeyFactory("DSA", null).generatePublic(new DSAPublicKeySpec(y, p, q, g));
} catch (InvalidKeySpecException ex) {
throw new IllegalKeyException();
}
}
use of com.jn.langx.security.crypto.IllegalKeyException in project agileway by fangjinuo.
the class SshRsaPublicKeyCodec method decode.
@Override
public PublicKey decode(byte[] bytes) throws CodecException {
Buffer<?> buf = new Buffer.PlainBuffer(bytes);
final BigInteger e, n;
try {
e = buf.readMPInt();
n = buf.readMPInt();
return PKIs.getKeyFactory("RSA", null).generatePublic(new RSAPublicKeySpec(n, e));
} catch (Buffer.BufferException be) {
throw new IllegalKeyException(be);
} catch (InvalidKeySpecException ex) {
throw new IllegalKeyException(ex);
}
}
Aggregations