rama icon indicating copy to clipboard operation
rama copied to clipboard

implement jwa algorithms

Open valkrypton opened this issue 4 months ago • 10 comments

working on #621.

@GlenDC I've written the conversions in rama-crypto/src/jose/jwa.rs file. Let me know if they are correct. However, I'd like some guidance on what changes needs to be made in the rama-crypto/src/jose/jwk.rs file.

valkrypton avatar Jul 31 '25 09:07 valkrypton

I've asked @soundofspace to do the initial reviews and guidance here. He'll come back to you.

GlenDC avatar Jul 31 '25 10:07 GlenDC

For changes in rama-crypto/src/jose/jwk.rs I would start with RSA as it behaves quite similar to EC curves.

Places that need updating:

  • Add JWK::new_from_rsa_keypair using RsaKeyPair from awc_lc_rs. Here you create key_type JWKType::RSA with base64 encoded values for n, e (using RsaKeyPair.public_key().modules/exponent)
  • In JWK::unparsed_public_key implement the reverse so we can get an UnparsedPublicKey
  • Add RsaKey very similar to EcdsaKey but modify where needed to use RSA stuff
  • Rename EcdsaKeySigningHeaders to SigningHeaders so you can also use it to sign for RSA
  • Implement Signer for RsaKey, this logic can probably be copied from the implementation for EcdsaKey but might need small tweaks
  • Add some tests to verify that everything works like expected. These can be hardcoded to some expected output for a given input, there are lots of other projects online that have already a very nice test suite for this if you need inspiration
  • If you see opportunities to extend the current (very minimal) test suite please also do, it would appreciated a lot

Also don't be afraid to look at the jwk rfc it's a decently sized one but it's split up in a lot of chapters and it also contains some examples

And thanks for looking into this!

soundofspace avatar Jul 31 '25 15:07 soundofspace

@soundofspace could you review this?

valkrypton avatar Oct 23 '25 06:10 valkrypton

@valkrypton I waited with reviewing since tests were failing. And seems there is a merge conflict now also.

Can you fix both, I will review after? Let me know if you need help with the merge conflict.

You can run the same tests ci-cd does by running just qa locally, if that command succeeds ci-cd should also succeed

soundofspace avatar Oct 23 '25 07:10 soundofspace

Fixed @soundofspace

valkrypton avatar Oct 23 '25 08:10 valkrypton

LGTM for me, thanks for this! @GlenDC do you still want to review?

soundofspace avatar Oct 23 '25 13:10 soundofspace

LGTM for me, thanks for this! @GlenDC do you still want to review?

Yes I'll review tonight and merge it if I'm also okay with it. Can you @soundofspace please resolve the threads with a comment if they are resolved as there are still open (review/comment) threads in this PR.

GlenDC avatar Oct 23 '25 13:10 GlenDC

LGTM for me, thanks for this! @GlenDC do you still want to review?

Yes I'll review tonight and merge it if I'm also okay with it. Can you @soundofspace please resolve the threads with a comment if they are resolved as there are still open (review/comment) threads in this PR.

Resolved them, thought I resolved all of them, but seems like Github didn't load all of them

soundofspace avatar Oct 23 '25 13:10 soundofspace

In case there is something nog clear @valkrypton , do ask @soundofspace or myself for more explanation. Issues like these come with mentoring so do make use of it where you need and want it.

GlenDC avatar Oct 28 '25 13:10 GlenDC

In case there is something nog clear @valkrypton , do ask @soundofspace or myself for more explanation. Issues like these come with mentoring so do make use of it where you need and want it.

Yes I will definitely ask for help if i need it. I've been busy with my day job. I'll take a look at this over the weekend

valkrypton avatar Oct 28 '25 13:10 valkrypton

@GlenDC could you take a look at the new changes?

valkrypton avatar Nov 25 '25 09:11 valkrypton

@GlenDC @soundofspace I've updated the docs, please have a look

valkrypton avatar Nov 26 '25 09:11 valkrypton

@valkrypton ci/cd is failing can you fix it and run just qa locally to test if everything is working

soundofspace avatar Nov 27 '25 09:11 soundofspace

just qa runs successfully for me

valkrypton avatar Nov 27 '25 11:11 valkrypton

just qa runs successfully for me

rebase main branch in your branch, you’ll see the errors once you did that.

We no longer allow usage of expext/unwrap unless you explicitly allow it. Most of the times however you want to actually avoid it

GlenDC avatar Nov 27 '25 11:11 GlenDC

rebased and pushed

valkrypton avatar Nov 27 '25 12:11 valkrypton