FileDocCategorySizeDatePackage
ElGamalKeyPairGenerator.javaAPI DocExample1002Tue Feb 24 10:53:12 GMT 1998oreilly.jonathan.crypto

ElGamalKeyPairGenerator

public class ElGamalKeyPairGenerator extends KeyPairGeneratorSpi

Fields Summary
private int
mStrength
private SecureRandom
mSecureRandom
Constructors Summary
Methods Summary
public java.security.KeyPairgenerateKeyPair()

    if (mSecureRandom == null) {
      mStrength = 1024;
      mSecureRandom = new SecureRandom();
    }
    BigInteger p = new BigInteger(mStrength, 16, mSecureRandom);
    BigInteger g = new BigInteger(mStrength - 1, mSecureRandom);
    BigInteger x = new BigInteger(mStrength - 1, mSecureRandom);
    BigInteger y = g.modPow(x, p);
    
    ElGamalPublicKey publicKey = new ElGamalPublicKey(y, g, p);
    ElGamalPrivateKey privateKey = new ElGamalPrivateKey(x, g, p);
    return new KeyPair(publicKey, privateKey);
  
public voidinitialize(int strength, java.security.SecureRandom random)

  
  // Strength is interpreted as the bit length of p.
        
    mStrength = strength;
    mSecureRandom = random;