javax.crypto
public abstract class KeyAgreementSpi extends Object
KeyAgreement
class.
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 Provider
class (the service name for key
agreement algorithms is "KeyAgreement"
).
KeyAgreement
,
SecretKey
Constructor and Description |
---|
KeyAgreementSpi()
Create a new KeyAgreementSpi instance.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public KeyAgreementSpi()
protected abstract Key engineDoPhase(Key key, boolean lastPhase) throws IllegalStateException, InvalidKeyException
key
- The key to use for this phase.lastPhase
- true
if this call should be the last
phase.null
if there is
no intermediate result.IllegalStateException
- If this instance has not
been initialized.InvalidKeyException
- If the supplied key is
not appropriate.protected abstract byte[] engineGenerateSecret() throws IllegalStateException
IllegalStateException
- If this key agreement is
not ready to generate the secret.protected abstract int engineGenerateSecret(byte[] sharedSecret, int offset) throws IllegalStateException, ShortBufferException
sharedSecret
- The byte array in which to store the secret.offset
- The offset into the byte array to start.IllegalStateException
- If this key agreement is
not ready to generate the secret.ShortBufferException
- If there is not enough
space in the supplied array for the shared secret.protected abstract SecretKey engineGenerateSecret(String algorithm) throws IllegalStateException, InvalidKeyException, NoSuchAlgorithmException
SecretKey
.algorithm
- The algorithm with which to generate the secret key.IllegalStateException
- If this key agreement is
not ready to generate the secret.InvalidKeyException
- If the shared secret
cannot be made into a SecretKey
.NoSuchAlgorithmException
- If
algorithm
cannot be found.protected abstract void engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException, InvalidKeyException
key
- The key to initialize with, usually a private key.params
- The parameters to initialize with.random
- The source of randomness to use.InvalidAlgorithmParameterException
- If the
supplied parameters are inappropriate.InvalidKeyException
- If the supplied key is
inappropriate.protected abstract void engineInit(Key key, SecureRandom random) throws InvalidKeyException
key
- The key to initialize with, usually a private key.random
- The source of randomness to use.InvalidKeyException
- If the supplied key is
inappropriate.