Interface Cipher
-
- All Known Implementing Classes:
AES128CBC
,AES128CTR
,AES192CBC
,AES192CTR
,AES256CBC
,AES256CTR
,BaseCipher
,BlockCipher
,BlowfishCBC
,ChachaPolyCipher
,GcmCipher
,NoneCipher
,StreamCipher
,TripleDESCBC
public interface Cipher
Wrapper for a cryptographic cipher, used either for encryption or decryption.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Cipher.Mode
-
Method Summary
Modifier and Type Method Description int
getAuthenticationTagSize()
int
getBlockSize()
int
getIVSize()
void
init(Cipher.Mode mode, byte[] key, byte[] iv)
Initialize the cipher for encryption or decryption with the given private key and initialization vectorvoid
setSequenceNumber(long seq)
void
update(byte[] input, int inputOffset, int inputLen)
Performs in-place encryption or decryption on the given data.void
updateAAD(byte[] data)
Adds the provided input data as additional authenticated data during encryption or decryption.void
updateAAD(byte[] data, int offset, int length)
Adds the provided input data as additional authenticated data during encryption or decryption.void
updateWithAAD(byte[] input, int offset, int aadLen, int inputLen)
Performs in-place authenticated encryption or decryption with additional data (AEAD).
-
-
-
Method Detail
-
getBlockSize
int getBlockSize()
- Returns:
- the block size for this cipher
-
getIVSize
int getIVSize()
- Returns:
- the size of the initialization vector
-
getAuthenticationTagSize
int getAuthenticationTagSize()
- Returns:
- Size of the authentication tag (AT) in bytes or 0 if this cipher does not support authentication
-
init
void init(Cipher.Mode mode, byte[] key, byte[] iv)
Initialize the cipher for encryption or decryption with the given private key and initialization vector- Parameters:
mode
- whether this instance wil encrypt or decryptkey
- the key for the cipheriv
- initialization vector
-
update
void update(byte[] input, int inputOffset, int inputLen)
Performs in-place encryption or decryption on the given data.- Parameters:
input
- the subjectinputOffset
- offset at which to startinputLen
- number of bytes starting atinputOffset
-
updateAAD
void updateAAD(byte[] data, int offset, int length)
Adds the provided input data as additional authenticated data during encryption or decryption.- Parameters:
data
- The additional data to authenticateoffset
- The offset of the additional data in the bufferlength
- The number of bytes in the buffer to use for authentication
-
updateAAD
void updateAAD(byte[] data)
Adds the provided input data as additional authenticated data during encryption or decryption.- Parameters:
data
- The data to authenticate
-
updateWithAAD
void updateWithAAD(byte[] input, int offset, int aadLen, int inputLen)
Performs in-place authenticated encryption or decryption with additional data (AEAD). Authentication tags are implicitly appended after the output ciphertext or implicitly verified after the input ciphertext. Header data indicated by theaadLen
parameter are authenticated but not encrypted/decrypted, while payload data indicated by theinputLen
parameter are authenticated and encrypted/decrypted.- Parameters:
input
- The input/output bytesoffset
- The offset of the data in the input bufferaadLen
- The number of bytes to use as additional authenticated data - starting at offsetinputLen
- The number of bytes to update - starting at offset + aadLen
-
setSequenceNumber
void setSequenceNumber(long seq)
-
-