Skip to content
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

JWK to RSA key translation #551

Open
bellebaum opened this issue Oct 12, 2022 · 2 comments
Open

JWK to RSA key translation #551

bellebaum opened this issue Oct 12, 2022 · 2 comments

Comments

@bellebaum
Copy link

Hey there :)

We were having a bit of trouble generating RSA keys from JSON Web Keys (JWK, RFC 7517).
Linking the original issue: jwt/ruby-jwt#523

We had this working fine with earlier versions of OpenSSL, where we were able to use functions like set_key on a new instance of OpenSSL::PKey::RSA.
With OpenSSL 3 the API has changed though, so this is no longer an option.
We are looking for guidance on how to implement parsing an (especially private) RSA key from the parameters alone.

A temporary solution we had consisted of parsing the key into ASN.1, then have it exported as DER and read by this gem, but the problem we are facing with this solution is that a private RSA JWK may in some cases only include the modulus and both exponents, rather than all CRT values present in the RFC 3447 ASN.1 description of a private key.

I apologize in advance, should I have overlooked some obvious API functionality. If you have some pointers for us, please let us know :)

@rhenium
Copy link
Member

rhenium commented Oct 17, 2022

a private RSA JWK may in some cases only include the modulus and both exponents, rather than all CRT values present in the RFC 3447 ASN.1 description of a private key.

This is a TODO item. We need a wrapper around EVP_PKEY_fromdata() (available in OpenSSL 3.0+ only) for this purpose.

Linking related issues: #498 (for EC) and #369 (OpenSSL 3.0 support in general)

@bdewater
Copy link
Contributor

I like the direction @anakinj is taking in #555 - thank you for working on this!

The API there looks a lot like what we're currently do manually with ASN.1 in in cose-ruby to transform COSE keys (for WebAuthn/passkeys) to OpenSSL PKeys, and I'd love to see a less laborious interface as well for the same reasons as ruby-jwt:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants