Package org.conscrypt
Class OpenSSLKey
- java.lang.Object
-
- org.conscrypt.OpenSSLKey
-
final class OpenSSLKey extends java.lang.ObjectRepresents a BoringSSLEVP_PKEY.
-
-
Field Summary
Fields Modifier and Type Field Description private NativeRef.EVP_PKEYctxprivate booleanhardwareBackedprivate booleanwrapped
-
Constructor Summary
Constructors Constructor Description OpenSSLKey(long ctx)OpenSSLKey(long ctx, boolean wrapped)OpenSSLKey(long ctx, boolean wrapped, boolean hardwareBacked)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)(package private) static OpenSSLKeyfromECPrivateKeyForTLSStackOnly(java.security.PrivateKey key, java.security.spec.ECParameterSpec ecParams)Gets anOpenSSLKeyinstance backed by the provided EC private key.private static OpenSSLKeyfromKeyMaterial(java.security.PrivateKey key)Gets anOpenSSLKeyinstance initialized with the key material of the provided key.(package private) static OpenSSLKeyfromPrivateKey(java.security.PrivateKey key)(package private) static OpenSSLKeyfromPrivateKeyForTLSStackOnly(java.security.PrivateKey privateKey, java.security.PublicKey publicKey)Gets anOpenSSLKeyinstance backed by the provided private key.(package private) static OpenSSLKeyfromPrivateKeyPemInputStream(java.io.InputStream is)Parse a private key in PEM encoding from the provided input stream.(package private) static OpenSSLKeyfromPublicKey(java.security.PublicKey key)(package private) static OpenSSLKeyfromPublicKeyPemInputStream(java.io.InputStream is)Parse a public key in PEM encoding from the provided input stream.(package private) NativeRef.EVP_PKEYgetNativeRef()Returns the EVP_PKEY context for use in JNI calls.private static OpenSSLKeygetOpenSSLKey(java.security.PrivateKey key)Gets theOpenSSLKeyinstance of the provided key.(package private) java.security.PrivateKeygetPrivateKey()(package private) static java.security.PrivateKeygetPrivateKey(java.security.spec.PKCS8EncodedKeySpec keySpec, int type)(package private) java.security.PublicKeygetPublicKey()(package private) static java.security.PublicKeygetPublicKey(java.security.spec.X509EncodedKeySpec keySpec, int type)inthashCode()(package private) booleanisHardwareBacked()(package private) booleanisWrapped()private static OpenSSLKeywrapJCAPrivateKeyForTLSStackOnly(java.security.PrivateKey privateKey, java.security.PublicKey publicKey)Wraps the provided private key for use in the TLS/SSL stack only.private static OpenSSLKeywrapPrivateKey(java.security.PrivateKey key)
-
-
-
Field Detail
-
ctx
private final NativeRef.EVP_PKEY ctx
-
wrapped
private final boolean wrapped
-
hardwareBacked
private final boolean hardwareBacked
-
-
Method Detail
-
getNativeRef
NativeRef.EVP_PKEY getNativeRef()
Returns the EVP_PKEY context for use in JNI calls.
-
isWrapped
boolean isWrapped()
-
isHardwareBacked
boolean isHardwareBacked()
-
fromPrivateKey
static OpenSSLKey fromPrivateKey(java.security.PrivateKey key) throws java.security.InvalidKeyException
- Throws:
java.security.InvalidKeyException
-
fromPrivateKeyPemInputStream
static OpenSSLKey fromPrivateKeyPemInputStream(java.io.InputStream is) throws java.security.InvalidKeyException
Parse a private key in PEM encoding from the provided input stream.- Throws:
java.security.InvalidKeyException- if parsing fails
-
fromPrivateKeyForTLSStackOnly
static OpenSSLKey fromPrivateKeyForTLSStackOnly(java.security.PrivateKey privateKey, java.security.PublicKey publicKey) throws java.security.InvalidKeyException
Gets anOpenSSLKeyinstance backed by the provided private key. The resulting key is usable only by this provider's TLS/SSL stack.- Parameters:
privateKey- private key.publicKey- corresponding public key ornullif not available. Some opaque private keys cannot be used by the TLS/SSL stack without the public key.- Throws:
java.security.InvalidKeyException
-
fromECPrivateKeyForTLSStackOnly
static OpenSSLKey fromECPrivateKeyForTLSStackOnly(java.security.PrivateKey key, java.security.spec.ECParameterSpec ecParams) throws java.security.InvalidKeyException
Gets anOpenSSLKeyinstance backed by the provided EC private key. The resulting key is usable only by this provider's TLS/SSL stack.- Parameters:
key- private key.ecParams- EC parametersnullif not available. Some opaque private keys cannot be used by the TLS/SSL stack without the parameters because the private key itself might not expose the parameters.- Throws:
java.security.InvalidKeyException
-
getOpenSSLKey
private static OpenSSLKey getOpenSSLKey(java.security.PrivateKey key)
Gets theOpenSSLKeyinstance of the provided key.- Returns:
- instance or
nullif thekeyis not backed by OpenSSL'sEVP_PKEY.
-
fromKeyMaterial
private static OpenSSLKey fromKeyMaterial(java.security.PrivateKey key) throws java.security.InvalidKeyException
Gets anOpenSSLKeyinstance initialized with the key material of the provided key.- Returns:
- instance or
nullif thekeydoes not export its key material in a suitable format. - Throws:
java.security.InvalidKeyException
-
wrapJCAPrivateKeyForTLSStackOnly
private static OpenSSLKey wrapJCAPrivateKeyForTLSStackOnly(java.security.PrivateKey privateKey, java.security.PublicKey publicKey) throws java.security.InvalidKeyException
Wraps the provided private key for use in the TLS/SSL stack only. Sign/decrypt operations using the key will be delegated to theSignature/Cipherimplementation of the provider which accepts the key.- Throws:
java.security.InvalidKeyException
-
wrapPrivateKey
private static OpenSSLKey wrapPrivateKey(java.security.PrivateKey key) throws java.security.InvalidKeyException
- Throws:
java.security.InvalidKeyException
-
fromPublicKey
static OpenSSLKey fromPublicKey(java.security.PublicKey key) throws java.security.InvalidKeyException
- Throws:
java.security.InvalidKeyException
-
fromPublicKeyPemInputStream
static OpenSSLKey fromPublicKeyPemInputStream(java.io.InputStream is) throws java.security.InvalidKeyException
Parse a public key in PEM encoding from the provided input stream.- Throws:
java.security.InvalidKeyException- if parsing fails
-
getPublicKey
java.security.PublicKey getPublicKey() throws java.security.NoSuchAlgorithmException- Throws:
java.security.NoSuchAlgorithmException
-
getPublicKey
static java.security.PublicKey getPublicKey(java.security.spec.X509EncodedKeySpec keySpec, int type) throws java.security.spec.InvalidKeySpecException- Throws:
java.security.spec.InvalidKeySpecException
-
getPrivateKey
java.security.PrivateKey getPrivateKey() throws java.security.NoSuchAlgorithmException- Throws:
java.security.NoSuchAlgorithmException
-
getPrivateKey
static java.security.PrivateKey getPrivateKey(java.security.spec.PKCS8EncodedKeySpec keySpec, int type) throws java.security.spec.InvalidKeySpecException- Throws:
java.security.spec.InvalidKeySpecException
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-