public class DHKeyAgreement extends KeyAgreement
To generate a secret key value, the local party private key and the other party public key must be present. If parameters are missing from any of the keys, they should be known from the application envrionment and must be set before using this class.
DHKey, DHPublicKey, DHPrivateKey| Constructor and Description |
|---|
DHKeyAgreement()
Create a new uninitialized instance of
DHKeyAgreement. |
DHKeyAgreement(DHPrivateKey privKey)
Create a new instance of
DHKeyAgreement with the specified local party private key. |
DHKeyAgreement(DHPrivateKey privKey, DHPublicKey pubKey)
Create a new instance of
DHKeyAgreement with the specified local party private key and the other party public key. |
DHKeyAgreement(DHPublicKey pubKey)
Create a new instance of
DHKeyAgreement with the specified other party public key. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
algName()
Returns the name of the key agreement algorithm.
|
byte[] |
generateSecret()
Generate the shared secret value from the local party private key and the other party public key.
|
AlgorithmIdentifier |
getAlgID()
Gets the algorithm identifier of this key agreeement.
|
PublicKey |
getPublicKey()
Returns the public (other party's) key.
|
void |
setAlgID(AlgorithmIdentifier algID)
Sets the algorith identifier of the key agreement object.
|
void |
setPrivateKey(PrivateKey privKey)
Sets the local party private key for generating secret value.
|
void |
setPublicKey(PublicKey pubKey)
Sets the other party public key for generating secret value.
|
getInstance, getInstance, getInstancepublic DHKeyAgreement()
DHKeyAgreement.public DHKeyAgreement(DHPrivateKey privKey) throws InvalidKeyException
DHKeyAgreement with the specified local party private key.privKey - The private key for the local party.InvalidKeyExceptionpublic DHKeyAgreement(DHPublicKey pubKey) throws InvalidKeyException
DHKeyAgreement with the specified other party public key.pubKey - The public key for the other party.InvalidKeyExceptionpublic DHKeyAgreement(DHPrivateKey privKey, DHPublicKey pubKey) throws InvalidKeyException
DHKeyAgreement with the specified local party private key and the other party public key.privKey - The private key for the local party.pubKey - The public key for the other party.InvalidKeyExceptionpublic void setAlgID(AlgorithmIdentifier algID) throws AlgorithmIdentifierException
KeyAgreementsetAlgID in class KeyAgreementalgID - The AlgorithmIdentifier to use for this KeyAgreement.AlgorithmIdentifierExceptionpublic AlgorithmIdentifier getAlgID()
KeyAgreementgetAlgID in class KeyAgreementAlgorithmIdentifier representing the algorithm used in this key agreement.public void setPrivateKey(PrivateKey privKey) throws InvalidKeyException
setPrivateKey in class KeyAgreementprivKey - The private key for the local party.InvalidKeyExceptionpublic void setPublicKey(PublicKey pubKey) throws InvalidKeyException
setPublicKey in class KeyAgreementpubKey - The public key of the other party.InvalidKeyExceptionpublic PublicKey getPublicKey()
getPublicKey in class KeyAgreementpublic java.lang.String algName()
algName in class KeyAgreement
public byte[] generateSecret()
throws KeyAgreementException
KeyAgreementgenerateSecret in class KeyAgreementKeyAgreementException