private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); byte[] encoded = (byte[]) stream.readObject(); key = new OpenSSLKey(NativeCrypto.d2i_PUBKEY(encoded)); group = new OpenSSLECGroupContext( new NativeRef.EC_GROUP(NativeCrypto.EC_KEY_get1_group(key.getNativeRef()))); }
public static OpenSSLKey getInstance(ECPublicKey ecPublicKey) throws InvalidKeyException { try { OpenSSLECGroupContext group = OpenSSLECGroupContext.getInstance(ecPublicKey.getParams()); OpenSSLECPointContext pubKey = OpenSSLECPointContext.getInstance( NativeCrypto.get_EC_GROUP_type(group.getNativeRef()), group, ecPublicKey.getW()); return new OpenSSLKey( NativeCrypto.EVP_PKEY_new_EC_KEY(group.getNativeRef(), pubKey.getNativeRef(), null)); } catch (Exception e) { throw new InvalidKeyException(e); } }
private ECPoint getPublicKey() { final OpenSSLECPointContext pubKey = new OpenSSLECPointContext( group, new NativeRef.EC_POINT(NativeCrypto.EC_KEY_get_public_key(key.getNativeRef()))); return pubKey.getECPoint(); }
private void ensureReadParams() { if (fetchedParams) { return; } byte[][] params = NativeCrypto.get_RSA_public_params(key.getPkeyContext()); modulus = new BigInteger(params[0]); publicExponent = new BigInteger(params[1]); fetchedParams = true; }
static OpenSSLKey getInstance(RSAPublicKey rsaPublicKey) throws InvalidKeyException { try { return new OpenSSLKey( NativeCrypto.EVP_PKEY_new_RSA( rsaPublicKey.getModulus().toByteArray(), rsaPublicKey.getPublicExponent().toByteArray(), null, null, null, null, null, null)); } catch (Exception e) { throw new InvalidKeyException(e); } }
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); key = new OpenSSLKey( NativeCrypto.EVP_PKEY_new_RSA( modulus.toByteArray(), publicExponent.toByteArray(), null, null, null, null, null, null)); fetchedParams = true; }
OpenSSLRSAPublicKey(RSAPublicKeySpec spec) throws InvalidKeySpecException { try { key = new OpenSSLKey( NativeCrypto.EVP_PKEY_new_RSA( spec.getModulus().toByteArray(), spec.getPublicExponent().toByteArray(), null, null, null, null, null, null)); } catch (Exception e) { throw new InvalidKeySpecException(e); } }
private final synchronized void ensureReadParams() { if (fetchedParams) { return; } byte[][] params = NativeCrypto.get_DSA_params(key.getPkeyContext()); if (params[0] != null) { g = new BigInteger(params[0]); } if (params[1] != null) { p = new BigInteger(params[1]); } if (params[2] != null) { q = new BigInteger(params[2]); } if (params[3] != null) { y = new BigInteger(params[3]); } if (params[4] != null) { x = new BigInteger(params[4]); } fetchedParams = true; }
public String[] getSupportedCipherSuites() { return NativeCrypto.getSupportedCipherSuites(); }
public String[] getDefaultCipherSuites() { return NativeCrypto.getDefaultCipherSuites(); }
@Override public byte[] getEncoded() { return NativeCrypto.i2d_PUBKEY(key.getNativeRef()); }
public OpenSSLECPublicKey(OpenSSLKey key) { this.group = new OpenSSLECGroupContext( new NativeRef.EC_GROUP(NativeCrypto.EC_KEY_get1_group(key.getNativeRef()))); this.key = key; }
@Override public String toString() { return NativeCrypto.EVP_PKEY_print_public(key.getNativeRef()); }
@Override public int hashCode() { return Arrays.hashCode(NativeCrypto.i2d_PUBKEY(key.getNativeRef())); }
@Override public byte[] getEncoded() { return NativeCrypto.i2d_PUBKEY(key.getPkeyContext()); }