public class AESKeyedCipherProvider extends KeyedCipherProvider
KeyedCipherProvider
which supports AES
cipher families with arbitrary modes of operation (currently only CBC
, CTR
, and GCM
are supported as EncryptionMethod
s.Modifier and Type | Field and Description |
---|---|
private static int |
IV_LENGTH |
private static org.slf4j.Logger |
logger |
private static List<Integer> |
VALID_KEY_LENGTHS |
IV_DELIMITER, MAX_IV_LIMIT
Constructor and Description |
---|
AESKeyedCipherProvider() |
Modifier and Type | Method and Description |
---|---|
byte[] |
generateIV()
Generates a new random IV of 16 bytes using
SecureRandom . |
Cipher |
getCipher(EncryptionMethod encryptionMethod,
SecretKey key,
boolean encryptMode)
Returns an initialized cipher for the specified algorithm.
|
Cipher |
getCipher(EncryptionMethod encryptionMethod,
SecretKey key,
byte[] iv,
boolean encryptMode)
Returns an initialized cipher for the specified algorithm.
|
protected Cipher |
getInitializedCipher(EncryptionMethod encryptionMethod,
SecretKey key,
byte[] iv,
boolean encryptMode) |
private boolean |
isValidKeyLength(SecretKey key) |
readIV, writeIV
private static final org.slf4j.Logger logger
private static final int IV_LENGTH
public Cipher getCipher(EncryptionMethod encryptionMethod, SecretKey key, byte[] iv, boolean encryptMode) throws Exception
getCipher
in class KeyedCipherProvider
encryptionMethod
- the EncryptionMethod
key
- the keyiv
- the IV or nonce (cannot be all 0x00)encryptMode
- true for encrypt, false for decryptException
- if there is a problem initializing the cipherpublic Cipher getCipher(EncryptionMethod encryptionMethod, SecretKey key, boolean encryptMode) throws Exception
getCipher
in class KeyedCipherProvider
encryptionMethod
- the EncryptionMethod
key
- the keyencryptMode
- true for encrypt, false for decryptException
- if there is a problem initializing the cipher or if decryption is requestedprotected Cipher getInitializedCipher(EncryptionMethod encryptionMethod, SecretKey key, byte[] iv, boolean encryptMode) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException
private boolean isValidKeyLength(SecretKey key)
public byte[] generateIV()
SecureRandom
.generateIV
in class KeyedCipherProvider
Copyright © 2021 Apache NiFi Project. All rights reserved.