-
Notifications
You must be signed in to change notification settings - Fork 595
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
Verify that SigningKey matches public key within certificate #1918
Comments
👋 Hi there, thanks for opening an issue I think we're open to adding functionality for this. Previously (rustls/webpki#67) I had started implementing something similar in Would you be interested in working on a PR? |
Yeah! I still have a lot to learn in this space, though. Are you guys are okay with nurturing a newbie? Naively, the interface I would want is one of:
Looking at rustls/webpki#67, it looks like one tricky part of this will be finding certificate and key types (types meaning Rust types) that are abstract, but not so much so that we lose distinctive information like cryptographic key types—which also must be consistent, aside from the actual public key bytes we'd like to compare. For example, take the I'll have some contiguous time over the weekend to get started on this, along with a few hours here and there during the week. If you guys have any pointers in the meantime, I'd greatly appreciate it! |
The pieces I had in mind for this were:
|
I would be happy to help you work through the above if you're still interested. You can find us in Discord in the Ctz's plan sounds good to me. WDYT about starting with the first bullet point and working up a |
This sounds great, and thank you! I'll drop a few questions in your Discord channel soon. |
Perhaps stating the obvious: the crypto library may read in a (private key, public key) pair but never check that the privacy key is consistent with the public key. Then the crypto library might expose the potentially-mismatched public key to others. Many crypto libraries don't check pairwise consistency at all, and/or they offer options or separate APIs that optionally do it. Ideally Rustls would extract the SPKI from the EE certificate and then ask the crypto provider to do a pairwise consistency check as part of the construction of a CertifiedKey. |
👋 Hello!
Checklist
Apologies if this has already been asked and I didn't notice!
Is your feature request related to a problem? Please describe.
Right now, it looks like it's possible to create a
CertifiedKey
with inconsistent public and private keys, and there doesn't seem to be any functionality out of the box to check if this is the case.Describe the solution you'd like
Ideally, I'm looking for a Rustls-compatible equivalent for OpenSSL's
X509_check_private_key
, which verifies that the given public and private keys are consistent 1:This would be great even it functions in the same way that
X509_check_private_key
does:Describe alternatives you've considered
I suppose I could write something myself that does some ASN.1/DER parsing. I feel like this is useful to have!
An external crate that has this functionality would also be great!
Additional context
Footnotes
https://www.openssl.org/docs/manmaster/man3/X509_check_private_key.html ↩
The text was updated successfully, but these errors were encountered: