Package org.bouncycastle.crypto.engines
Class NaccacheSternEngine
java.lang.Object
org.bouncycastle.crypto.engines.NaccacheSternEngine
- All Implemented Interfaces:
AsymmetricBlockCipher
NaccacheStern Engine. For details on this cipher, please see
https://www.gemplus.com/smart/rd/publications/pdf/NS98pkcs.pdf
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]addCryptedBlocks(byte[] block1, byte[] block2) Adds the contents of two encrypted blocks mod sigmabyte[]encrypt(BigInteger plain) Encrypts a BigInteger aka Plaintext with the public key.intReturns the input block size of this algorithm.intReturns the output block size of this algorithm.voidinit(boolean forEncryption, CipherParameters param) Initializes this algorithm.byte[]processBlock(byte[] in, int inOff, int len) Process a single Block using the Naccache-Stern algorithm.byte[]processData(byte[] data) Convenience Method for data exchange with the cipher.voidsetDebug(boolean debug)
-
Constructor Details
-
NaccacheSternEngine
public NaccacheSternEngine()
-
-
Method Details
-
init
Initializes this algorithm. Must be called before all other Functions.- Specified by:
initin interfaceAsymmetricBlockCipher- Parameters:
forEncryption- if true the cipher is initialised for encryption, if false for decryption.param- the key and other data required by the cipher.- See Also:
-
setDebug
public void setDebug(boolean debug) -
getInputBlockSize
public int getInputBlockSize()Returns the input block size of this algorithm.- Specified by:
getInputBlockSizein interfaceAsymmetricBlockCipher- Returns:
- maximum size for an input block.
- See Also:
-
getOutputBlockSize
public int getOutputBlockSize()Returns the output block size of this algorithm.- Specified by:
getOutputBlockSizein interfaceAsymmetricBlockCipher- Returns:
- maximum size of the output block produced by the cipher.
- See Also:
-
processBlock
Process a single Block using the Naccache-Stern algorithm.- Specified by:
processBlockin interfaceAsymmetricBlockCipher- Parameters:
in- the input datainOff- offset into the in array where the data startslen- the length of the block to be processed.- Returns:
- the resulting byte array of the encryption/decryption process.
- Throws:
InvalidCipherTextException- data decrypts improperly.- See Also:
-
encrypt
Encrypts a BigInteger aka Plaintext with the public key.- Parameters:
plain- The BigInteger to encrypt- Returns:
- The byte[] representation of the encrypted BigInteger (i.e. crypted.toByteArray())
-
addCryptedBlocks
Adds the contents of two encrypted blocks mod sigma- Parameters:
block1- the first encrypted blockblock2- the second encrypted block- Returns:
- encrypt((block1 + block2) mod sigma)
- Throws:
InvalidCipherTextException
-
processData
Convenience Method for data exchange with the cipher. Determines blocksize and splits data to blocksize.- Parameters:
data- the data to be processed- Returns:
- the data after it went through the NaccacheSternEngine.
- Throws:
InvalidCipherTextException
-