micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

pyjwt: ES256 algorithm support for PyJWT.

Open jonahbron opened this issue 1 year ago • 1 comments

Add optional support for ES256 JWT signing/verifying to PyJWT using @dmazzella's cryptography port.

Test output:

Testing HS256
     Encode/decode test: OK
     Invalid signature test: OK
     Expired token test: OK
Testing ES256
     Encode/decode ES256 test: OK
     Invalid signature test: OK

jonahbron avatar Mar 18 '24 05:03 jonahbron

Thanks for the contribution!

This isn't a full review, but some initial questions/feedback:

  • Is this ES256 support compatible with the CPython PyJWT library?
  • MicroPython tries to be minimal where possible, so I suggest inlining _sig_jws_to_der and _sig_der_to_jws at their place of use (they are only used once). That will save a bit of code size.
  • Also maybe the error message about required dependencies can be a little shorter/terser, to save size.
  • Can you please put the new test into a separate test for ES256, so that the tests can be run independently, and the original one still pass without cryptography installed.
  • Would be great to also add the tests to CI, see tools/ci.sh.

dpgeorge avatar Oct 18 '24 02:10 dpgeorge