Package org.conscrypt
Class OpenSSLKey
java.lang.Object
org.conscrypt.OpenSSLKey
Represents a BoringSSL
EVP_PKEY
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final NativeRef.EVP_PKEY
private final boolean
private 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 OpenSSLKey
fromECPrivateKeyForTLSStackOnly
(PrivateKey key, ECParameterSpec ecParams) Gets anOpenSSLKey
instance backed by the provided EC private key.private static OpenSSLKey
Gets anOpenSSLKey
instance initialized with the key material of the provided key.(package private) static OpenSSLKey
fromPrivateKey
(PrivateKey key) (package private) static OpenSSLKey
fromPrivateKeyForTLSStackOnly
(PrivateKey privateKey, PublicKey publicKey) Gets anOpenSSLKey
instance backed by the provided private key.(package private) static OpenSSLKey
Parse a private key in PEM encoding from the provided input stream.(package private) static OpenSSLKey
fromPublicKey
(PublicKey key) (package private) static OpenSSLKey
Parse a public key in PEM encoding from the provided input stream.(package private) NativeRef.EVP_PKEY
Returns the EVP_PKEY context for use in JNI calls.private static OpenSSLKey
getOpenSSLKey
(PrivateKey key) Gets theOpenSSLKey
instance of the provided key.(package private) PrivateKey
(package private) static PrivateKey
getPrivateKey
(PKCS8EncodedKeySpec keySpec, int type) (package private) PublicKey
(package private) static PublicKey
getPublicKey
(X509EncodedKeySpec keySpec, int type) int
hashCode()
(package private) boolean
(package private) boolean
private static OpenSSLKey
wrapJCAPrivateKeyForTLSStackOnly
(PrivateKey privateKey, PublicKey publicKey) Wraps the provided private key for use in the TLS/SSL stack only.private static OpenSSLKey
wrapPrivateKey
(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 anOpenSSLKey
instance 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 ornull
if 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 anOpenSSLKey
instance 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 parametersnull
if 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 theOpenSSLKey
instance of the provided key.- Returns:
- instance or
null
if thekey
is not backed by OpenSSL'sEVP_PKEY
.
-
fromKeyMaterial
Gets anOpenSSLKey
instance initialized with the key material of the provided key.- Returns:
- instance or
null
if thekey
does 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
/Cipher
implementation 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()
-