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

[crypto] Harden RSA modexp subroutine. #25694

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions sw/otbn/crypto/modexp.s
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,29 @@
* @param[in] x11: pointer to temp reg, must be set to 2
*
* clobbered registers: x8, x21, w0, w2
* clobbered Flag Groups: none
* clobbered Flag Groups: FG1
*/
sel_sqr_or_sqrmul:
/* iterate over all limbs */
loop x30, 4
loop x30, 8
/* load limb from dmem */
bn.lid x9, 0(x21)

/* load limb from regfile buffer */
bn.movr x11, x8++

/* conditional select: w0 = FG0.C?w[x8+i]:dmem[x21+i] */
bn.sel w0, w2, w3, C
/* randomize dmem with value from URND (one extra dummy call to clear) */
bn.addi w31, w31, 0, FG1 /* dummy */
bn.wsrr w0, URND
bn.sid x0, 0(x21)

/* store selected limb to dmem */
/* select a limb and store to dmem */
bn.sel w0, w2, w3, FG0.C
bn.sid x0, 0(x21++)

/* dummy call to clear */
bn.addi w31, w31, 0, FG1

ret


Expand Down
Loading