Skip to content

Most visited

Recently visited

navigation
Added in API level 1

KeyAgreementSpi

public abstract class KeyAgreementSpi
extends Object

java.lang.Object
   ↳ javax.crypto.KeyAgreementSpi


The Service Provider Interface (SPI) definition for the KeyAgreement class.

Summary

Public constructors

KeyAgreementSpi()

Creates a new KeyAgreementSpi instance.

Protected methods

abstract Key engineDoPhase(Key key, boolean lastPhase)

Does the next (or the last) phase of the key agreement, using the specified key.

abstract int engineGenerateSecret(byte[] sharedSecret, int offset)

Generates the shared secret and stores it into the buffer sharedSecred at offset.

abstract byte[] engineGenerateSecret()

Generates the shared secret.

abstract SecretKey engineGenerateSecret(String algorithm)

Generates the shared secret.

abstract void engineInit(Key key, SecureRandom random)

Initializes this KeyAgreementSpi with the specified key and the specified randomness source.

abstract void engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random)

Initializes this KeyAgreementSpi with the specified key, algorithm parameters and randomness source.

Inherited methods

From class java.lang.Object

Public constructors

KeyAgreementSpi

Added in API level 1
KeyAgreementSpi ()

Creates a new KeyAgreementSpi instance.

Protected methods

engineDoPhase

Added in API level 1
Key engineDoPhase (Key key, 
                boolean lastPhase)

Does the next (or the last) phase of the key agreement, using the specified key.

Parameters
key Key: the key received from the other party for this phase.
lastPhase boolean: set to true if this is the last phase of this key agreement.
Returns
Key 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

Added in API level 1
int engineGenerateSecret (byte[] sharedSecret, 
                int offset)

Generates the shared secret and stores it into the buffer sharedSecred at offset.

Parameters
sharedSecret byte: the buffer to store the shared secret.
offset int: the offset in the buffer.
Returns
int 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

Added in API level 1
byte[] engineGenerateSecret ()

Generates the shared secret.

Returns
byte[] the generated shared secret.
Throws
IllegalStateException if this key agreement is not complete.

engineGenerateSecret

Added in API level 1
SecretKey engineGenerateSecret (String algorithm)

Generates the shared secret.

Parameters
algorithm String: the algorithm to for the SecretKey
Returns
SecretKey the shared secret as a SecretKey of the specified algorithm.
Throws
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.

engineInit

Added in API level 1
void engineInit (Key key, 
                SecureRandom random)

Initializes this KeyAgreementSpi with the specified key and the specified randomness source.

Parameters
key Key: the key to initialize this key agreement.
random SecureRandom: the source for any randomness needed.
Throws
InvalidKeyException if the specified key cannot be used to initialize this key agreement.

engineInit

Added in API level 1
void engineInit (Key key, 
                AlgorithmParameterSpec params, 
                SecureRandom random)

Initializes this KeyAgreementSpi with the specified key, algorithm parameters and randomness source.

Parameters
key Key: the key to initialize this key agreement.
params AlgorithmParameterSpec: the parameters for this key agreement algorithm.
random SecureRandom: 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.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.