Skip to content

Decoupled crypto backends (the rest) #428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 47 commits into
base: master
Choose a base branch
from

Conversation

sulami
Copy link

@sulami sulami commented May 11, 2025

This is following up on #410 with the rest of the decoupled implementations, and addressing most of the review comments (I think?).

There are still some todos left for documentation, which I haven't filled in yet.

I've verified that tests & clippy pass with all combinations of features, but a lot of this I only know enough about to be dangerous, so I'd appreciate close looks at the actual implementations to make sure e.g. I've picked the correct library functions in each case.

@Keats
Copy link
Owner

Keats commented Jun 24, 2025

:o how did i miss this sorry, i'll go through it asap

Copy link
Owner

@Keats Keats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall. I think some macros would help reduce the duplication

Cargo.toml Outdated
@@ -48,8 +60,10 @@ time = { version = "0.3", features = ["wasm-bindgen"] }
criterion = { version = "0.4", default-features = false }

[features]
default = ["use_pem"]
default = ["use_pem", "aws_lc_rs"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a default crypto backend or let users pick the one they want?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, that's up to you. I personally think it's nice to have a reasonable default.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aws_lc_rs would be a good default

src/decoding.rs Outdated
return Err(new_error(ErrorKind::MissingAlgorithm));
}

// Todo: This behaviour is currently not captured anywhere.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have an idea on how to improve that, i'll take it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is actually @sidrubs', I'm not entirely sure what they mean by that, whether it's not covered by tests, or docs, or...?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to uncomment it for now, but ideally we find a better way to handle it before releasing the next version since it trips up people

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've re-enabled this with adaptation to the new code structure, and at least it doesn't seem to break any tests.

@sulami
Copy link
Author

sulami commented Jun 25, 2025

I'll have a go at reducing the duplication through some macros and addressing the other comments.

@sulami
Copy link
Author

sulami commented Jun 25, 2025

Alright, done some refactoring to reduce the duplication and re-enabled the WASM HMAC test cases. I checked that tests pass with both AWS-LC and Rust-crypto.

Copy link
Owner

@Keats Keats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks great. I'll have another look before merging but it's a great improvement!

src/decoding.rs Outdated
return Err(new_error(ErrorKind::MissingAlgorithm));
}

// Todo: This behaviour is currently not captured anywhere.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to uncomment it for now, but ideally we find a better way to handle it before releasing the next version since it trips up people

tests/rsa/mod.rs Outdated
@@ -26,6 +26,8 @@ pub struct Claims {
exp: i64,
}

// Todo: These no longer apply because `verify` does not exist, would probably need to convert it to test the factory for getting signers and verifiers. But I would rather this not be part of the public facing API.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it still a todo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah true, missed that one. verify does indeed exist again.

sulami added 3 commits July 3, 2025 12:39
This was commented out with the note that it wasn't "captured anywhere,"
presumably in tests, but is present in similar form in the
pre-decoupling version of the code.
They had todos for docstrings, and I realized they're single-use and
should probably not be exposed publicly anyway.
@sulami sulami force-pushed the decoupled-crypto-backends branch from 4664843 to 76b2fe3 Compare July 3, 2025 03:53
@sulami
Copy link
Author

sulami commented Jul 3, 2025

Addressed the latest comments, and also inlined _encode and _decode, which were single use, for some reason pub, and had TODO as docstrings.

@sulami
Copy link
Author

sulami commented Aug 5, 2025

@Keats Just in case you missed it again, I think this should be good for another review now.

@sulami sulami requested a review from Keats August 5, 2025 00:28
Copy link
Owner

@Keats Keats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good. One small copy/paste issue but fine otherwise. I need to create a 0.10 branch to group everything

@Keats
Copy link
Owner

Keats commented Aug 14, 2025

The wasm failure seems legit?

@sulami
Copy link
Author

sulami commented Aug 14, 2025

Looking at the AWS-LC docs, I don't think it builds/is supported on WASM. I've also recently read this with regards to default features, and I'm thinking maybe we shouldn't have a default backend after all? That way we could also pick a different backend for the WASM build.

@Keats
Copy link
Owner

Keats commented Aug 15, 2025

Yeah maybe let's not have a default if the default doesn't work with wasm.

In most situations AWS-LC is the better backend, but it's not available
on all platforms, for example WASM. Explicitly asking the user to pick a
backend is also more future-proof.
@Keats
Copy link
Owner

Keats commented Aug 18, 2025

Looks like legit failures as well

@sulami
Copy link
Author

sulami commented Aug 19, 2025

I don't know if this'll work or not, at least it builds on my machine, but it doesn't pass the WASM tests. Neither does master though, so I'm not sure that counts for much.

I'm not terribly familiar with WASM overall, so I wouldn't mind additional pointers & opinions.

This is fixing a Clippy complaint.
@sulami sulami force-pushed the decoupled-crypto-backends branch from 6619f3b to 570d732 Compare August 23, 2025 02:15
@sulami sulami force-pushed the decoupled-crypto-backends branch from 570d732 to eca3603 Compare August 23, 2025 02:27
@sulami
Copy link
Author

sulami commented Aug 23, 2025

I've addressed @jplatte's feedback, and I've also run a wasm CI run in my fork to shorten the feedback loop a bit here.

Copy link

@jplatte jplatte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking forward to this landing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants