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

k256: get rid of eager computation in mul_shift_vartime() #638

Merged
merged 2 commits into from
Aug 10, 2022

Conversation

fjarri
Copy link
Contributor

@fjarri fjarri commented Aug 10, 2022

  • Get rid of eager computation in mul_shift_vartime() in places where it is shift-dependent. It is expected to be vartime on the value of shift, and calculating some of the paths eagerly when they are not required leads to panics. Fixes K256: panic 'attempt to shift left with overflow' in mul_shift_vartime #624
  • Fix a typo in mul_shift_vartime() (incorrect constant, it was 448 instead of 384 in the expression for r1). Fortunately, since it was only ever used with shift == 272, it never mattered.

Fortunately since it was an internal method only used with shift=272,
it never made any difference.
@fjarri fjarri added the k256 secp256k1 crate label Aug 10, 2022
@fjarri fjarri requested a review from tarcieri August 10, 2022 00:04
…t is shift-dependent

It is expected to be vartime on the value of `shift`,
and calculating some of the paths eagerly when they are not required
leads to panics.
@tarcieri tarcieri merged commit d88e8a5 into RustCrypto:master Aug 10, 2022
@fjarri fjarri deleted the shift-fix branch August 10, 2022 03:02
@tarcieri tarcieri mentioned this pull request Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k256 secp256k1 crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

K256: panic 'attempt to shift left with overflow' in mul_shift_vartime
2 participants