Skip to content
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

Make RSA API more usable #766

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Make RSA API more usable #766

wants to merge 4 commits into from

Conversation

keks
Copy link
Member

@keks keks commented Jan 23, 2025

This PR makes changes to the API of the libcrux-rsa crate:

  • Get rid of the signature type and use byte arrays instead
  • Add an API that uses slices instead of array references and does the relevant length checks. The idea here is that this makes it easier to use if the lengths of the keys and signatures are not known at compile time.
  • Add a test using that API

@keks keks requested a review from a team as a code owner January 23, 2025 10:26
@keks keks requested review from franziskuskiefer and removed request for franziskuskiefer January 23, 2025 11:31
Copy link
Collaborator

@jschneider-bensch jschneider-bensch left a comment

Choose a reason for hiding this comment

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

I think it looks good!
Could you add some tests that trigger the new errors, as well?

Copy link
Collaborator

@jschneider-bensch jschneider-bensch left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for adding more docs, as well. :)

/// Returns `Ok(())` on success.
///
/// Returns an error in any of the following cases:
/// - the secret key is invalid
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is that the SigningFailed error?

/// Returns an error in any of the following cases:
/// - the secret key is invalid
/// - the length of `msg` exceeds `u32::MAX`
/// - `salt_len` exceeds `u32::MAX - alg.hash_len() - 8`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// - `salt_len` exceeds `u32::MAX - alg.hash_len() - 8`
/// - `salt_len` exceeds `u32::MAX - alg.hash_len() - 8`
/// - the length of `sig` does not match the length of `sk`

&salt,
&mut signature[..],
)
.expect_err("expected singing with wrong length to fail");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
.expect_err("expected singing with wrong length to fail");
.expect_err("expected signing with wrong length to fail");

@franziskuskiefer
Copy link
Member

@keks can this get merged?

@keks
Copy link
Member Author

keks commented Jan 30, 2025

There are still the outstanding comments by Jonas. I'll get this ready on Monday

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.

3 participants