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: Add is_valid_public_key function #6948

Merged
merged 3 commits into from
Oct 4, 2023
Merged

Conversation

legoktm
Copy link
Member

@legoktm legoktm commented Sep 22, 2023

Status

Ready for review; but will fail CI until #6892 lands (this will be rebased on top of that prior to merge)

Description of Changes

We have multiple cases in Python code where we want to validate that a
string is valid PGP public key that Sequoia will accept. Exporting a
is_valid_public_key function will help make checks more robust and
simplify some tests.

The validation code on the Rust side is also a bit duplicated and
currently manually kept in sync with comments, so let's take the
opportunity to unify it into one file and de-duplicated with a macro
(hopefully not too magical).

Fixes #6947.

Testing

  • Visual review
  • CI passes

Deployment

Any special considerations for deployment? no

Checklist

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

@legoktm legoktm force-pushed the sequoia-valid-key branch 3 times, most recently from 1e86f38 to 306bf14 Compare September 27, 2023 17:32
@legoktm legoktm marked this pull request as ready for review September 27, 2023 17:38
@legoktm legoktm requested a review from a team as a code owner September 27, 2023 17:38
@legoktm
Copy link
Member Author

legoktm commented Sep 27, 2023

Marking as ready for review; CI will fail because SD tests are generating 1024-bit keys until #6892 lands. But at least the code can be reviewed ahead of time.

@rocodes rocodes self-requested a review October 2, 2023 13:43
rocodes
rocodes previously approved these changes Oct 2, 2023
Copy link
Contributor

@rocodes rocodes left a comment

Choose a reason for hiding this comment

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

LGTM, and very polite way of making improvements to my attempt at enforcing the key policy 🙈

Waiting til #6928 lands but otherwise 🚀

cfm
cfm previously approved these changes Oct 2, 2023
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.

This is just a drive-by review after #6892 and before #6946. Very nice addition and refactoring! I'll defer to you two for the final rebase and merge.

We have multiple cases in Python code where we want to validate that a
string is valid PGP public key that Sequoia will accept. Exporting a
`is_valid_public_key` function will help make checks more robust and
simplify some tests.

The validation code on the Rust side is also a bit duplicated and
currently manually kept in sync with comments, so let's take the
opportunity to unify it into one file and de-duplicated with a macro
(hopefully not too magical).

Tests are provided that verify a good public key passes, a bad SHA-1
key is rejected and a secret key is also rejected.

Fixes #6947.
This is a more comprehensive check than just verifying some variant of
the string "BEGIN PGP PUBLIC KEY BLOCK" is present.
StandardPolicy::new() is const, so we can create one instance of
the policy and use it everywhere, ensuring that we don't accidentally
use different policies.
@legoktm legoktm dismissed stale reviews from cfm and rocodes via 87e1359 October 3, 2023 00:43
@legoktm legoktm force-pushed the sequoia-valid-key branch from babdf26 to 87e1359 Compare October 3, 2023 00:43
@rocodes rocodes merged commit c52eb9e into develop Oct 4, 2023
@legoktm legoktm deleted the sequoia-valid-key branch October 4, 2023 15:56
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.

Add Python function that verifies the given public key is valid
3 participants