Search in sources :

Example 1 with PK11ECPublicKey

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;
}
Also used : PK11ECPublicKey(org.mozilla.jss.pkcs11.PK11ECPublicKey) RSAPublicKey(java.security.interfaces.RSAPublicKey) DerValue(org.mozilla.jss.netscape.security.util.DerValue) BigInt(org.mozilla.jss.netscape.security.util.BigInt) X509Key(org.mozilla.jss.netscape.security.x509.X509Key) CertificateX509Key(org.mozilla.jss.netscape.security.x509.CertificateX509Key)

Aggregations

RSAPublicKey (java.security.interfaces.RSAPublicKey)1 BigInt (org.mozilla.jss.netscape.security.util.BigInt)1 DerValue (org.mozilla.jss.netscape.security.util.DerValue)1 CertificateX509Key (org.mozilla.jss.netscape.security.x509.CertificateX509Key)1 X509Key (org.mozilla.jss.netscape.security.x509.X509Key)1 PK11ECPublicKey (org.mozilla.jss.pkcs11.PK11ECPublicKey)1