Keats / jsonwebtoken

JWT lib in rust
MIT License
1.67k stars 266 forks source link

Does adding from_rsa_components() for EncodingKey make sense? #281

Open nlfiedler opened 1 year ago

nlfiedler commented 1 year ago

I'm presently using the rsa crate and creating a private/public key pair, then creating an EncodingKey from that. For now, it seems that I must convert the private key to a PEM encoded string and then create EncodingKey from that. I would like to skip that step if I may. I took a brief look at the code and it seems that DecodingKey and EncodingKey are built up differently, so it's not obvious to me if adding an from_rsa_components() to EncodingKey is a good idea or not. But it sure would be convenient. If you have any suggestions, I can give it a try myself and submit a PR.

Keats commented 1 year ago

I'm not sure it makes sense. It's added to DecodingKey because you commonly get them as components (eg JWKs). It's much rarer for the encoding part.

davidreis97 commented 1 year ago

This is actually something that I would love to have, I'm aware that it's a rare use case but we do use the JWK format to represent our private keys. A from_rsa_components() or even from_jwk() would be greatly appreciated.