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

Add JWK support for HMAC and RSA keys #202

Merged
merged 1 commit into from
Oct 24, 2016
Merged

Conversation

mark-adams
Copy link
Contributor

@mark-adams mark-adams commented May 6, 2016

This adds support for JWK serialization to HMAC and RSA keys.

Looking something like this:

     public_key = RSAAlgorithm.from_jwk('{"kty": "RSA", "e": "AQAB", ...')

and also

     jwk = RSAAlgorithm.to_jwk(public_key)
     print(jwk)

     > '{"kty": "RSA", "e": "AQAB", ...'

@mark-adams mark-adams force-pushed the add-jwk-for-hmac-rsa branch 2 times, most recently from 3466f90 to 41c24b2 Compare May 7, 2016 21:50
@jpadilla
Copy link
Owner

@mark-adams let me know if there's anything I can help with.

@mark-adams mark-adams force-pushed the add-jwk-for-hmac-rsa branch 6 times, most recently from 22b5e39 to 12b24be Compare August 6, 2016 04:24
@mark-adams
Copy link
Contributor Author

@jpadilla Mind taking a look at this?

@mark-adams mark-adams force-pushed the add-jwk-for-hmac-rsa branch 2 times, most recently from dad9ba4 to bfa24f3 Compare August 7, 2016 18:17
@coveralls
Copy link

coveralls commented Aug 7, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling bfa24f3 on add-jwk-for-hmac-rsa into 899fdaf on master.

'kty': 'RSA',
'use': 'sig',
'key_ops': ['verify'],
'n': force_unicode(to_base64url_uint(numbers.n)),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot find specific documentation on encoding RSA keys, but the examples I have seen include modulus (n) and public exponent (e) values in both the private and public keys.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. That was an oversight on my part. I missed the text that says:

In addition to the members used to represent RSA public keys, the
following members are used to represent RSA private keys.

@clintonb
Copy link

This looks good to go once the comments are addressed. Thanks, @mark-adams!

- JWKs for RSA and HMAC can be encoded / decoded using the .to_jwk() and
  .from_jwk() methods on their respective jwt.algorithms instances

- Replaced tests.utils ensure_unicode and ensure_bytes with jwt.utils versions
@coveralls
Copy link

coveralls commented Aug 28, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 42b0114 on add-jwk-for-hmac-rsa into b35d522 on master.

@coveralls
Copy link

coveralls commented Aug 28, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 42b0114 on add-jwk-for-hmac-rsa into b35d522 on master.

@mark-adams
Copy link
Contributor Author

@jpadilla Does this look good to you?

@jpadilla
Copy link
Owner

@mark-adams yup, all yours!

@mark-adams mark-adams merged commit f013347 into master Oct 24, 2016
@jpadilla jpadilla added this to the v1.4.3 milestone Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants