public class MyKeyAgreementSpi extends KeyAgreementSpi
Constructor and Description |
---|
MyKeyAgreementSpi() |
Modifier and Type | Method and Description |
---|---|
protected Key |
engineDoPhase(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 int |
engineGenerateSecret(byte[] sharedSecret,
int offset)
Generates the shared secret and stores it into the buffer
sharedSecred at offset . |
protected SecretKey |
engineGenerateSecret(String algorithm)
Generates the shared secret.
|
protected void |
engineInit(Key key,
AlgorithmParameterSpec params,
SecureRandom random)
Initializes this
KeyAgreementSpi with the specified key,
algorithm parameters and randomness source. |
protected void |
engineInit(Key key,
SecureRandom random)
Initializes this
KeyAgreementSpi with the specified key and the
specified randomness source. |
protected Key engineDoPhase(Key key, boolean lastPhase) throws InvalidKeyException, IllegalStateException
KeyAgreementSpi
engineDoPhase
in class KeyAgreementSpi
key
- the key received from the other party for this phase.lastPhase
- set to true
if this is the last phase of this key
agreement.InvalidKeyException
- if the specified key cannot be used in this key agreement or
this phase,IllegalStateException
- if this instance has not been initialized.protected byte[] engineGenerateSecret() throws IllegalStateException
KeyAgreementSpi
engineGenerateSecret
in class KeyAgreementSpi
IllegalStateException
- if this key agreement is not complete.protected int engineGenerateSecret(byte[] sharedSecret, int offset) throws IllegalStateException, ShortBufferException
KeyAgreementSpi
sharedSecred
at offset
.engineGenerateSecret
in class KeyAgreementSpi
sharedSecret
- the buffer to store the shared secret.offset
- the offset in the buffer.IllegalStateException
- if this key agreement is not complete.ShortBufferException
- if the specified buffer is too small for the shared secret.protected SecretKey engineGenerateSecret(String algorithm) throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException
KeyAgreementSpi
engineGenerateSecret
in class KeyAgreementSpi
algorithm
- the algorithm to for the SecretKey
SecretKey
of the specified
algorithm.IllegalStateException
- if this key agreement is not complete.NoSuchAlgorithmException
- if the specified algorithm for the secret key does not
exists.InvalidKeyException
- if a SecretKey
with the specified algorithm cannot be
created using the generated shared secret.protected void engineInit(Key key, SecureRandom random) throws InvalidKeyException
KeyAgreementSpi
KeyAgreementSpi
with the specified key and the
specified randomness source.engineInit
in class KeyAgreementSpi
key
- the key to initialize this key agreement.random
- the source for any randomness needed.InvalidKeyException
- if the specified key cannot be used to initialize this key
agreement.protected void engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
KeyAgreementSpi
KeyAgreementSpi
with the specified key,
algorithm parameters and randomness source.engineInit
in class KeyAgreementSpi
key
- the key to initialize this key agreement.params
- the parameters for this key agreement algorithm.random
- the source for any randomness needed.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.