private class PasswordBasedEncryptor.DecryptCallback extends Object implements StreamCallback
| Modifier and Type | Field and Description |
|---|---|
private static boolean |
DECRYPT |
private static int |
RETRY_LIMIT_LENGTH |
| Constructor and Description |
|---|
DecryptCallback() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
handleBcryptDecryption(BcryptCipherProvider bcryptCipherProvider,
ByteCountingInputStream bcis,
ByteCountingOutputStream bcos,
byte[] salt,
int keyLength,
Cipher cipher,
byte[] iv,
String password)
Handles the
Bcrypt decryption separately, as the Bcrypt key derivation process changed during NiFi 1.12.0
and some cipher texts encrypted with a legacy key may need to be decrypted. |
void |
process(InputStream in,
OutputStream out) |
protected boolean |
shouldAttemptLegacyDecrypt(ProcessException e,
long bytesConsumed)
Returns
true if the Bcrypt decryption failed for reasons that might be resolved by attempting a second
decryption using the legacy key derivation process. |
private static final boolean DECRYPT
private static final int RETRY_LIMIT_LENGTH
public void process(InputStream in, OutputStream out) throws IOException
process in interface StreamCallbackIOExceptionprotected void handleBcryptDecryption(BcryptCipherProvider bcryptCipherProvider, ByteCountingInputStream bcis, ByteCountingOutputStream bcos, byte[] salt, int keyLength, Cipher cipher, byte[] iv, String password) throws IOException, ProcessException
Bcrypt decryption separately, as the Bcrypt key derivation process changed during NiFi 1.12.0
and some cipher texts encrypted with a legacy key may need to be decrypted. This method attempts to decrypt normally,
and if certain conditions are met (the cipher text is under 10 MiB and the failure was specifically due to the wrong
key), the legacy key derivation is used to make a second attempt.bcryptCipherProvider - the cipher providerbcis - the input stream (cipher text)bcos - the output stream to write the plaintext tosalt - the saltkeyLength - the key length to derive in bitscipher - the initial cipher objectiv - the IVpassword - the passwordIOException - if there is a problem reading/writing to the streamsProcessException - if there is any other exceptionprotected boolean shouldAttemptLegacyDecrypt(ProcessException e, long bytesConsumed)
true if the Bcrypt decryption failed for reasons that might be resolved by attempting a second
decryption using the legacy key derivation process.e - the exception thrown during the initial decryption attemptbytesConsumed - the number of bytes consumed from the cipher text streamCopyright © 2023 Apache NiFi Project. All rights reserved.