-
Notifications
You must be signed in to change notification settings - Fork 696
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
Conversation
1e86f38
to
306bf14
Compare
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. |
There was a problem hiding this 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 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
babdf26
to
87e1359
Compare
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 andsimplify 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
Deployment
Any special considerations for deployment? no
Checklist
make lint
) and tests (make test
) pass in the development container