-
Notifications
You must be signed in to change notification settings - Fork 30
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
Fix parsing for PrivateKeyDer #42
Conversation
Indeed, its version is encoded as
Aha, specifically
Thanks for digging in! |
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
So should we not encode that as |
If other crate consider parse it a Pkcs8 or Pkcs8 like, I feel it would add unnecessary complexity to separate them. I assume not, as ring at least which is used on the tests support only pkcs8. Perhaps a change in the documentation is more appropriate. |
I'm not sure yet.
So it sounds like you could emit a RFC5958 In this case, the That said: do the downstream APIs we feed these bytes to care? or are they all just treating this as PKCS8 anyway? 🤔 |
Yeah, I guess for our purposes ring and aws-lc-rs are the authorities on what counts as PKCS#8. |
I take this back, I think since 5958 obsoletes 5208 it would be fair to still consider it PKCS8. Ring is specifically citing 5958 for it's definition of PKCS8 so I think in the end this is semantics and we shouldn't have over-fit our heuristic on the RFC 5208 version number. I think we should ship the fix we have and not split the enum further. |
The key fails to parse on openssl binding but works with ring. Here. |
SGTM. |
For completeness, it looks like aws-lc-rs is citing the older RFC, but also recognizes V2 and the fn for decoding is described as supporting v1 and v2 through the same entrypoint. |
This following key is supposed to be pkcs8 key:
-----BEGIN PRIVATE KEY-----
MFMCAQEwBQYDK2VwBCIEIC2pHJYjFHhK8V7mj6BnHWUVMS4CRolUlDdRXKCtguDuoSMDIQDrvH/x8Nx9untsuc6ET+ce3w7PSuLY8BLWcHdXDGvkQA==
-----END PRIVATE KEY-----
it is included in one of rcgen tests for ring, so it is indeed probably pkcs8. The problem is that the version is set as 1, so the previous parsing considered it Sec1.
I am opening this PR so I can test it with rcgen to check again if it work correctly. I am not sure if this fix the issue.The tests in rcgen works now with this patch.This may be relevant.