-
Notifications
You must be signed in to change notification settings - Fork 725
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
New API for verifying public key signatures using keys constructed by components #445
Comments
Thanks for creating the issue! I'm already taking a stab at this, and will probably have something to show soon. :) (I'll make sure it's on top of #441, keeping that PR free of breaking changes.) |
I don't have time to write everything I'd like here, but here are three things to keep in mind off the top of my head:
|
Do the key parts (the bignums) need to go through the same validation that from_der does to make sure ring is able to use the loaded key? |
As @cmsd2 stated, that was the direction I was working in. Even for Ed25519, I introduced a
So in terms of complexity, the intent is to just move things around, and not introduce any additional copying or allocation than was already the case. (But allow a bit more control, and important for us, more ways to create and inspect keys.) I'm still working on ECDSA, but should have a PR open soon. For the curious, here's the branch as I'm working on it: master...stephank:feat/rsa-export-2 Note that I'm often rewriting history here, so I don't base any work on this yet. :) |
If I understand correctly: The public constructor for impl<'a> RSAPublicKey<'a> {
pub fn from_n_and_e(alg: &RSAParameters, n: &'a [u8], e: &'a [u8]) -> Self<'a> {
from_n_and_e_private(alg.min_bits, n, e)
}
// Used by `from_n_and_e()` and by `RSAKeyPair::from_der()`.
fn from_n_and_e_private(n_bits: bits::BitLength, n: &'a [u8], e: &'a [u8]) -> Self<'a> {
// The implementation from `check_public_modulus_and_exponent` goes here.
}
} |
Oops, the return type should be a |
@briansmith Thanks for thinking along here. I'm curious to see if I've missed opportunities in the implementation. :) I did try separate public/private constructors for I don't know enough about the internal representation of The setup I built now is to have And that's more or less what I've applied to all types of signatures. The code paths are nearly the same as they were, just shuffled around a bit. I've finished work on the branch at master...stephank:feat/rsa-export-2 for now. It's on top of #441, so I can either push the remaining commits there, or wait until we finish that work, then create a new PR. Significantly, I've completely removed The one concern I have myself is that |
Don't do this. To understand why, try rebasing https://github.com/briansmith/webpki and https://github.com/ctz/rustls on top of your changes. |
The internal representation of BIGNUM and BN_MONT_CTX is a little-endian array of words (32-bit on 32-bit systems, 64-bit on 64-bit systems), not a big-endian array of bytes. Basically, your proposed changes to the |
Oh, sorry, I misread a previous comment of yours. I need to check if it works reasonable given the memory usage requirements we have. |
Hi, in order for me to look at your code changes, I need you to submit them as PRs where all commits have the contributor statement (see https://github.com/briansmith/ring#contributing) at the end. One thing to keep in mind is that ring is optimized for the case where keys and signatures are encoded in the formats that it supports natively, which is why we have |
Alright, that all makes sense, and I've taken a few wrong directions here and there. In light of that, I've pushed one extra commit to #441, adding just the The remaining stuff is of no real benefit, I think. I actually didn't think about how to export/import ECDSA keys. The work I did before allowed for just 'caching' the I also added the missing contributor statements to the commits. Thanks again for taking the time to review and provide feedback. :) |
I do think all your changes make sense. It's just that there are competing concerns regarding memory (stack) usage and other concerns that they have to be weighed against. Are you working on JWT? If so, maybe we should have a discussion with the (several) other people who are working on JWT support to come to an agreement on exactly what we need to change in ring, and also perhaps find a way for people to work together on a common JWT library based on ring. |
Well, I certainly wrecked important API in the webpki context. 😁 I also do see the value in preventing access to private components. It'd be better to have something along the lines of
Yes, I work on Portier, which is both an OpenID Connect relying party and identity provider. We currently have our own bare-bones JWT implementation that does just RS256. I have an in-progress (but working!) branch of Portier on top of #441: portier/portier-broker#130 I see you already pinged some JWT people. Would it make more sense to have that discussion in Keats/jsonwebtoken#13 and #441? This thread has gotten a bit lengthy in a different direction already. |
@stephank Please save your branch where you did your bigger refactoring somewhere safe. I actually am considering doing something like that, but I don't have time to work on it until after April, and I'm not 100% sure I want to commit to doing it. |
Sorry to dig up an old thread. Adding my two cents since I have been working on a JOSE library (https://github.com/lawliet89/biscuit) that was based off https://github.com/Keats/rust-jwt initially, but I have had to change the API surface almost completely to add support for JWE, among other things. So far, I have managed to whip up some semblance of the JWK representation, and as On the other hand, |
Amusingly, I implemented some of this, but in trust-dns: https://github.com/bluejekyll/trust-dns/blob/master/client/src/rr/dnssec/rsa_public_key.rs and https://github.com/bluejekyll/trust-dns/blob/master/client/src/rr/dnssec/rsa_public_key.rs. It seems like a good idea to copy/move that stuff into ring. |
Any update? |
In #441 (comment), @stephank suggested:
The text was updated successfully, but these errors were encountered: