jonasroussel / dart_jsonwebtoken

A dart implementation of the famous javascript library 'jsonwebtoken'
MIT License
87 stars 29 forks source link

Feature Request: Direct use of pointy castle keys #35

Closed nblum37 closed 1 year ago

nblum37 commented 1 year ago

Hi :)

currently, the framework allows importing PEM keys. As the framework also uses pointy castle keys internally, it would be nice, if it would be possible to directly use pointy castle keys instead of converting them to a PEM string first and then parsing them back to the framework key class. Thank you!

jonasroussel commented 1 year ago

Hello !

I totally understand the need. So I pushed a new version (v2.6.3) that includes this feature on all JWTKey https://pub.dev/packages/dart_jsonwebtoken/versions/2.6.3

You can now instantiate a JWTKey like this:

final pcKey = pc.RSAPrivateKey(modulus, privateExponent, prime1, prime2);

...

final key = RSAPrivateKey.raw(pcKey);
nblum37 commented 1 year ago

Nice! Thank you :)

nblum37 commented 1 year ago

I run into the attached issue with ECDSA keys. It seems like, the new .raw method does not initialize the size property.

Bildschirm­foto 2023-01-24 um 00 20 52
jonasroussel commented 1 year ago

Yeah right ! Fixed : https://pub.dev/packages/dart_jsonwebtoken/versions/2.6.4

nblum37 commented 1 year ago

Nice, seems to work now :)