Top Description Fields Constructors Methods
org.bouncycastle.crypto.engines

public Class ElGamalEngine

extends Object
implements AsymmetricBlockCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.AsymmetricBlockCipher
Imports
java.math.BigInteger, java.security.SecureRandom, org.bouncycastle.crypto.AsymmetricBlockCipher, .CipherParameters, .CryptoServicesRegistrar, .DataLengthException, org.bouncycastle.crypto.constraints.ConstraintUtils, .DefaultServiceProperties, org.bouncycastle.crypto.params.ElGamalKeyParameters, .ElGamalPrivateKeyParameters, .ElGamalPublicKeyParameters, .ParametersWithRandom, org.bouncycastle.util.BigIntegers

this does your basic ElGamal algorithm.

Field Summary

Modifier and TypeField and Description
private int
private boolean
private ElGamalKeyParameters
private static final BigInteger
private SecureRandom
private static final BigInteger
private static final BigInteger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

maximum size for an input block.
getInputBlockSize
()

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.getInputBlockSize.

Return the maximum size for an input block to this engine.
public int

Returns:

maximum size for an output block.
getOutputBlockSize
()

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.getOutputBlockSize.

Return the maximum size for an output block to this engine.
public void
init(boolean
true if we are encrypting, false otherwise.
forEncryption
,
CipherParameters
the necessary ElGamal key parameters.
param
)

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.init.

initialise the ElGamal engine.
public byte[]

Returns:

the result of the ElGamal process.
processBlock
(byte[]
the input array.
in
,
int
the offset into the input buffer where the data starts.
inOff
,
int
the length of the data to be processed.
inLen
)

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.processBlock.

Process a single block using the basic ElGamal algorithm.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bitSizeback to summary
private int bitSize
forEncryptionback to summary
private boolean forEncryption
keyback to summary
private ElGamalKeyParameters key
ONEback to summary
private static final BigInteger ONE
randomback to summary
private SecureRandom random
TWOback to summary
private static final BigInteger TWO
ZEROback to summary
private static final BigInteger ZERO

Constructor Detail

ElGamalEngineback to summary
public ElGamalEngine()

Method Detail

getInputBlockSizeback to summary
public int getInputBlockSize()

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.getInputBlockSize.

Return the maximum size for an input block to this engine. For ElGamal this is always one byte less than the size of P on encryption, and twice the length as the size of P on decryption.

Returns:int

maximum size for an input block.

getOutputBlockSizeback to summary
public int getOutputBlockSize()

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.getOutputBlockSize.

Return the maximum size for an output block to this engine. For ElGamal this is always one byte less than the size of P on decryption, and twice the length as the size of P on encryption.

Returns:int

maximum size for an output block.

initback to summary
public void init(boolean forEncryption, CipherParameters param)

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.init.

initialise the ElGamal engine.

Parameters
forEncryption:boolean

true if we are encrypting, false otherwise.

param:CipherParameters

the necessary ElGamal key parameters.

processBlockback to summary
public byte[] processBlock(byte[] in, int inOff, int inLen)

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.processBlock.

Process a single block using the basic ElGamal algorithm.

Parameters
in:byte[]

the input array.

inOff:int

the offset into the input buffer where the data starts.

inLen:int

the length of the data to be processed.

Returns:byte[]

the result of the ElGamal process.

Exceptions
DataLengthException:
the input block is too large.