public interface Cipher extends CipherInformation
| Modifier and Type | Interface and Description |
|---|---|
static class |
Cipher.Mode |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkSupported(String xform,
int keyLength) |
void |
init(Cipher.Mode mode,
byte[] key,
byte[] iv)
Initialize the cipher for encryption or decryption with the given key and initialization vector
|
default void |
update(byte[] input)
Performs in-place encryption or decryption on the given data.
|
void |
update(byte[] input,
int inputOffset,
int inputLen)
Performs in-place encryption or decryption on the given data.
|
default 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.
|
default void |
updateWithAAD(byte[] input,
int offset,
int aadLen,
int inputLen)
Performs in-place authenticated encryption or decryption with additional data (AEAD).
|
getAuthenticationTagSize, getCipherBlockSize, getIVSize, getKdfSize, getTransformationgetAlgorithmgetKeySizevoid init(Cipher.Mode mode, byte[] key, byte[] iv) throws Exception
mode - Encrypt/Decrypt initializationkey - Key bytesiv - Initialization vector bytesException - If failed to initializedefault void update(byte[] input)
throws Exception
Note:input.length must be a multiple of the cipher's block size.
input - The input/output bytesException - If failed to executeupdate(byte[], int, int)void update(byte[] input,
int inputOffset,
int inputLen)
throws Exception
input - The input/output bytesinputOffset - The offset of the data in the data bufferinputLen - The number of bytes to update, starting at the given offset; must be a multiple of the
cipher's block sizeException - If failed to executedefault void updateAAD(byte[] data)
throws Exception
data - The data to authenticateException - If failed to executevoid updateAAD(byte[] data,
int offset,
int length)
throws Exception
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 authenticationException - If failed to executedefault void updateWithAAD(byte[] input,
int offset,
int aadLen,
int inputLen)
throws Exception
aadLen parameter are authenticated but not encrypted/decrypted, while payload data
indicated by the inputLen parameter are authenticated and encrypted/decrypted.
Note: on encryption the input must have enough space after offset + aadLen + inputLength
to store the authentication tag. On decryption, the authentication tag is assumed to be in the input at
that offset (i.e., after the payload data).
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; must be a multiple of the cipher's
block sizeException - If failed to executestatic boolean checkSupported(String xform, int keyLength)
xform - The full cipher transformation - e.g., AES/CBC/NoPadding - never null/emptykeyLength - The required key length in bits - always positivetrue if the cipher transformation and required key length are supportedCipher.getMaxAllowedKeyLength(String)Copyright © 2018–2024 The Apache Software Foundation. All rights reserved.