Class Nil
java.lang.Object
com.coderslagoon.crypto.estreamj.ciphers.nil.Nil
- All Implemented Interfaces:
ICipher,ICipherMAC
THIS IS NOT A REAL CIPHER!
Just some pass-through implementation for testing and debugging purposes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intfor checks: each byte of the MAC passed must always contain this value!static final intstatic final intstatic final intFields inherited from interface com.coderslagoon.crypto.estreamj.framework.ICipher
MODE_DECRYPT, MODE_ENCRYPT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiderase()Erases all sensitive data.voidfinalize(byte[] macBuf, int macOfs) Finalize and compute the MAC.intintintintbooleanvoidprocess(byte[] inBuf, int inOfs, byte[] outBuf, int outOfs, int len) Processes data.voidprocessAAD(byte[] buf, int ofs, int len) Processes AAD (additional authentication data).static voidregister()voidreset()Resets the instance, so it can be reused.voidsetupKey(int mode, byte[] key, int ofs) Sets up a new key with the existing instance.voidsetupNonce(byte[] nonce, int ofs) Sets up a new nonce with the existing cipher instance.
-
Field Details
-
WORD_SIZE
public static final int WORD_SIZE- See Also:
-
KEY_SIZE
public static final int KEY_SIZE- See Also:
-
MAC_SIZE
public static final int MAC_SIZE- See Also:
-
NONCE_SIZE
public static final int NONCE_SIZE- See Also:
-
MAC_FILL_VALUE
public static final int MAC_FILL_VALUEfor checks: each byte of the MAC passed must always contain this value!- See Also:
-
-
Constructor Details
-
Nil
public Nil()
-
-
Method Details
-
getKeySize
public int getKeySize()- Specified by:
getKeySizein interfaceICipher- Returns:
- key size in bytes
-
getMacSize
public int getMacSize()- Specified by:
getMacSizein interfaceICipherMAC- Returns:
- MAC size in bytes
-
getNonceSize
public int getNonceSize()- Specified by:
getNonceSizein interfaceICipher- Returns:
- nonce size in bytes.
-
getWordSize
public int getWordSize()- Specified by:
getWordSizein interfaceICipher- Returns:
- alignment of data needed during calls into process()
-
isPatented
public boolean isPatented()- Specified by:
isPatentedin interfaceICipher- Returns:
- true: algorithm is patented, check with vendor for license details / false: free to use in private and commercial applications
-
reset
public void reset()Description copied from interface:ICipherResets the instance, so it can be reused. -
setupKey
Description copied from interface:ICipherSets up a new key with the existing instance.- Specified by:
setupKeyin interfaceICipher- Parameters:
mode- see MODE_xxxkey- buffer with key materialofs- where the key starts- Throws:
ESJException- if any error occurs
-
setupNonce
Description copied from interface:ICipherSets up a new nonce with the existing cipher instance.- Specified by:
setupNoncein interfaceICipher- Parameters:
nonce- buffer with nonce materialofs- where the nonce starts- Throws:
ESJException- if any error occurs
-
process
public void process(byte[] inBuf, int inOfs, byte[] outBuf, int outOfs, int len) throws ESJException Description copied from interface:ICipherProcesses data.- Specified by:
processin interfaceICipher- Parameters:
inBuf- input bufferinOfs- where to start reading from the input bufferoutBuf- output bufferoutOfs- where to start writing in the output bufferlen- number of bytes to process, must be aligned to the cipher's word size except on the last call where an arbitrary size can be used- Throws:
ESJException- in any error occurred
-
processAAD
Description copied from interface:ICipherMACProcesses AAD (additional authentication data).- Specified by:
processAADin interfaceICipherMAC- Parameters:
buf- input bufferofs- where to start reading from the input bufferlen- number of bytes to process, must be aligned to the cipher's word size except on the last call where an arbitrary size can be used- Throws:
ESJException- in any error occurred
-
finalize
Description copied from interface:ICipherMACFinalize and compute the MAC.- Specified by:
finalizein interfaceICipherMAC- Parameters:
macBuf- MAC buffermacOfs- where to write MAC- Throws:
ESJException- if any error occurred
-
erase
public void erase()Description copied from interface:ICipherErases all sensitive data. Instance MUST be abadonned afterwards. -
register
public static void register()
-