Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redwood: Don't armor encrypted files/messages #7023

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

legoktm
Copy link
Member

@legoktm legoktm commented Oct 20, 2023

Status

Ready for review

Description of Changes

We didn't have GPG armor ciphertext, so we don't need redwood to either. This will result in a noticable speedup during encryption (c.f. #7022).

We do need to adjust tests now that we can no longer easily look for the "-----BEGIN PGP MESSAGE-----" string.

Testing

How should the reviewer test this PR?

  • CI passes
  • Visual review

Deployment

Any special considerations for deployment? No, this restores the status quo of non-armored messages.

Checklist

  • Linting (make lint) and tests (make test) pass in the development container

@legoktm legoktm added this to the SecureDrop 2.7.0 milestone Oct 20, 2023
@legoktm legoktm requested a review from a team as a code owner October 20, 2023 23:13
@legoktm
Copy link
Member Author

legoktm commented Oct 20, 2023

Hmm, seems like there are tests that need an armored version to POST. 🤔

...except in one test.

We didn't have GPG armor ciphertext, so we don't need redwood to either.
This will result in a noticable speedup during encryption. Keys will
still be armored when being stored in the database.

Tests make this a bit more complicated, we want to generate an armored
message we can post to the journalist API, so we make it an optional
parameter for redwood.encrypt_message() only. We have to adjust other
tests now that we can no longer easily look for the
"-----BEGIN PGP MESSAGE-----" string.

Refs #7022.
Copy link
Member

@cfm cfm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tidy change, well documented.

encrypted_file = encrypted_file_path.read_bytes()
assert encrypted_file.startswith(b"-----BEGIN PGP MESSAGE-----")
assert file_to_encrypt_path.read_bytes() not in encrypted_file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I raised an eyebrow at this, since file_to_encrypt_path.read_bytes() could be up to 500 MB: couldn't we just check the first chunk, of whatever size? But of course this is just a test, so we control the plaintext input as well as the ciphertext output.

@cfm cfm merged commit 6fae718 into develop Oct 27, 2023
12 checks passed
@legoktm legoktm deleted the redwood-no-armor branch October 27, 2023 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants