mirror of https://github.com/apache/nifi.git
NIFI-8465 Handle bcrypt legacy decrypt failures in testing
This closes #5029 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
9f45b48866
commit
835f50c83a
|
@ -442,7 +442,18 @@ class PasswordBasedEncryptorGroovyTest {
|
|||
String recovered = new String(recoveredBytes, StandardCharsets.UTF_8)
|
||||
logger.info("Plaintext (${recoveredBytes.size()}): ${recovered}")
|
||||
|
||||
assert recovered == PLAINTEXT
|
||||
// handle reader logic error (PKCS7 padding false positive) by explicitly testing legacy key derivation
|
||||
if (PLAINTEXT != recovered) {
|
||||
logger.warn("Explicit test of legacy key derivation logic.")
|
||||
InputStream inputStreamLegacy = new ByteArrayInputStream(cipherBytes)
|
||||
OutputStream outputStreamLegacy = new ByteArrayOutputStream()
|
||||
byte[] salt = bcryptCipherProvider.readSalt(inputStreamLegacy)
|
||||
byte[] iv = bcryptCipherProvider.readIV(inputStreamLegacy)
|
||||
Cipher cipherLegacy = bcryptCipherProvider.getLegacyDecryptCipher(encryptionMethod, PASSWORD, salt, iv, keyLength)
|
||||
CipherUtility.processStreams(cipherLegacy, inputStreamLegacy, outputStreamLegacy)
|
||||
String recoveredLegacy = new String(outputStreamLegacy.toByteArray(), StandardCharsets.UTF_8)
|
||||
assert recoveredLegacy == PLAINTEXT
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue