Conversation
* Add PEM support with pem and simple_asn1. Documentation TODO * Make pkcs1 and pkcs8 versions of the RSA key, confirm they pass tests. * Add documentation, simplify * Update readme * Bump pem version * Remove extra print
|
b9a3e30 removes the I'll start thinking about the new API now, with pem handling it can be much nicer than the current |
|
I've reviewed the 3 commits you've referenced and I'm good with them. |
|
So my thought for the api would be to take a |
|
It is possible. You'll see that it's encoded as a ASN1 sequence of a big endian big int followed by the modulus (similarly encoded) The simple_asn1 library already included may be able to assist with that. |
|
In fact, it's one of the things I was looking into, using another JWK to feed these algorithms which rely on decoding an ASN1 body. The challenge I had with the simple asn1 though is that it wants the user to calculate the size of things. I haven't gotten to the part of actually doing it, but in theory it would be |
|
Nice, so I guess the encode/decode with |
|
@LeviSchuck are you interested in building a function that looks like This generated a valid key (afaik) but I could not get the test |
|
Hey @Keats Thanks for the example code. I've spent a few weekends at a coffee shop studying this stuff for that exact reason. I didn't use simple_asn1 for it, its much more restricted and hacky in my current implementation but I can put some time tonight into this. For reference I was making a way to go to and back from pem and jwks and |
|
No hurry, take your time. If we nail that function, we can have a pretty optimal DX while supporting more formats than before. |
|
It would also mean that I can drop my inflexible jwt implementation :) |
|
The API could definitely use some refining or access via module, but I got it working for public keys. (EC(x) and RSA(n,e)) Everything is in one commit so far but I'd make a PR once I get documentation in. Then @Keats you can make the API more DX friendly. |
|
That looks very good, thanks for that. Some changes will be required (eg not exposing |
|
I haven’t seen it yet, but I’m wanting to use it for my own projects. As for not exposing ring, that’s only in the tests as a convenience to prove that I can go from private PEM to ring to public pem, else I’d need to start making “key parameters” and that’s kinda reimplementing ring. I could also hard code the keys in the tests but that’s less confidence to me than using arbitrary external key data via include str DX wise I think the next part is going from modulus exponent to der for rsa |
|
I also replied on the commit, the specification predefined the curve used for JOSE HS* as prime256v1 |
Those tests are fine but should be implemented in the module itself.
I am thinking into having dedicated decode functions for RSA jwk and EC jwk instead of using the default If you can do a PR with what you currently have on this branch, we can start having a look. |
|
I noticed while peeking into ring, there were functions that took the parameters directly. But sure, I’ll submit a pr |
|
👍 |
|
Important tools for Rust: clippy and fmt as shown in a6ea8c2 |
|
RE: JWKs are you planning on doing verification with a JWK struct or vec of jwks? |
|
After some thoughts, I might just have an example for JWK set since they can in people own struct/hashmap etc and it is probably simpler to provider the plumbing + example on how to do it |
|
I've added not yet working JWK decoding, I'm not entirely sure why b279815#diff-d866210ac5208ba9071685e86eba4beeR117-R127 is failing to verify but that can be left for later. |
|
Its probably what I mentioned earlier
I unfortunately don't have much time to poke at this. |
|
Look at 614f361 to see the bugfix... 🤦♂ |
|
Oh, I can see how that went wrong. Glad that's resolved. |
|
@LeviSchuck after writing the docs, I've realized I don't actually need anything from |
|
I think API & docs is in a good place right now, probably ready for some alpha release after I add a few more testcases from jwt.io. |
|
Thanks a lot @LeviSchuck ! I'll push an alpha release now for v7 |
|
Hi, I'm extremely new to all this, and I'm following this guide for verifying a google token. I'm stuck here:
Does this library allow verifying with PEM and/or transforming |
|
Hey @rokit You'll need to fetch the remote JWK, find the key associated to the kid present in the JOSE header, and then use the parameters in that JWK to create a public key. You can then verify the key from there. A constructor for a public key of that kind should be demonstrated in the test folder. |
|
Thanks @LeviSchuck. It looks like I needed |
Add PEM decoding support (#106)

Add PEM support with pem and simple_asn1. Documentation TODO
Make pkcs1 and pkcs8 versions of the RSA key, confirm they pass tests.
Add documentation, simplify
Update readme
Bump pem version
Remove extra print