Github user apiri commented on a diff in the pull request:
https://github.com/apache/nifi/pull/140#discussion_r46610289
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEncryptContent.java
---
@@ -60,12 +74,97 @@ public void testRoundTrip() throws IOException {
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EncryptContent.REL_SUCCESS, 1);
+ logger.info("Successfully decrypted {}", method.name());
+
flowFile =
testRunner.getFlowFilesForRelationship(EncryptContent.REL_SUCCESS).get(0);
flowFile.assertContentEquals(new
File("src/test/resources/hello.txt"));
}
}
@Test
+ public void testShouldDecryptOpenSSLRawSalted() throws IOException {
+ // Arrange
+ final TestRunner testRunner = TestRunners.newTestRunner(new
EncryptContent());
+
+ final String password = "thisIsABadPassword";
+ final EncryptionMethod method = EncryptionMethod.MD5_256AES;
+ final KeyDerivationFunction kdf =
KeyDerivationFunction.OPENSSL_EVP_BYTES_TO_KEY;
+
+ testRunner.setProperty(EncryptContent.PASSWORD, password);
+ testRunner.setProperty(EncryptContent.KEY_DERIVATION_FUNCTION,
kdf.name());
+ testRunner.setProperty(EncryptContent.ENCRYPTION_ALGORITHM,
method.name());
+ testRunner.setProperty(EncryptContent.MODE,
EncryptContent.DECRYPT_MODE);
+
+ // Act
+
testRunner.enqueue(Paths.get("src/test/resources/TestEncryptContent/salted_raw.enc"));
+ testRunner.clearTransferState();
+ testRunner.run();
+
+ // Assert
+
testRunner.assertAllFlowFilesTransferred(EncryptContent.REL_SUCCESS, 1);
+ testRunner.assertQueueEmpty();
+
+ MockFlowFile flowFile =
testRunner.getFlowFilesForRelationship(EncryptContent.REL_SUCCESS).get(0);
+ logger.info("Decrypted contents (hex): {}",
Hex.encodeHexString(flowFile.toByteArray()));
+ logger.info("Decrypted contents: {}", new
String(flowFile.toByteArray(), "UTF-8"));
+
+ // Assert
+ flowFile.assertContentEquals(new
File("src/test/resources/TestEncryptContent/plain.txt"));
+ }
+
+ @Test
+ public void testShouldDecryptOpenSSLRawUnsalted() throws IOException {
--- End diff --
This also failed as the previous, salted, version:
[pool-5-thread-1] ERROR org.apache.nifi.processors.standard.EncryptContent
- EncryptContent[id=e334c103-1236-4427-b695-63fd0b49712c] Cannot decrypt
FlowFile[0,unsalted_raw.enc,32B] - :
org.apache.nifi.processor.exception.ProcessException:
java.security.InvalidKeyException: Illegal key size
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---