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

DSAKeyPairGenerator

public class DSAKeyPairGenerator extends Object implements org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
a DSA key pair generator. This generates DSA keys in line with the method described in FIPS 186-2.

Fields Summary
private static BigInteger
ZERO
private org.bouncycastle.crypto.params.DSAKeyGenerationParameters
param
Constructors Summary
Methods Summary
public org.bouncycastle.crypto.AsymmetricCipherKeyPairgenerateKeyPair()

        BigInteger      p, q, g, x, y;
        DSAParameters   dsaParams = param.getParameters();
        SecureRandom    random = param.getRandom();

        q = dsaParams.getQ();
        p = dsaParams.getP();
        g = dsaParams.getG();

        do
        {
            x = new BigInteger(160, random);
        }
        while (x.equals(ZERO)  || x.compareTo(q) >= 0);

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

        return new AsymmetricCipherKeyPair(
                new DSAPublicKeyParameters(y, dsaParams),
                new DSAPrivateKeyParameters(x, dsaParams));
    
public voidinit(org.bouncycastle.crypto.KeyGenerationParameters param)


      
         
    
        this.param = (DSAKeyGenerationParameters)param;