javax.crypto
public abstract class KeyAgreementSpi extends Object
Providers wishing to implement a key agreement algorithm must
subclass this and provide an appropriate implementation for all the
abstract methods below, and provide an appropriate entry in the
master java.security.Provider class (the service name for key
agreement algorithms is "KeyAgreement"
).
Since: 1.4
See Also: KeyAgreement SecretKey
Constructor Summary | |
---|---|
KeyAgreementSpi()
Create a new KeyAgreementSpi instance. |
Method Summary | |
---|---|
protected abstract Key | engineDoPhase(Key key, boolean lastPhase)
Do a phase in the key agreement.
|
protected abstract byte[] | engineGenerateSecret()
Generate the shared secret in a new byte array.
|
protected abstract int | engineGenerateSecret(byte[] sharedSecret, int offset)
Generate the shared secret, storing it into the specified array.
|
protected abstract SecretKey | engineGenerateSecret(String algorithm)
Generate the shared secret and return it as a SecretKey.
|
protected abstract void | engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random)
Initialize this key agreement with a key, parameters, and source of
randomness.
|
protected abstract void | engineInit(Key key, SecureRandom random)
Initialize this key agreement with a key and source of randomness.
|
Parameters: key The key to use for this phase. lastPhase true
if this call should be the last
phase.
Returns: The intermediate result, or null
if there is
no intermediate result.
Throws: java.lang.IllegalStateException If this instance has not been initialized. java.security.InvalidKeyException If the supplied key is not appropriate.
Returns: The shared secret in a new byte array.
Throws: java.lang.IllegalStateException If this key agreement is not ready to generate the secret.
Parameters: sharedSecret The byte array in which to store the secret. offset The offset into the byte array to start.
Returns: The size of the shared secret.
Throws: java.lang.IllegalStateException If this key agreement is not ready to generate the secret. javax.crypto.ShortBufferException If there is not enough space in the supplied array for the shared secret.
Parameters: algorithm The algorithm with which to generate the secret key.
Returns: The shared secret as a secret key.
Throws: java.lang.IllegalStateException If this key agreement is
not ready to generate the secret. java.security.InvalidKeyException If the shared secret
cannot be made into a SecretKey. java.security.NoSuchAlgorithmException If
algorithm
cannot be found.
Parameters: key The key to initialize with, usually a private key. params The parameters to initialize with. random The source of randomness to use.
Throws: java.security.InvalidAlgorithmParameterException If the supplied parameters are inappropriate. java.security.InvalidKeyException If the supplied key is inappropriate.
Parameters: key The key to initialize with, usually a private key. random The source of randomness to use.
Throws: java.security.InvalidKeyException If the supplied key is inappropriate.