-
Notifications
You must be signed in to change notification settings - Fork 114
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
Support more private key formats when using aws_lc_rs feature #242
Conversation
3cd7961
to
8c44388
Compare
Is the direction I am going with this PR okay? I added too many functions (which maybe I could reduce somehow, better rename, etc..). But I would love that, by simply enabling aws_lc_rs feature the user would get more formats supported out of box. I am adding tests a bit later. |
I think names like |
Yes I understand but I want to find a way that make it easiest to the user to parse a private key of either, sec1, pkcs1, pkcs8. I feel if each format has an API specific to them. Many (at least me) would have to write a wrapper that tries them all. What about changing the original APIs to specify pkcs8 in it is name, and keeping the generic one without? Similar to the following:
We could also not export these APIs but use them inside from_raw. We alternatively could use the same API but make the key type differ based on enabled features. (I don't like this approach, it may confuse users)
If you really don't think there is a good API design with a generic solution and want a specific API for the sec1 format, I could do it as you asked like this. (But this way doesn't support for example pkcs1)
|
If we can add tests that show that the aws-lc-rs API accepts all of PKCS#8, PKCS#1 and SEC1, I think something like this could make sense? I would move the |
Is there any function like rustls_pemfile::private_key that can take DER input (instead of PEM) and give PrivateKeyDer? Because I could use it in this PR. (It is the biggest remaining issue) |
Look at the |
I think it makes sense to make this change ahead of the next release so we can land this branch as a follow-up without needing any breaking API changes: #249 |
The ones here? All these require knowing the key type. (e.g: converting first to pkcs8 for example). I meant something that parses &[u8] slice and provide PrivateKeyDer without knowing the type:
If there is no way to convert currently, is it okay for the functions to take a byte slice directly? Or should I try to add a function which perform the conversion? (in this crate or some other rustls crate)
instead of
|
We discussed this on Discord and we think it might make sense to have |
Yes, I will try to do so. |
8c44388
to
bbbc92d
Compare
I rebased this on prefer-aws branch. I patched this to use changes in pki-types. These changes are temporary until both are ready. The added test show aws-lc-rs work with the mentioned formats. |
796e33c
to
8cee68d
Compare
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.
This is looking great modulo some nits!
8cee68d
to
97ce049
Compare
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.
This looks good to me, thank you. I think once we sort out the pki-types side (rustls/pki-types#40) and publish a release this would be ready to go.
This was done and pki-types 1.4.0 has the required change. @Alvenix When you have a chance can you update your branch to take that release and drop the patch? Thanks! |
97ce049
to
e4408e7
Compare
I updated it, but PR 252 should be merged before. So I can rebase on main. |
Thanks!
Agreed, I think we're just waiting on est31 to +1 it. |
#252 has been merged. If you can rebase soon this can be released at the same time. |
e4408e7
to
5cf09a9
Compare
Can we maybe offer the new name everywhere, on ring-only builds being a wrapper to the pkcs8 version? |
d52e09a
to
a29fc21
Compare
I have done the requested changes in WIP: to squash after review which I will squash later after review is done. The third commit is temporary, it contains a patch to pki-types to fix a bug. |
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.
506d807
to
f56f44f
Compare
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, great work!
My other question is whether it still makes sense to expose |
e1a264e
to
9bba912
Compare
8a6b354
to
80ff41c
Compare
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.
Thanks!
80ff41c
to
9cc7e9c
Compare
9cc7e9c
to
0aa37e7
Compare
I did the requested changes, rebased and squashed all commits. |
There might be instances where you only want to support pkcs8 because some standard or so requires it to be pkcs8. Validation plus loading with something more permissive is prone to exploitable bugs where you trick the validator then get to the loading stage and get treated differently. I'm not sure it's enough justification to have all parsing functions be present both for pkcs8 and general formats though, maybe we just have the lowest level |
If you really want PKCS#8 you can |
I hope this change is okay. I am not sure if I need to add tests for this? Also should I rename the function in ring-like?