use of org.mozilla.jss.pkcs11.PK11ECPublicKey in project jss by dogtagpki.
the class X509CertTest method convertPublicKeyToX509Key.
public static X509Key convertPublicKeyToX509Key(PublicKey pubk) throws Exception {
X509Key xKey = null;
if (pubk instanceof RSAPublicKey) {
RSAPublicKey rsaKey = (RSAPublicKey) pubk;
xKey = new org.mozilla.jss.netscape.security.provider.RSAPublicKey(new BigInt(rsaKey.getModulus()), new BigInt(rsaKey.getPublicExponent()));
} else if (pubk instanceof PK11ECPublicKey) {
byte[] encoded = pubk.getEncoded();
xKey = X509Key.parse(new DerValue(encoded));
}
return xKey;
}
Aggregations