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

public Class CramerShoupCoreEngine

extends Object
Class Inheritance
Imports
java.math.BigInteger, java.security.SecureRandom, org.bouncycastle.crypto.CipherParameters, .CryptoServicesRegistrar, .DataLengthException, .Digest, org.bouncycastle.crypto.constraints.ConstraintUtils, .DefaultServiceProperties, org.bouncycastle.crypto.params.CramerShoupKeyParameters, .CramerShoupPrivateKeyParameters, .CramerShoupPublicKeyParameters, .ParametersWithRandom, org.bouncycastle.util.BigIntegers, .Strings

Essentially the Cramer-Shoup encryption / decryption algorithms according to "A practical public key cryptosystem provably secure against adaptive chosen ciphertext attack." (Crypto 1998)

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CramerShoupCoreEngine.CramerShoupCiphertextException

CS exception for wrong cipher-texts

Field Summary

Modifier and TypeField and Description
private boolean
private CramerShoupKeyParameters
private byte[]
private static final BigInteger
private SecureRandom

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public BigInteger
convertInput(byte[] in, int inOff, int inLen)

public byte[]
public BigInteger
public CramerShoupCiphertext
private BigInteger
public int

Returns:

maximum size for an input block.
getInputBlockSize
()

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

public int

Returns:

maximum size for an output block.
getOutputBlockSize
()

Return the maximum size for an output block to this engine.

public void
init(boolean
whether this engine should encrypt or decrypt
forEncryption
,
CipherParameters
the necessary CramerShoup key parameters.
param
,
String
the label for labelled CS as String
label
)

initialise the CramerShoup engine.

public void
init(boolean
whether this engine should encrypt or decrypt
forEncryption
,
CipherParameters
the necessary CramerShoup key parameters.
param
)

initialise the CramerShoup engine.

protected SecureRandom
initSecureRandom(boolean needed, SecureRandom provided)

private boolean
isValidMessage(BigInteger m, BigInteger p)

just checking whether the message m is actually less than the group order p

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

forEncryptionback to summary
private boolean forEncryption
keyback to summary
private CramerShoupKeyParameters key
labelback to summary
private byte[] label
ONEback to summary
private static final BigInteger ONE
randomback to summary
private SecureRandom random

Constructor Detail

CramerShoupCoreEngineback to summary
public CramerShoupCoreEngine()

Method Detail

convertInputback to summary
public BigInteger convertInput(byte[] in, int inOff, int inLen)
convertOutputback to summary
public byte[] convertOutput(BigInteger result)
decryptBlockback to summary
public BigInteger decryptBlock(CramerShoupCiphertext input) throws CramerShoupCiphertextException
encryptBlockback to summary
public CramerShoupCiphertext encryptBlock(BigInteger input)
generateRandomElementback to summary
private BigInteger generateRandomElement(BigInteger p, SecureRandom random)
getInputBlockSizeback to summary
public int getInputBlockSize()

Return the maximum size for an input block to this engine. For Cramer Shoup this is always one byte less than the key size on encryption, and the same length as the key size on decryption.

Todo

correct?

Returns:int

maximum size for an input block.

getOutputBlockSizeback to summary
public int getOutputBlockSize()

Return the maximum size for an output block to this engine. For Cramer Shoup this is always one byte less than the key size on decryption, and the same length as the key size on encryption.

Todo

correct?

Returns:int

maximum size for an output block.

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

initialise the CramerShoup engine.

Parameters
forEncryption:boolean

whether this engine should encrypt or decrypt

param:CipherParameters

the necessary CramerShoup key parameters.

label:String

the label for labelled CS as String

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

initialise the CramerShoup engine.

Parameters
forEncryption:boolean

whether this engine should encrypt or decrypt

param:CipherParameters

the necessary CramerShoup key parameters.

initSecureRandomback to summary
protected SecureRandom initSecureRandom(boolean needed, SecureRandom provided)
isValidMessageback to summary
private boolean isValidMessage(BigInteger m, BigInteger p)

just checking whether the message m is actually less than the group order p

org.bouncycastle.crypto.engines back to summary

public Class CramerShoupCoreEngine.CramerShoupCiphertextException

extends Exception
Class Inheritance

CS exception for wrong cipher-texts

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Constructor Detail

CramerShoupCiphertextExceptionback to summary
public CramerShoupCiphertextException(String msg)