Class OpenSSLBaseDHKeyAgreement<T>
java.lang.Object
javax.crypto.KeyAgreementSpi
org.conscrypt.OpenSSLBaseDHKeyAgreement<T>
- Direct Known Subclasses:
OpenSSLECDHKeyAgreement, OpenSSLXDHKeyAgreement
Generic base classe for Diffie-Hellman style key agreement backed by the OpenSSL engine.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprotected 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 Tprotected abstract TengineDoPhase(Key key, boolean lastPhase) protected byte[]protected intengineGenerateSecret(byte[] sharedSecret, int offset) protected SecretKeyengineGenerateSecret(String algorithm) protected voidengineInit(Key key, SecureRandom random) protected voidengineInit(Key key, AlgorithmParameterSpec params, SecureRandom random) protected abstract intgetOutputSize(T key) Returns the expected result length for the givenkey.
-
Field Details
-
mPrivateKey
OpenSSL handle of the private key. Only available after the engine has been initialized. -
mExpectedResultLength
private int mExpectedResultLengthExpected length (in bytes) of the agreed key (mResult). Only available after the engine has been initialized. -
mResult
private byte[] mResultAgreed key. Only available afterengineDoPhase(Key, boolean)completes.
-
-
Constructor Details
-
OpenSSLBaseDHKeyAgreement
protected OpenSSLBaseDHKeyAgreement()
-
-
Method Details
-
engineDoPhase
- Specified by:
engineDoPhasein classKeyAgreementSpi- Throws:
InvalidKeyException
-
convertPublicKey
- Throws:
InvalidKeyException
-
convertPrivateKey
- Throws:
InvalidKeyException
-
computeKey
protected abstract int computeKey(byte[] buffer, T theirPublicKey, T ourPrivateKey) throws InvalidKeyException Given the public keytheirPublicKeyand the private keyourPrivateKeywrite the shared secret tobufferand return the actual output size.- Throws:
InvalidKeyException
-
engineGenerateSecret
- Specified by:
engineGenerateSecretin classKeyAgreementSpi- Throws:
ShortBufferException
-
engineGenerateSecret
protected byte[] engineGenerateSecret()- Specified by:
engineGenerateSecretin classKeyAgreementSpi
-
engineGenerateSecret
- Specified by:
engineGenerateSecretin classKeyAgreementSpi
-
engineInit
- Specified by:
engineInitin classKeyAgreementSpi- Throws:
InvalidKeyException
-
getOutputSize
Returns the expected result length for the givenkey. -
engineInit
protected void engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
engineInitin classKeyAgreementSpi- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
checkCompleted
private void checkCompleted()
-