Package org.conscrypt
Class OpenSSLKey
- java.lang.Object
-
- org.conscrypt.OpenSSLKey
-
public class OpenSSLKey extends Object
-
-
Constructor Summary
Constructors Constructor Description OpenSSLKey(long ctx)OpenSSLKey(long ctx, boolean wrapped)OpenSSLKey(long ctx, OpenSSLEngine engine, String alias)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Compares this instance with the specified object and indicates if they are equal.static OpenSSLKeyfromECPrivateKeyForTLSStackOnly(PrivateKey key, ECParameterSpec ecParams)Gets anOpenSSLKeyinstance backed by the provided EC private key.static OpenSSLKeyfromPrivateKey(PrivateKey key)static OpenSSLKeyfromPrivateKeyForTLSStackOnly(PrivateKey privateKey, PublicKey publicKey)Gets anOpenSSLKeyinstance backed by the provided private key.static OpenSSLKeyfromPrivateKeyPemInputStream(InputStream is)Parse a private key in PEM encoding from the provided input stream.static OpenSSLKeyfromPublicKey(PublicKey key)static OpenSSLKeyfromPublicKeyPemInputStream(InputStream is)Parse a public key in PEM encoding from the provided input stream.StringgetAlias()NativeRef.EVP_PKEYgetNativeRef()Returns the EVP_PKEY context for use in JNI calls.PrivateKeygetPrivateKey()PublicKeygetPublicKey()inthashCode()Returns an integer hash code for this object.booleanisWrapped()
-
-
-
Constructor Detail
-
OpenSSLKey
public OpenSSLKey(long ctx)
-
OpenSSLKey
public OpenSSLKey(long ctx, boolean wrapped)
-
OpenSSLKey
public OpenSSLKey(long ctx, OpenSSLEngine engine, String alias)
-
-
Method Detail
-
getNativeRef
public NativeRef.EVP_PKEY getNativeRef()
Returns the EVP_PKEY context for use in JNI calls.
-
getAlias
public String getAlias()
-
isWrapped
public boolean isWrapped()
-
fromPrivateKey
public static OpenSSLKey fromPrivateKey(PrivateKey key) throws InvalidKeyException
- Throws:
InvalidKeyException
-
fromPrivateKeyPemInputStream
public static OpenSSLKey fromPrivateKeyPemInputStream(InputStream is) throws InvalidKeyException
Parse a private key in PEM encoding from the provided input stream.- Throws:
InvalidKeyException- if parsing fails
-
fromPrivateKeyForTLSStackOnly
public 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
public 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
-
fromPublicKey
public static OpenSSLKey fromPublicKey(PublicKey key) throws InvalidKeyException
- Throws:
InvalidKeyException
-
fromPublicKeyPemInputStream
public static OpenSSLKey fromPublicKeyPemInputStream(InputStream is) throws InvalidKeyException
Parse a public key in PEM encoding from the provided input stream.- Throws:
InvalidKeyException- if parsing fails
-
getPublicKey
public PublicKey getPublicKey() throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
getPrivateKey
public PrivateKey getPrivateKey() throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
equals
public boolean equals(Object o)
Description copied from class:ObjectCompares this instance with the specified object and indicates if they are equal. In order to be equal,omust represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.The default implementation returns
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
o- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()
Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually override both methods or neither method.Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
-