public class NativeCipherSpi extends AbstractCipherSpi
It can be used with NativeSecretKey, or raw-encoded keys that are dynamically imported as
NativeSecretKey for the duration of this cipher.
| Constructor and Description |
|---|
NativeCipherSpi(int nativeTransformationId,
int blockSize,
int unitBytes,
int cipherMode) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
decrypt(byte[] buffer,
int i,
int len,
byte[] output,
int outputOffset,
boolean doFinal)
Performs decryption operation.
|
protected int |
encrypt(byte[] buffer,
int i,
int len,
byte[] output,
int outputOffset,
boolean doFinal)
Performs encryption operation.
|
protected byte[] |
engineGetIV()
Returns the initialization vector (IV) in a new buffer.
|
protected void |
engineInit(boolean decrypting,
String algorithm,
SecretKey key,
byte[] iv,
int tagLength)
Initializes the cipher in the specified mode with the given key and iv.
|
protected void |
engineSetIV(byte[] iv)
Sets the initial vector.
|
protected int |
getBufferedLength()
TODO
|
static CipherSpi |
getInstance(String transformation)
Create a cipher context for the given transformation.
|
static int |
nativeGetTransformationDescription(byte[] transformation,
byte[] description)
Gets for the given transformation the cipher description.
|
protected void |
updateAAD(byte[] src,
int offset,
int len)
Continues a multi-part update of the Additional Authentication Data (AAD), using a subset of the provided buffer.
|
addExact, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetOutputSize, engineInit, engineInit, engineUpdate, engineUpdate, engineUpdateAADengineUnwrap, engineWrappublic NativeCipherSpi(int nativeTransformationId,
int blockSize,
int unitBytes,
int cipherMode)
protected int decrypt(byte[] buffer,
int i,
int len,
byte[] output,
int outputOffset,
boolean doFinal)
AbstractCipherSpi
The input cipher, starting at cipherOffset and ending at
(cipherOffset+cipherLen-1), is decrypted. The result is stored in plain, starting at
plainOffset.
The subclass that implements Cipher should ensure that init has been called before this method is
called.
decrypt in class AbstractCipherSpibuffer - the input buffer with the data to be decryptedi - the offset in cipherlen - the length of the input dataoutput - the buffer for the decryption resultoutputOffset - the offset in plainplainprotected int encrypt(byte[] buffer,
int i,
int len,
byte[] output,
int outputOffset,
boolean doFinal)
AbstractCipherSpi
The input plain, starting at plainOffset and ending at
(plainOffset+plainLen-1), is encrypted. The result is stored in cipher, starting at
cipherOffset.
The subclass that implements Cipher should ensure that init has been called before this method is
called.
encrypt in class AbstractCipherSpibuffer - the input buffer with the data to be encryptedi - the offset in plainlen - the length of the input dataoutput - the buffer for the encryption resultoutputOffset - the offset in ciphercipherprotected byte[] engineGetIV()
CipherSpiThis is useful in the context of password-based encryption or decryption, where the IV is derived from a user-provided passphrase.
engineGetIV in class CipherSpiprotected void engineInit(boolean decrypting,
String algorithm,
SecretKey key,
byte[] iv,
int tagLength)
throws InvalidKeyException,
InvalidAlgorithmParameterException
AbstractCipherSpiengineInit in class AbstractCipherSpidecrypting - flag indicating encryption or decryption modealgorithm - the algorithm name (never null)key - the key (never null)iv - the iv (either null or blockSize bytes long)tagLength - the tag Length (only for GCM)InvalidKeyException - if the given key is inappropriate for initializing this cipherInvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for this cipher.protected void engineSetIV(byte[] iv)
AbstractCipherSpiengineSetIV in class AbstractCipherSpiiv - the iv (either null or blockSize bytes long)protected int getBufferedLength()
AbstractCipherSpigetBufferedLength in class AbstractCipherSpi@Nullable public static CipherSpi getInstance(String transformation)
transformation - the cipher transformation to be usednull if the transformation is not supported.public static int nativeGetTransformationDescription(byte[] transformation,
byte[] description)
transformation - Null terminated string that describes the transformationdescription - a 12-byte buffer to be filled-in with:
*_MODE values defined in
AbstractCipherSpiNativeConstants.ERROR on error.protected void updateAAD(byte[] src,
int offset,
int len)
AbstractCipherSpi
Calls to this method provide AAD to the cipher when operating in modes such as AEAD (GCM/CCM). If this cipher is
operating in either GCM or CCM mode, all AAD must be supplied before beginning operations on the ciphertext (via
the update and doFinal methods).
updateAAD in class AbstractCipherSpisrc - the buffer containing the AADoffset - the offset in src where the AAD input startslen - the number of AAD bytes