-
Notifications
You must be signed in to change notification settings - Fork 904
[crypto] P256 scalar multiplication code-review for SCA hardening #27771
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
[crypto] P256 scalar multiplication code-review for SCA hardening #27771
Conversation
Avoid potential horizontal SCA issue in P256 scalar multiplication based on code review. Avoid that source and dest of one case in BN.SEL uses the same value by preseting with randomness. Re-order code to randomize destination of (first) BN.SEL before 1st use. Typos and minor edits of comments in P256 scalar mult. Signed-off-by: Johann Heyszl <[email protected]>
6978fad
to
7df9b56
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM!
I think the initialization of the registers with randomness in this PR is absolutely necessary. Otherwise, the transient leakage from overwriting regs with the same value vs a new value could potentially leak the value of the OR/XOR result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sound. Thank you @johannheyszl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @johannheyszl
Closing and re-opening to enable merge queue for this PR (which was created before MQs were enabled -- see Slack) |
Successfully created backport PR for |
Avoid potential horizontal SCA issue in P256 scalar multiplication based on code review. Avoid that source and dest of one case in BN.SEL uses the same value by preseting with randomness.
Runtime overhead +3*320 instructions = very low.
Codesize overhead +3 instruction = very low.