Package org.conscrypt
Class OpenSSLBaseDHKeyAgreement<T>
- java.lang.Object
-
- javax.crypto.KeyAgreementSpi
-
- org.conscrypt.OpenSSLBaseDHKeyAgreement<T>
-
- Direct Known Subclasses:
OpenSSLECDHKeyAgreement,OpenSSLXDHKeyAgreement
@Internal public abstract class OpenSSLBaseDHKeyAgreement<T> extends javax.crypto.KeyAgreementSpi
Generic base classe for Diffie-Hellman style key agreement backed by the OpenSSL engine.
-
-
Field Summary
Fields Modifier and Type Field Description private intmExpectedResultLengthExpected length (in bytes) of the agreed key (mResult).private TmPrivateKeyOpenSSL handle of the private key.private byte[]mResultAgreed key.
-
Constructor Summary
Constructors Modifier Constructor Description protectedOpenSSLBaseDHKeyAgreement()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private voidcheckCompleted()protected abstract intcomputeKey(byte[] buffer, T theirPublicKey, T ourPrivateKey)Given the public keytheirPublicKeyand the private keyourPrivateKeywrite the shared secret tobufferand return the actual output size.protected abstract TconvertPrivateKey(java.security.PrivateKey key)protected abstract TconvertPublicKey(java.security.PublicKey key)java.security.KeyengineDoPhase(java.security.Key key, boolean lastPhase)protected byte[]engineGenerateSecret()protected intengineGenerateSecret(byte[] sharedSecret, int offset)protected javax.crypto.SecretKeyengineGenerateSecret(java.lang.String algorithm)protected voidengineInit(java.security.Key key, java.security.SecureRandom random)protected voidengineInit(java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)protected abstract intgetOutputSize(T key)Returns the expected result length for the givenkey.
-
-
-
Field Detail
-
mPrivateKey
private T mPrivateKey
OpenSSL handle of the private key. Only available after the engine has been initialized.
-
mExpectedResultLength
private int mExpectedResultLength
Expected length (in bytes) of the agreed key (mResult). Only available after the engine has been initialized.
-
mResult
private byte[] mResult
Agreed key. Only available afterengineDoPhase(Key, boolean)completes.
-
-
Method Detail
-
engineDoPhase
public java.security.Key engineDoPhase(java.security.Key key, boolean lastPhase) throws java.security.InvalidKeyException- Specified by:
engineDoPhasein classjavax.crypto.KeyAgreementSpi- Throws:
java.security.InvalidKeyException
-
convertPublicKey
protected abstract T convertPublicKey(java.security.PublicKey key) throws java.security.InvalidKeyException
- Throws:
java.security.InvalidKeyException
-
convertPrivateKey
protected abstract T convertPrivateKey(java.security.PrivateKey key) throws java.security.InvalidKeyException
- Throws:
java.security.InvalidKeyException
-
computeKey
protected abstract int computeKey(byte[] buffer, T theirPublicKey, T ourPrivateKey) throws java.security.InvalidKeyExceptionGiven the public keytheirPublicKeyand the private keyourPrivateKeywrite the shared secret tobufferand return the actual output size.- Throws:
java.security.InvalidKeyException
-
engineGenerateSecret
protected int engineGenerateSecret(byte[] sharedSecret, int offset) throws javax.crypto.ShortBufferException- Specified by:
engineGenerateSecretin classjavax.crypto.KeyAgreementSpi- Throws:
javax.crypto.ShortBufferException
-
engineGenerateSecret
protected byte[] engineGenerateSecret()
- Specified by:
engineGenerateSecretin classjavax.crypto.KeyAgreementSpi
-
engineGenerateSecret
protected javax.crypto.SecretKey engineGenerateSecret(java.lang.String algorithm)
- Specified by:
engineGenerateSecretin classjavax.crypto.KeyAgreementSpi
-
engineInit
protected void engineInit(java.security.Key key, java.security.SecureRandom random) throws java.security.InvalidKeyException- Specified by:
engineInitin classjavax.crypto.KeyAgreementSpi- Throws:
java.security.InvalidKeyException
-
getOutputSize
protected abstract int getOutputSize(T key)
Returns the expected result length for the givenkey.
-
engineInit
protected void engineInit(java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException- Specified by:
engineInitin classjavax.crypto.KeyAgreementSpi- Throws:
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterException
-
checkCompleted
private void checkCompleted()
-
-