public class NaccacheSternEngine extends java.lang.Object implements AsymmetricBlockCipher
Modifier and Type | Field and Description |
---|---|
private boolean |
debug |
private boolean |
forEncryption |
private NaccacheSternKeyParameters |
key |
private java.util.Vector[] |
lookup |
private static java.math.BigInteger |
ONE |
private static java.math.BigInteger |
ZERO |
Constructor and Description |
---|
NaccacheSternEngine() |
Modifier and Type | Method and Description |
---|---|
byte[] |
addCryptedBlocks(byte[] block1,
byte[] block2)
Adds the contents of two encrypted blocks mod sigma
|
private static java.math.BigInteger |
chineseRemainder(java.util.Vector congruences,
java.util.Vector primes)
Computes the integer x that is expressed through the given primes and the
congruences with the chinese remainder theorem (CRT).
|
byte[] |
encrypt(java.math.BigInteger plain)
Encrypts a BigInteger aka Plaintext with the public key.
|
int |
getInputBlockSize()
Returns the input block size of this algorithm.
|
int |
getOutputBlockSize()
Returns the output block size of this algorithm.
|
void |
init(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.
|
void |
setDebug(boolean debug) |
private boolean forEncryption
private NaccacheSternKeyParameters key
private java.util.Vector[] lookup
private boolean debug
private static java.math.BigInteger ZERO
private static java.math.BigInteger ONE
public void init(boolean forEncryption, CipherParameters param)
init
in interface AsymmetricBlockCipher
forEncryption
- if true the cipher is initialised for
encryption, if false for decryption.param
- the key and other data required by the cipher.AsymmetricBlockCipher.init(boolean,
org.spongycastle.crypto.CipherParameters)
public void setDebug(boolean debug)
public int getInputBlockSize()
getInputBlockSize
in interface AsymmetricBlockCipher
AsymmetricBlockCipher.getInputBlockSize()
public int getOutputBlockSize()
getOutputBlockSize
in interface AsymmetricBlockCipher
AsymmetricBlockCipher.getOutputBlockSize()
public byte[] processBlock(byte[] in, int inOff, int len) throws InvalidCipherTextException
processBlock
in interface AsymmetricBlockCipher
in
- the input datainOff
- offset into the in array where the data startslen
- the length of the block to be processed.InvalidCipherTextException
- data decrypts improperly.AsymmetricBlockCipher.processBlock(byte[],
int, int)
public byte[] encrypt(java.math.BigInteger plain)
plain
- The BigInteger to encryptpublic byte[] addCryptedBlocks(byte[] block1, byte[] block2) throws InvalidCipherTextException
block1
- the first encrypted blockblock2
- the second encrypted blockInvalidCipherTextException
public byte[] processData(byte[] data) throws InvalidCipherTextException
data
- the data to be processedInvalidCipherTextException
private static java.math.BigInteger chineseRemainder(java.util.Vector congruences, java.util.Vector primes)
congruences
- the congruences c_iprimes
- the primes p_i