Skip to content

Conversation

@andrewwhitehead
Copy link
Contributor

This reapplies the changes in #930 with additional tests for wrapping_mul and wrapping_square, and a small fix for an error occurring in the rsa crate.

…thods into a separate module

Signed-off-by: Andrew Whitehead <[email protected]>
Signed-off-by: Andrew Whitehead <[email protected]>
Signed-off-by: Andrew Whitehead <[email protected]>
Signed-off-by: Andrew Whitehead <[email protected]>
Signed-off-by: Andrew Whitehead <[email protected]>
Signed-off-by: Andrew Whitehead <[email protected]>
while k < lhs.len() {
let j = k - i;
if k == rhs.len() {
if j == rhs.len() {
Copy link
Member

Choose a reason for hiding this comment

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

Was this the only issue? I saw some other test failures besides the out-of-bounds panic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, seems to fix all the tests. Besides the panic it could cause incorrect results, some of the new tests capture that:

thread 'uint::mul::tests::wrapping_mul_mixed' panicked at src/uint/mul.rs:357:9:
assertion `left == right` failed
  left: Uint(0x0000000000000000751EA4E5BF0EB289)
 right: Uint(0x7527C959D947A4F1751EA4E5BF0EB289)

Copy link
Member

@baloo baloo left a comment

Choose a reason for hiding this comment

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

Ran CI on RSA with this change: RustCrypto/RSA#581

@tarcieri
Copy link
Member

I generally wish we had better testing coverage testing which is something I intend to pursue after a release. I feel like we've had a few deficiencies which weren't caught by manual code review or tests. It's generally a bit scary to have defects that aren't caught until we actually integration test against a full cryptographic algorithm implementation. And the real worries are in all those untested branches.

I keep poking at things like hax which would let us possibly have small snippets of code which are proven to be equivalent to some formally verified reference implementation (for all inputs, using e.g. symbolic execution).

@tarcieri tarcieri merged commit 7fd787d into RustCrypto:master Sep 23, 2025
23 checks passed
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