MINIFICPP-2749 Add EncryptContentPGP and DecryptContentPGP - #2225
martinzink wants to merge 20 commits into
Conversation
d8d95a6 to
3c78d17
Compare
3c78d17 to
ec38f7e
Compare
0727d82 to
2ba9029
Compare
75e1bf9 to
beb4e74
Compare
beb4e74 to
6bb2ae0
Compare
6bb2ae0 to
d3260c4
Compare
b913bef to
b632b71
Compare
71ba3f0 to
b81b278
Compare
b81b278 to
39c2916
Compare
szaszm
left a comment
There was a problem hiding this comment.
It's great to see the new Rust API working beautifully in practice, I really like the API design. A few minor comments below. I'm about halfway through, and will finish with a more thorough review next week.
| | Name | Default Value | Allowable Values | Description | | ||
| |--------------------|---------------|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| | **File Encoding** | BINARY | ASCII<br/>BINARY | File Encoding for encryption | | ||
| | Symmetric Password | | | Password used for encrypting data with Password-Based Encryption<br/>**Sensitive Property: true** | |
There was a problem hiding this comment.
Can we rename this to Passphrase to match NiFi?
There was a problem hiding this comment.
passphrase for me signals its used to decrypt the private key, but i can change it if we want to be more in line with nifi
There was a problem hiding this comment.
I'd rather be matching NiFi even if it's at a slight cost to clarity. Password and passphrase are used similarly, passphrase just signals that it can (and should) be longer than a word.
|
|
||
| | Name | Default Value | Allowable Values | Description | | ||
| |---------------------|---------------|------------------|-------------------------------------------------------------------------------------------------------------| | ||
| | Symmetric Password | | | Password used for decrypting data encrypted with Password-Based Encryption<br/>**Sensitive Property: true** | |
There was a problem hiding this comment.
Can we rename this to Passphrase to match NiFi?
There was a problem hiding this comment.
changed the properties to match nifi in review changes and review changes 2
There was a problem hiding this comment.
I'd keep all of the processor-related metadata in the same file as the processor implementation
There was a problem hiding this comment.
still unsure which looks better
move defs into super files
There was a problem hiding this comment.
If you prefer them separate, then it's ultimately your call as the author. I prefer them in a single file.
56651b5 to
47e48ce
Compare
dcac03e to
b83eae8
Compare
There was a problem hiding this comment.
If there is an easy way to reduce the code duplication without unifying public and private key types, and without exploding code complexity, it might be worth exploring.
There was a problem hiding this comment.
Since they are completely different types, its either this or macros or add our own trait which we would have to implement twice so not much better. I've tried it originally but didnt like it, feel free to play with it, maybe you can come up with something better.
| if let Some(sym_passwd) = &self.symmetric_password { | ||
| ring.message_password.push(sym_passwd); | ||
| } |
There was a problem hiding this comment.
What if both a private key and a symmetric passphrase are used? How does that work? Does it work at all? Does it double encrypt and decrypt the message, once with asymmetric and once with symmetric encryption? Does roundtrip with EncryptContent work in that case? If not, should we disable that and exforce an exclusive-OR relationship between the different key types, in schedule?
There was a problem hiding this comment.
it can be decrypted with either, its quite smart, pgp generates a single session token it uses that to encrypt the message/file symmetrically and then it encrypts the session token twice, once with public key, once with the configured symmetric key, then saves both results, during decrypiption if it can decrypt the sesion key with either private or symmetric key it can decrypt the file.
| pub(super) const LITERAL_DATA_FILENAME: OutputAttribute = OutputAttribute { | ||
| name: "pgp.literal.data.filename", | ||
| relationships: &["success"], | ||
| description: "Filename from decrypted Literal Data (Note that OpenPGP signatures do not include the formatting octet, the file name, and the date field of the Literal Data packet in a signature hash; therefore, those fields are not protected against tampering in a signed document. Therefore a lot of implementations omit these inherently malleable metadata)", |
There was a problem hiding this comment.
Should we ignore the unprotected metadata instead of using them when they're present? As a defense-in-depth measure, I think we should protect flowfile attributes from untrusted values, as some of our processors treat them as trusted data, opening attack vectors.
There was a problem hiding this comment.
| pub(super) const LITERAL_DATA_MODIFIED: OutputAttribute = OutputAttribute { | ||
| name: "pgp.literal.data.modified", | ||
| relationships: &["success"], | ||
| description: "Modified Date from decrypted Literal Data (Note that OpenPGP signatures do not include the formatting octet, the file name, and the date field of the Literal Data packet in a signature hash; therefore, those fields are not protected against tampering in a signed document. Therefore a lot of implementations omit these inherently malleable metadata)", |
There was a problem hiding this comment.
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically main)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.