All Packages Class Hierarchy This Package Previous Next Index
Class cryptix.provider.elgamal.RawElGamalCipher
java.lang.Object
|
+----java.security.IJCE_Traceable
|
+----java.security.Cipher
|
+----cryptix.provider.elgamal.RawElGamalCipher
- public class RawElGamalCipher
- extends Cipher
- implements AsymmetricCipher, Cloneable
The raw ElGamal encryption algorithm.
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 $
- Author:
- David Hopwood
-
RawElGamalCipher()
- Constructor for a RawElGamalCipher.
-
engineCiphertextBlockSize()
- SPI: Return the ciphertext block size, in bytes.
-
engineGetParameter(String)
- SPI: Return an algorithm-specific parameter.
-
engineInitDecrypt(Key)
- SPI: Initializes the cipher for decryption, using the
given private key.
-
engineInitEncrypt(Key)
- SPI: Initializes the cipher for encryption, using the
given public key.
-
enginePlaintextBlockSize()
- SPI: Return the plaintext block size, in bytes.
-
engineSetParameter(String, Object)
- SPI: Set an algorithm-specific parameter.
-
engineUpdate(byte[], int, int, byte[], int)
- SPI: DOCUMENT ME
-
main(String[])
- Entry point for very basic
self_test
.
-
self_test(PrintWriter)
-
RawElGamalCipher
public RawElGamalCipher()
- Constructor for a RawElGamalCipher.
engineInitEncrypt
protected void engineInitEncrypt(Key key) throws KeyException
- SPI: Initializes the cipher for encryption, using the
given public key. The key object must implement
java.security.interfaces.ElGamalPublicKey.
- Parameters:
- key - the public key
- Throws: InvalidKeyException
- if !(key instanceof
java.security.interfaces.ElGamalPublicKey), or the
key is otherwise invalid
- Overrides:
- engineInitEncrypt in class Cipher
engineInitDecrypt
protected void engineInitDecrypt(Key key) throws KeyException
- SPI: Initializes the cipher for decryption, using the
given private key. The key object must implement
java.security.interfaces.ElGamalPrivateKey.
- Parameters:
- key - the private key
- Throws: InvalidKeyException
- if !(key instanceof
java.security.interfaces.ElGamalPrivateKey), or the
key is otherwise invalid
- Overrides:
- engineInitDecrypt in class Cipher
enginePlaintextBlockSize
protected int enginePlaintextBlockSize()
- SPI: Return the plaintext block size, in bytes. For ElGamal this
is the number of bytes needed for a bit string one bit shorter than the
prime, p.
If the key has not been set, this method throws CryptixException (a subclass
of ProviderException).
- Returns:
- the plaintext block size
- Overrides:
- enginePlaintextBlockSize in class Cipher
engineCiphertextBlockSize
protected int engineCiphertextBlockSize()
- SPI: Return the ciphertext block size, in bytes. For ElGamal this
is double the number of bytes needed to represent p-1.
If the key has not been set, this method throws CryptixException (a subclass
of ProviderException).
- Returns:
- the ciphertext block size
- Overrides:
- engineCiphertextBlockSize in class Cipher
engineSetParameter
protected void engineSetParameter(String param,
Object value)
- SPI: Set an algorithm-specific parameter.
ElGamal has one algorithm-specific parameter called "random", of type
java.util.Random, which specifies the source of random bits used to
generate the k values needed for encryption. If this parameter
is not set when initKey
is called, the result of
new SecureRandom()
will be used.
You can set the "random" parameter using the following code:
try {
elgamal.setParameter("random", existingSecureRandom);
} catch (InvalidParameterException e) { /* ignore */ }
elgamal.initEncrypt(publicKey);
This is not useful if the cipher will only be used for decryption.
- Parameters:
- param - the string identifier of the parameter.
- value - the parameter value.
- Throws: InvalidParameterException
- if (!(param.equals("random") &&
value instanceof java.util.Random))
- Overrides:
- engineSetParameter in class Cipher
engineGetParameter
protected Object engineGetParameter(String param)
- SPI: Return an algorithm-specific parameter.
ElGamal has one algorithm-specific parameter called "random", as described
above. It is guaranteed to be a subclass
of java.util.Random. Calling this method with a param string
other than "random" will return null.
- Parameters:
- param - the string name of the parameter.
- Returns:
- the object that represents the parameter value, or null if there
is none.
- Overrides:
- engineGetParameter in class Cipher
engineUpdate
protected int engineUpdate(byte in[],
int inOffset,
int inLen,
byte out[],
int outOffset)
- SPI: DOCUMENT ME
- Overrides:
- engineUpdate in class Cipher
main
public static final void main(String args[])
- Entry point for very basic
self_test
.
self_test
public static void self_test(PrintWriter out) throws KeyException
All Packages Class Hierarchy This Package Previous Next Index