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 EncryptionMethods.| 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, writeIVprivate 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 KeyedCipherProviderencryptionMethod - the EncryptionMethodkey - 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 KeyedCipherProviderencryptionMethod - the EncryptionMethodkey - 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, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, UnsupportedEncodingException
private boolean isValidKeyLength(SecretKey key)
public byte[] generateIV()
SecureRandom.generateIV in class KeyedCipherProviderCopyright © 2018 Apache NiFi Project. All rights reserved.