Top Description Fields Constructors Methods
org.bouncycastle.crypto.agreement

public Class DHAgreement

extends Object
Class Inheritance
Imports
java.math.BigInteger, java.security.SecureRandom, org.bouncycastle.crypto.AsymmetricCipherKeyPair, .CipherParameters, .CryptoServicesRegistrar, org.bouncycastle.crypto.generators.DHKeyPairGenerator, org.bouncycastle.crypto.params.AsymmetricKeyParameter, .DHKeyGenerationParameters, .DHParameters, .DHPrivateKeyParameters, .DHPublicKeyParameters, .ParametersWithRandom

a Diffie-Hellman key exchange engine.

Note

This uses MTI/A0 key agreement in order to make the key agreement secure against passive attacks. If you're doing Diffie-Hellman and both parties have long term public keys you should look at using this. For further information have a look at RFC 2631.

It's possible to extend this to more than two parties as well, for the moment that is left as an exercise for the reader.

Field Summary

Modifier and TypeField and Description
private DHParameters
private DHPrivateKeyParameters
private static final BigInteger
private BigInteger
private SecureRandom

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public BigInteger
calculateAgreement(DHPublicKeyParameters pub, BigInteger message)

given a message from a given party and the corresponding public key, calculate the next message in the agreement sequence.

public BigInteger
calculateMessage()

calculate our initial message.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dhParamsback to summary
private DHParameters dhParams
keyback to summary
private DHPrivateKeyParameters key
ONEback to summary
private static final BigInteger ONE
privateValueback to summary
private BigInteger privateValue
randomback to summary
private SecureRandom random

Constructor Detail

DHAgreementback to summary
public DHAgreement()

Method Detail

calculateAgreementback to summary
public BigInteger calculateAgreement(DHPublicKeyParameters pub, BigInteger message)

given a message from a given party and the corresponding public key, calculate the next message in the agreement sequence. In this case this will represent the shared secret.

calculateMessageback to summary
public BigInteger calculateMessage()

calculate our initial message.

initback to summary
public void init(CipherParameters param)