Class KeyAgreementSpi
java.lang.Object
javax.crypto.KeyAgreementSpi
org.bouncycastle.jcajce.provider.asymmetric.ec.KeyAgreementSpi
- Direct Known Subclasses:
KeyAgreementSpi.DH
public class KeyAgreementSpi extends KeyAgreementSpi
Diffie-Hellman key agreement using elliptic curve keys, ala IEEE P1363
both the simple one, and the simple one with cofactors are supported.
Also, MQV key agreement per SEC-1
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKeyAgreementSpi.DH -
Constructor Summary
Constructors Modifier Constructor Description protectedKeyAgreementSpi(String kaAlgorithm, BasicAgreement agreement, DerivationFunction kdf) -
Method Summary
Modifier and Type Method Description protected KeyengineDoPhase(Key key, boolean lastPhase)Does the next (or the last) phase of the key agreement, using the specified key.protected byte[]engineGenerateSecret()Generates the shared secret.protected intengineGenerateSecret(byte[] sharedSecret, int offset)Generates the shared secret and stores it into the buffersharedSecredatoffset.protected SecretKeyengineGenerateSecret(String algorithm)Generates the shared secret.protected voidengineInit(Key key, SecureRandom random)Initializes thisKeyAgreementSpiwith the specified key and the specified randomness source.protected voidengineInit(Key key, AlgorithmParameterSpec params, SecureRandom random)Initializes thisKeyAgreementSpiwith the specified key, algorithm parameters and randomness source.
-
Constructor Details
-
KeyAgreementSpi
-
-
Method Details
-
engineDoPhase
protected Key engineDoPhase(Key key, boolean lastPhase) throws InvalidKeyException, IllegalStateExceptionDescription copied from class:KeyAgreementSpiDoes the next (or the last) phase of the key agreement, using the specified key.- Specified by:
engineDoPhasein classKeyAgreementSpi- Parameters:
key- the key received from the other party for this phase.lastPhase- set totrueif this is the last phase of this key agreement.- Returns:
- the intermediate key from this phase or null if there is no intermediate key for this phase.
- Throws:
InvalidKeyException- if the specified key cannot be used in this key agreement or this phase,IllegalStateException- if this instance has not been initialized.
-
engineGenerateSecret
Description copied from class:KeyAgreementSpiGenerates the shared secret.- Specified by:
engineGenerateSecretin classKeyAgreementSpi- Returns:
- the generated shared secret.
- Throws:
IllegalStateException- if this key agreement is not complete.
-
engineGenerateSecret
protected int engineGenerateSecret(byte[] sharedSecret, int offset) throws IllegalStateException, ShortBufferExceptionDescription copied from class:KeyAgreementSpiGenerates the shared secret and stores it into the buffersharedSecredatoffset.- Specified by:
engineGenerateSecretin classKeyAgreementSpi- Parameters:
sharedSecret- the buffer to store the shared secret.offset- the offset in the buffer.- Returns:
- the number of bytes stored in the buffer.
- Throws:
IllegalStateException- if this key agreement is not complete.ShortBufferException- if the specified buffer is too small for the shared secret.
-
engineGenerateSecret
Description copied from class:KeyAgreementSpiGenerates the shared secret.- Specified by:
engineGenerateSecretin classKeyAgreementSpi- Parameters:
algorithm- the algorithm to for theSecretKey- Returns:
- the shared secret as a
SecretKeyof the specified algorithm. - Throws:
NoSuchAlgorithmException- if the specified algorithm for the secret key does not exists.
-
engineInit
protected void engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterExceptionDescription copied from class:KeyAgreementSpiInitializes thisKeyAgreementSpiwith the specified key, algorithm parameters and randomness source.- Specified by:
engineInitin classKeyAgreementSpi- Parameters:
key- the key to initialize this key agreement.params- the parameters for this key agreement algorithm.random- the source for any randomness needed.- Throws:
InvalidKeyException- if the specified key cannot be used to initialize this key agreement.InvalidAlgorithmParameterException- if the specified parameters are invalid for this key agreement algorithm.
-
engineInit
Description copied from class:KeyAgreementSpiInitializes thisKeyAgreementSpiwith the specified key and the specified randomness source.- Specified by:
engineInitin classKeyAgreementSpi- Parameters:
key- the key to initialize this key agreement.random- the source for any randomness needed.- Throws:
InvalidKeyException- if the specified key cannot be used to initialize this key agreement.
-