FileDocCategorySizeDatePackage
DHKeyPairGenerator.javaAPI DocAzureus 3.0.3.41589Tue Jun 08 05:12:58 BST 2004org.bouncycastle.crypto.generators

DHKeyPairGenerator

public class DHKeyPairGenerator extends Object implements org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
a Diffie-Helman key pair generator. This generates keys consistent for use in the MTI/A0 key agreement protocol as described in "Handbook of Applied Cryptography", Pages 516-519.

Fields Summary
private org.bouncycastle.crypto.params.DHKeyGenerationParameters
param
Constructors Summary
Methods Summary
public org.bouncycastle.crypto.AsymmetricCipherKeyPairgenerateKeyPair()

        BigInteger      p, g, x, y;
        int             qLength = param.getStrength() - 1;
        DHParameters    dhParams = param.getParameters();

        p = dhParams.getP();
        g = dhParams.getG();
    
        //
        // calculate the private key
        //
		x = new BigInteger(qLength, param.getRandom());

        //
        // calculate the public key.
        //
        y = g.modPow(x, p);

        return new AsymmetricCipherKeyPair(
                new DHPublicKeyParameters(y, dhParams),
                new DHPrivateKeyParameters(x, dhParams));
    
public voidinit(org.bouncycastle.crypto.KeyGenerationParameters param)

        this.param = (DHKeyGenerationParameters)param;