Package org.bouncycastle.crypto.engines
Class CramerShoupCoreEngine
java.lang.Object
org.bouncycastle.crypto.engines.CramerShoupCoreEngine
Essentially the Cramer-Shoup encryption / decryption algorithms according to
"A practical public key cryptosystem provably secure against adaptive chosen ciphertext attack." (Crypto 1998)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
CS exception for wrong cipher-texts -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertInput
(byte[] in, int inOff, int inLen) byte[]
convertOutput
(BigInteger result) encryptBlock
(BigInteger input) int
Return the maximum size for an input block to this engine.int
Return the maximum size for an output block to this engine.void
init
(boolean forEncryption, CipherParameters param) initialise the CramerShoup engine.void
init
(boolean forEncryption, CipherParameters param, String label) initialise the CramerShoup engine.protected SecureRandom
initSecureRandom
(boolean needed, SecureRandom provided)
-
Constructor Details
-
CramerShoupCoreEngine
public CramerShoupCoreEngine()
-
-
Method Details
-
init
initialise the CramerShoup engine.- Parameters:
forEncryption
- whether this engine should encrypt or decryptparam
- the necessary CramerShoup key parameters.label
- the label for labelled CS asString
-
init
initialise the CramerShoup engine.- Parameters:
forEncryption
- whether this engine should encrypt or decryptparam
- the necessary CramerShoup key parameters.
-
getInputBlockSize
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:
- maximum size for an input block.
-
getOutputBlockSize
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:
- maximum size for an output block.
-
convertInput
-
convertOutput
-
encryptBlock
-
decryptBlock
public BigInteger decryptBlock(CramerShoupCiphertext input) throws CramerShoupCoreEngine.CramerShoupCiphertextException -
initSecureRandom
-