cryptix.provider.elgamal
public class BaseElGamalKeyPairGenerator extends KeyPairGenerator implements ElGamalKeyPairGenerator
Users wishing to indicate the prime or base, and to generate a key pair suitable for use with the ElGamal signature or encryption algorithms typically
getInstance
method with "ElGamal"
as its argument.
initialize
methods.
generateKeyPair
method, as often as desired.
The algorithm used to generate ElGamal keys is as follows:
If p and g are specified in advance then only the last two steps are needed.
References:
Copyright © 1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.6 $
Since: Cryptix 2.2.2
See Also: java.security.KeyPairGenerator
Field Summary | |
---|---|
protected BigInteger | g |
protected BigInteger | p |
protected SecureRandom | source |
Constructor Summary | |
---|---|
BaseElGamalKeyPairGenerator() |
Method Summary | |
---|---|
KeyPair | generateKeyPair()
Generates a key pair. |
ElGamalParams | generateParams(int primeLen, SecureRandom random)
Generates new parameters, p and g. |
void | initialize(ElGamalParams params, SecureRandom random)
Initialises the key pair generator using the prime and base from
the specified ElGamalParams object.
|
void | initialize(BigInteger prime, BigInteger base, SecureRandom random)
Initialises the key pair generator using the specified prime
(p) and base (g). |
void | initialize(int primeLen, SecureRandom random)
Initialises the key pair generator for a given prime length,
without parameters.
|
void | initialize(int primeLen, boolean genParams, SecureRandom random)
Initialises the key pair generator for a given prime length,
without parameters.
|
generateKeyPair
.
Parameters: primeLen the prime length, in bits. Valid lengths are any integer >= 256. random the random bit source to use to generate the parameters.
Throws: InvalidParameterException if the prime length is less than 256.
Parameters: params the parameters to use to generate the keys. random the random bit source to use to generate key bits.
Throws: NullPointerException if params == null || random == null InvalidParameterException if the parameters passed are invalid.
An InvalidParameterException will be thrown if base >= prime
.
Parameters: prime the prime to be used, as a java.math.BigInteger base the base to be used, as a java.math.BigInteger random the random bit source to use to generate key bits.
Throws: NullPointerException if prime == null || base == null || random == null InvalidParameterException if the parameters passed are invalid.
Parameters: primeLen the prime length, in bits. Valid lengths are any integer >= 256. random the random bit source to use to generate key bits.
Throws: InvalidParameterException if the prime length is less than 256.
If genParams is true, this method will generate new p and g parameters. If it is false, the method will use precomputed parameters for the prime length requested. If there are no precomputed parameters for that prime length, an exception will be thrown. It is guaranteed that there will always be default parameters for a prime length of 512 bits.
[Future versions will probably also support 1024, 1536, 2048, 3072, and 4096 bits.]
Parameters: primeLen the prime length, in bits. Valid lengths are any integer >= 256. random the random bit source to use to generate key bits. genParams whether to generate new parameters for the prime length requested.
Throws: InvalidParameterException if the prime length is less than 256, or if genParams is false and there are not precomputed parameters for the prime length requested.