Package org.conscrypt
Class OpenSSLKey
java.lang.Object
org.conscrypt.OpenSSLKey
Represents a BoringSSL
EVP_PKEY.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final NativeRef.EVP_PKEYprivate final booleanprivate final boolean -
Constructor Summary
ConstructorsConstructorDescriptionOpenSSLKey(long ctx) OpenSSLKey(long ctx, boolean wrapped) OpenSSLKey(long ctx, boolean wrapped, boolean hardwareBacked) -
Method Summary
Modifier and TypeMethodDescriptionboolean(package private) static OpenSSLKeyfromECPrivateKeyForTLSStackOnly(PrivateKey key, ECParameterSpec ecParams) Gets anOpenSSLKeyinstance backed by the provided EC private key.private static OpenSSLKeyGets anOpenSSLKeyinstance initialized with the key material of the provided key.(package private) static OpenSSLKeyfromPrivateKey(PrivateKey key) (package private) static OpenSSLKeyfromPrivateKeyForTLSStackOnly(PrivateKey privateKey, PublicKey publicKey) Gets anOpenSSLKeyinstance backed by the provided private key.(package private) static OpenSSLKeyParse a private key in PEM encoding from the provided input stream.(package private) static OpenSSLKeyfromPublicKey(PublicKey key) (package private) static OpenSSLKeyParse a public key in PEM encoding from the provided input stream.(package private) NativeRef.EVP_PKEYReturns the EVP_PKEY context for use in JNI calls.private static OpenSSLKeygetOpenSSLKey(PrivateKey key) Gets theOpenSSLKeyinstance of the provided key.(package private) PrivateKey(package private) static PrivateKeygetPrivateKey(PKCS8EncodedKeySpec keySpec, int type) (package private) PublicKey(package private) static PublicKeygetPublicKey(X509EncodedKeySpec keySpec, int type) inthashCode()(package private) boolean(package private) booleanprivate static OpenSSLKeywrapJCAPrivateKeyForTLSStackOnly(PrivateKey privateKey, PublicKey publicKey) Wraps the provided private key for use in the TLS/SSL stack only.private static OpenSSLKeywrapPrivateKey(PrivateKey key)
-
Field Details
-
ctx
-
wrapped
private final boolean wrapped -
hardwareBacked
private final boolean hardwareBacked
-
-
Constructor Details
-
OpenSSLKey
OpenSSLKey(long ctx) -
OpenSSLKey
OpenSSLKey(long ctx, boolean wrapped) -
OpenSSLKey
OpenSSLKey(long ctx, boolean wrapped, boolean hardwareBacked)
-
-
Method Details
-
getNativeRef
NativeRef.EVP_PKEY getNativeRef()Returns the EVP_PKEY context for use in JNI calls. -
isWrapped
boolean isWrapped() -
isHardwareBacked
boolean isHardwareBacked() -
fromPrivateKey
- Throws:
InvalidKeyException
-
fromPrivateKeyPemInputStream
Parse a private key in PEM encoding from the provided input stream.- Throws:
InvalidKeyException- if parsing fails
-
fromPrivateKeyForTLSStackOnly
static OpenSSLKey fromPrivateKeyForTLSStackOnly(PrivateKey privateKey, PublicKey publicKey) throws 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:
InvalidKeyException
-
fromECPrivateKeyForTLSStackOnly
static OpenSSLKey fromECPrivateKeyForTLSStackOnly(PrivateKey key, ECParameterSpec ecParams) throws 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:
InvalidKeyException
-
getOpenSSLKey
Gets theOpenSSLKeyinstance of the provided key.- Returns:
- instance or
nullif thekeyis not backed by OpenSSL'sEVP_PKEY.
-
fromKeyMaterial
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:
InvalidKeyException
-
wrapJCAPrivateKeyForTLSStackOnly
private static OpenSSLKey wrapJCAPrivateKeyForTLSStackOnly(PrivateKey privateKey, PublicKey publicKey) throws 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:
InvalidKeyException
-
wrapPrivateKey
- Throws:
InvalidKeyException
-
fromPublicKey
- Throws:
InvalidKeyException
-
fromPublicKeyPemInputStream
Parse a public key in PEM encoding from the provided input stream.- Throws:
InvalidKeyException- if parsing fails
-
getPublicKey
- Throws:
NoSuchAlgorithmException
-
getPublicKey
- Throws:
InvalidKeySpecException
-
getPrivateKey
- Throws:
NoSuchAlgorithmException
-
getPrivateKey
static PrivateKey getPrivateKey(PKCS8EncodedKeySpec keySpec, int type) throws InvalidKeySpecException - Throws:
InvalidKeySpecException
-
equals
-
hashCode
public int hashCode()
-