Class NTRUEngine
java.lang.Object
org.bouncycastle.pqc.legacy.crypto.ntru.NTRUEngine
- All Implemented Interfaces:
AsymmetricBlockCipher
Encrypts, decrypts data and generates key pairs.
The parameter p is hardcoded to 3.
The parameter p is hardcoded to 3.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected IntegerPolynomialdecrypt(IntegerPolynomial e, Polynomial priv_t, IntegerPolynomial priv_fp) protected IntegerPolynomialencrypt(IntegerPolynomial m, TernaryPolynomial r, IntegerPolynomial pubKey) intreturns the largest size an input block can be.intreturns the maximum size of the block produced by this cipher.voidinit(boolean forEncryption, CipherParameters parameters) initialise the cipher.byte[]processBlock(byte[] in, int inOff, int len) process the block of len bytes stored in in from offset inOff.
-
Constructor Details
-
NTRUEngine
public NTRUEngine()Constructs a new instance with a set of encryption parameters.
-
-
Method Details
-
init
Description copied from interface:AsymmetricBlockCipherinitialise the cipher.- Specified by:
initin interfaceAsymmetricBlockCipher- Parameters:
forEncryption- if true the cipher is initialised for encryption, if false for decryption.parameters- the key and other data required by the cipher.
-
getInputBlockSize
public int getInputBlockSize()Description copied from interface:AsymmetricBlockCipherreturns the largest size an input block can be.- Specified by:
getInputBlockSizein interfaceAsymmetricBlockCipher- Returns:
- maximum size for an input block.
-
getOutputBlockSize
public int getOutputBlockSize()Description copied from interface:AsymmetricBlockCipherreturns the maximum size of the block produced by this cipher.- Specified by:
getOutputBlockSizein interfaceAsymmetricBlockCipher- Returns:
- maximum size of the output block produced by the cipher.
-
processBlock
Description copied from interface:AsymmetricBlockCipherprocess the block of len bytes stored in in from offset inOff.- 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.
-
encrypt
protected IntegerPolynomial encrypt(IntegerPolynomial m, TernaryPolynomial r, IntegerPolynomial pubKey) -
decrypt
protected IntegerPolynomial decrypt(IntegerPolynomial e, Polynomial priv_t, IntegerPolynomial priv_fp) - Parameters:
e-priv_t- a polynomial such that iffastFp=true,f=1+3*priv_t; otherwise,f=priv_tpriv_fp-- Returns:
- an IntegerPolynomial representing the output.
-