Skip to content

Conversation

johannheyszl
Copy link
Contributor

@johannheyszl johannheyszl commented Jul 30, 2025

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.

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]>
@johannheyszl johannheyszl force-pushed the fixSCAinP256exponentiationloop branch from 6978fad to 7df9b56 Compare July 30, 2025 20:31
@johannheyszl johannheyszl marked this pull request as ready for review August 6, 2025 12:12
Copy link
Contributor

@h-filali h-filali left a 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.

Copy link
Contributor

@andrea-caforio andrea-caforio left a 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

Copy link
Contributor

@andreaskurth andreaskurth left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @johannheyszl

@andreaskurth
Copy link
Contributor

Closing and re-opening to enable merge queue for this PR (which was created before MQs were enabled -- see Slack)

@andreaskurth andreaskurth reopened this Aug 7, 2025
@andreaskurth andreaskurth enabled auto-merge August 7, 2025 15:24
@andreaskurth andreaskurth added this pull request to the merge queue Aug 7, 2025
Merged via the queue into lowRISC:master with commit 17587fb Aug 7, 2025
69 of 79 checks passed
@h-filali h-filali added the CherryPick:earlgrey_1.0.0 This PR should be cherry-picked to earlgrey_1.0.0 label Oct 6, 2025
@lowrisc-ci
Copy link

lowrisc-ci bot commented Oct 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CherryPick:earlgrey_1.0.0 This PR should be cherry-picked to earlgrey_1.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants