cryptix.provider.elgamal
Class ElGamalAlgorithm
java.lang.Object
cryptix.provider.elgamal.ElGamalAlgorithm
public final class ElGamalAlgorithm
extends java.lang.Object
A class that calculates the ElGamal family of algorithms (encryption,
decryption, signing and verification).
References:
- Bruce Schneier,
"Section 19.6 ElGamal,"
Applied Cryptography, 2nd edition,
John Wiley & Sons, 1996.
Copyright © 1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.2 $
static BigInteger | decrypt(BigInteger a, BigInteger b, BigInteger p, BigInteger g, BigInteger x) - The decryption algorithm for ElGamal.
|
static void | encrypt(BigInteger M, BigInteger[] ab, BigInteger p, BigInteger g, BigInteger y, Random rng) - The encryption algorithm for ElGamal.
|
static void | sign(BigInteger M, BigInteger[] ab, BigInteger p, BigInteger g, BigInteger x, Random rng) - The signature algorithm for ElGamal.
|
static boolean | verify(BigInteger M, BigInteger a, BigInteger b, BigInteger p, BigInteger g, BigInteger y) - The verification algorithm for ElGamal.
|
decrypt
public static BigInteger decrypt(BigInteger a,
BigInteger b,
BigInteger p,
BigInteger g,
BigInteger x)
The decryption algorithm for ElGamal. a and b are the
two parts of the ciphertext (using the same convention as given in
Schneier).
a
- the first part of the ciphertext.b
- the second part of the ciphertext.p
- the prime from the private key.g
- the generator from the private key.x
- the value of x from the private key.
encrypt
public static void encrypt(BigInteger M,
BigInteger[] ab,
BigInteger p,
BigInteger g,
BigInteger y,
Random rng)
The encryption algorithm for ElGamal. The two parts of the ciphertext,
a and b, will be stored in ab[0]
and
ab[1]
respectively.
M
- the plaintext.ab
- a 2-element BigInteger array in which to store the ciphertext.p
- the prime from the public key.g
- the generator from the public key.y
- the value of y from the public key.rng
- a random number generator to be used for encryption.
sign
public static void sign(BigInteger M,
BigInteger[] ab,
BigInteger p,
BigInteger g,
BigInteger x,
Random rng)
The signature algorithm for ElGamal. ab should be a two-element
BigInteger array. The two parts of the signature, a and b,
will be stored in ab[0]
and ab[1]
respectively.
M
- the value to be signed.ab
- an array in which to store the result.p
- the prime from the private key.g
- the generator from the private key.x
- the value of x from the private key.rng
- a random number generator to be used for signing.
verify
public static boolean verify(BigInteger M,
BigInteger a,
BigInteger b,
BigInteger p,
BigInteger g,
BigInteger y)
The verification algorithm for ElGamal. Returns true iff the signature was
verified successfully.
M
- the value that was signed.a
- the first part of the signature.b
- the second part of the signature.p
- the prime from the public key.g
- the generator from the public key.y
- the value of y from the public key.
- true iff the signature is valid.