Interface ICipher
- All Known Subinterfaces:
ICipherMAC
- All Known Implementing Classes:
AESCTR,Dragon,Grain128Noopt,GrainP2Noopt,GrainRefNoopt,HC256,Hermes8,LEX,MICKEY,MICKEY128,MICKEYBase,Nil,Phelix,RC4,Salsa20,Sosemanuk,Spritz,Trivium
public interface ICipher
Generic interface every cipher needs to implement, so it can participate in
the test framework. If a cipher comes in different flavors (variable key
sizes, MAC computation or not, etc.) it should then implement a version for
each of them - this keeps the actual testing logic simple. Simple is good.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intmode: instance is used for decryptionstatic final intmode: instance is used for encryption -
Method Summary
Modifier and TypeMethodDescriptionvoiderase()Erases all sensitive data.intintintbooleanvoidprocess(byte[] inBuf, int inOfs, byte[] outBuf, int outOfs, int len) Processes data.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
-
MODE_ENCRYPT
static final int MODE_ENCRYPTmode: instance is used for encryption- See Also:
-
MODE_DECRYPT
static final int MODE_DECRYPTmode: instance is used for decryption- See Also:
-
-
Method Details
-
isPatented
boolean isPatented()- Returns:
- true: algorithm is patented, check with vendor for license details / false: free to use in private and commercial applications
-
getKeySize
int getKeySize()- Returns:
- key size in bytes
-
getNonceSize
int getNonceSize()- Returns:
- nonce size in bytes.
-
getWordSize
int getWordSize()- Returns:
- alignment of data needed during calls into process()
-
reset
Resets the instance, so it can be reused.- Throws:
ESJException- if any error occurs
-
setupKey
Sets up a new key with the existing instance.- Parameters:
mode- see MODE_xxxkey- buffer with key materialofs- where the key starts- Throws:
ESJException- if any error occurs
-
setupNonce
Sets up a new nonce with the existing cipher instance.- Parameters:
nonce- buffer with nonce materialofs- where the nonce starts- Throws:
ESJException- if any error occurs
-
process
Processes data.- 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
-
erase
void erase()Erases all sensitive data. Instance MUST be abadonned afterwards.
-