org.bouncycastle.crypto.engines

Class NaccacheSternEngine

public class NaccacheSternEngine extends Object implements AsymmetricBlockCipher

NaccacheStern Engine. For details on this cipher, please see http://www.gemplus.com/smart/rd/publications/pdf/NS98pkcs.pdf
Method Summary
byte[]addCryptedBlocks(byte[] block1, byte[] block2)
Adds the contents of two encrypted blocks mod sigma
byte[]encrypt(BigInteger plain)
Encrypts a BigInteger aka Plaintext with the public key.
intgetInputBlockSize()
Returns the input block size of this algorithm.
intgetOutputBlockSize()
Returns 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)

Method Detail

addCryptedBlocks

public byte[] addCryptedBlocks(byte[] block1, byte[] block2)
Adds the contents of two encrypted blocks mod sigma

Parameters: block1 the first encrypted block block2 the second encrypted block

Returns: encrypt((block1 + block2) mod sigma)

Throws: InvalidCipherTextException

encrypt

public byte[] encrypt(BigInteger plain)
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())

getInputBlockSize

public int getInputBlockSize()
Returns the input block size of this algorithm.

See Also: getInputBlockSize

getOutputBlockSize

public int getOutputBlockSize()
Returns the output block size of this algorithm.

See Also: getOutputBlockSize

init

public void init(boolean forEncryption, CipherParameters param)
Initializes this algorithm. Must be called before all other Functions.

See Also: AsymmetricBlockCipher

processBlock

public byte[] processBlock(byte[] in, int inOff, int len)
Process a single Block using the Naccache-Stern algorithm.

See Also: (byte[], int, int)

processData

public byte[] processData(byte[] data)
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

setDebug

public void setDebug(boolean debug)