|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.crypto.KeyAgreement
Engine class for algorithm independent Key Agreement.
Attention: This is not a SUN implementation!
This class has been developed by IAIK according to the documentation publically available.
For SUN´s documentation of this class see
http://java.sun.com/security/JCE1.2/spec/apidoc/index.html
This class provides the functionality of a key agreement algorithm. A key agreement algorithm (e.g. Diffie Hellman) is used for creating some shared secret between the involved parties by performing several phases, predicted by the specified algorithm.
A KeyAgreement object is created using a proper getInstance()
factory method.
After initializing the KeyAgreement object, each requested phase is performed by the
doPhase
method thereby using an extra flag for explicitly specifying if the actually executed phase
already is the last phase of this key agreement. Finally, each involved party creates the shared secret by calling
a generateSecret
method.
After the shared secret finally has been created, the KeyAgreement object is reset for being able to be used for further key agreements, either by using the same private key information as specified at the beginning of the key agreement, or using new parameters by properly initializing this KeyAgreement object again.
Constructor Summary | |
protected |
KeyAgreement(KeyAgreementSpi keyAgreeSpi,
Provider provider,
String algorithm)
Creates a KeyAgreement object. |
Method Summary | |
Key |
doPhase(Key key,
boolean lastPhase)
Returns the key resulting from the next phase of this key agreement. |
byte[] |
generateSecret()
Returns the shared secret finally generated by this key agreement algorithm. |
int |
generateSecret(byte[] sharedSecret,
int offset)
Generates the shared secret finishing this key agreement procedure and writes it into the given byte array, beginning at the given offset position. |
SecretKey |
generateSecret(String algorithm)
Returns the shared secret finally generated by this key agreement algorithm as SecretKey to be used for the secret key algorithm given by its name. |
String |
getAlgorithm()
Returns the standard name of the key agreement algorithm. |
static KeyAgreement |
getInstance(String algorithm)
Returns the default provider KeyAgreement implementation for the specified key agreement algorithm. |
static KeyAgreement |
getInstance(String algorithm,
String provider)
Returns a KeyAgreement object for the specified key agreement algorithm, implemented by the given provider. |
Provider |
getProvider()
Returns the provider used for creating this KeyAgreement object. |
void |
init(Key key)
Initializes this KeyAgreement with the given key, which constitutes the private key (including all required algorithm parameters) of some entity being involved in this key agreement procedure. |
void |
init(Key key,
AlgorithmParameterSpec params)
Initializes this KeyAgreement with the given key and algorithm parameters, where the given key constitutes the private key of some entity being involved in this key agreement procedure. |
void |
init(Key key,
AlgorithmParameterSpec params,
SecureRandom random)
Initializes this KeyAgreement with the given key, algorithm parameters, and random seed. |
void |
init(Key key,
SecureRandom random)
Initializes this KeyAgreement with the given key and random seed, where the given key constitutes the private key (including all required algorithm parameters) of some entity being involved in this key agreement procedure. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected KeyAgreement(KeyAgreementSpi keyAgreeSpi, Provider provider, String algorithm)
getInstance
factory methods for obtaining a KeyAgreemant object.keyAgreeSpi
- the SPI KeyAgreement implementation of the actual providerprovider
- the provideralgorithm
- the algorithmMethod Detail |
public final String getAlgorithm()
public static final KeyAgreement getInstance(String algorithm) throws NoSuchAlgorithmException
algorithm
- the standard name of the key agreement algorithmNoSuchAlgorithmException
- if this algorithm is not implementedpublic static final KeyAgreement getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm
- the standard name of the key agreement algorithmprovider
- the name of the provider as StringNoSuchAlgorithmException
- if this algorithm is not implementedNoSuchProviderException
- if the given provider cannot be fetchedpublic final Provider getProvider()
public final void init(Key key) throws InvalidKeyException
doFinal
methods will represent public key material of
another participated entity or key material resulting from some previously performed phase (if there
are more than two entities involved in the key agreement).key
- the private key information of the entity involved in the key agreementInvalidKeyException
- if the given key cannot be used for this key agreementpublic final void init(Key key, SecureRandom random) throws InvalidKeyException
doFinal
methods will represent public key material of
another participated entity or key material resulting from some previously performed phase (if there
are more than two entities involved in the key agreement).key
- the private key information of the entity involved in the key agreementrandom
- the random seedInvalidKeyException
- if the given key cannot be used for this key agreementpublic final void init(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException
doFinal
methods will represent public key material of
another participated entity or key material resulting from some previously performed phase (if there
are more than two entities involved in the key agreement).key
- the private key information of the entity involved in the key agreementparams
- the algorithm parameters used for this key agreement algorithmInvalidKeyException
- if the given key cannot be used for this key agreementInvalidAlgorithmParameterException
- if the given parameters do not match to this key agreement algorithmpublic final void init(Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
doFinal
methods will represent public key material of
another participated entity or key material resulting from some previously performed phase (if there
are more than two entities involved in the key agreement).key
- the private key information of the entity involved in the key agreementparams
- the algorithm parameters used for this key agreement algorithmrandom
- the random seedInvalidKeyException
- if the given key cannot be used for this key agreementInvalidAlgorithmParameterException
- if the given parameters do not match to this key agreement algorithmpublic final Key doPhase(Key key, boolean lastPhase) throws IllegalStateException, InvalidKeyException
key
- the required key for this phase, supplied by some other entity involved in this key agreementlastPhase
- true
if this is the last phase of this key agreemant, false
if notnull
if no key is returned by this phaseInvalidKeyException
- if the given key cannot be used for this key agreement algorithm / phaseIllegalStateException
- if the given phase cannot be performed in this state of the key agreement procedurepublic final byte[] generateSecret() throws IllegalStateException
IllegalStateException
- if this key agreement procedure yet is not ready for being finished by generating the shared secretpublic final int generateSecret(byte[] sharedSecret, int offset) throws IllegalStateException, ShortBufferException
sharedSecret
- the byte array to which the generated secret has to be writtenoffset
- the offset indicating the start position within the output byte array
to which to write the generated shared secretIllegalStateException
- if this key agreement procedure yet is not ready for being finished by generating the shared secretShortBufferException
- if the given output buffer is too small for holding the generated secretpublic final SecretKey generateSecret(String algorithm) throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException
algorithm
- the name of the secret key algorithm for which the generated secret key shall be usedIllegalStateException
- if this key agreement procedure yet is not ready for being
finished by generating the shared secretNoSuchAlgorithmException
- if the given secret key algorithm is not supportedInvalidKeyException
- if the generated shared secret cannot be returned as SecretKey
matching to the given algorithm
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |