Fix panic in Int::div_rem_unsigned with large divisors#1250
Open
cong-or wants to merge 1 commit intoRustCrypto:masterfrom
Open
Fix panic in Int::div_rem_unsigned with large divisors#1250cong-or wants to merge 1 commit intoRustCrypto:masterfrom
cong-or wants to merge 1 commit intoRustCrypto:masterfrom
Conversation
panics when the remainder's magnitude doesn't fit in , which happens when the divisor is large enough. Use instead, matching the vartime path. Fixes RustCrypto#847
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1250 +/- ##
==========================================
+ Coverage 87.99% 90.87% +2.88%
==========================================
Files 184 186 +2
Lines 21244 21609 +365
==========================================
+ Hits 18693 19638 +945
+ Misses 2551 1971 -580 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix ct
div_rem_unsignedblowing up on large divisorsRan into this while poking at something unrelated.
The constant-time
div_rem_unsignedbreaks when the divisor gets big enough(e.g. any
U128>I128::MAX), since the remainder can’t fit in a signedint of the same size. The ct path was going through
new_from_abs_sign,which ends up blowing up in that case.
The vartime version doesn’t have this issue since it just uses
as_int().wrapping_neg_if(), so this switches the ct path to do the same.Added a test with the values from the issue to make sure it doesn’t regress.
Fixes #847