All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class javax.crypto.KeyAgreementSpi

java.lang.Object
   |
   +----javax.crypto.KeyAgreementSpi

public abstract class KeyAgreementSpi
extends Object
This class provides the functionality of a key agreement protocol. The keys involved in establishing a shared secret are created by one of the key generators (KeyPairGenerator or KeyGenerator), a KeyFactory, or as a result from an intermediate phase of the key agreement protocol (see doPhase).

See Also:
AlgorithmParameterGenerator, AlgorithmParameters, KeyPairGenerator, KeyFactory, KeyGenerator, KeySpec, AlgorithmParameterSpec, DHPrivateKeySpec, DHPublicKeySpec, DHParameterSpec, DHGenParameterSpec

Constructor Index

 o KeyAgreementSpi()

Method Index

 o engineDoPhase(int, Key)
Executes the next phase phase of the key agreement protocol, using the provided key key.
 o engineGenerateSecret()
Generates the shared secret and returns it in a new buffer.
 o engineGenerateSecret(byte[], int)
Generates the shared secret, and places it into the buffer sharedSecret, beginning at offset.
 o engineInit(AlgorithmParameterSpec, SecureRandom)
Initializes this key agreement with a set of parameters and a source of randomness.
 o engineInit(SecureRandom)
Initializes this key agreement to get random bytes (if needed) from random.

Constructors

 o KeyAgreementSpi
 public KeyAgreementSpi()

Methods

 o engineInit
 protected abstract void engineInit(SecureRandom random)
Initializes this key agreement to get random bytes (if needed) from random.

Parameters:
random - the source of randomness
 o engineInit
 protected abstract void engineInit(AlgorithmParameterSpec params,
                                    SecureRandom random) throws InvalidAlgorithmParameterException
Initializes this key agreement with a set of parameters and a source of randomness.

Parameters:
params - the key agreement parameters
random - the source of randomness
Throws: InvalidAlgorithmParameterException
if the given parameters are inappropriate for this key agreement protocol
 o engineDoPhase
 protected abstract Key engineDoPhase(int phase,
                                      Key key) throws IllegalStateException, InvalidKeyException
Executes the next phase phase of the key agreement protocol, using the provided key key.

Parameters:
phase - the phase of the key agreement protocol to be executed
key - the key for this phase
Returns:
the key resulting from phase, or null if phase does not yield a key
Throws: IllegalStateException
if phase is inappropriate for this key agreement protocol, or does not correspond to the next phase in the protocol sequence
Throws: InvalidKeyException
if the given key is inappropriate for this key agreement protocol, or inappropriate for the specified phase phase
 o engineGenerateSecret
 protected abstract byte[] engineGenerateSecret() throws IllegalStateException
Generates the shared secret and returns it in a new buffer.

The key agreement is reset to its initial state after this call.

Returns:
the new buffer with the shared secret
Throws: IllegalStateException
if this key agreement has not been completed yet
 o engineGenerateSecret
 protected abstract int engineGenerateSecret(byte sharedSecret[],
                                             int offset) throws IllegalStateException, ShortBufferException
Generates the shared secret, and places it into the buffer sharedSecret, beginning at offset.

If the sharedSecret buffer is too small to hold the result, a ShortBufferException is thrown. In this case, this call should be repeated with a larger output buffer.

After this call has completed successfully, this KeyAgreement is reset to its initial state (uninitialized), and can be re-used for further key agreements.

Parameters:
sharedSecret - the buffer for the shared secret
offset - the offset in sharedSecret where the shared secret will be stored
Returns:
the number of bytes placed into sharedSecret
Throws: IllegalStateException
if this key agreement has not been completed yet
Throws: ShortBufferException
if the given output buffer is too small to hold the secret

All Packages  Class Hierarchy  This Package  Previous  Next  Index