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/otbn/sca] ecc256 device software for SCA #17273

Closed
wants to merge 28 commits into from

Conversation

wettermo
Copy link
Contributor

This PR is related to lowRISC/ot-sca#115 in the ot-sca repository.

I fetched previous work from @jadephilipoom on ecc256 keygen and sign, which contains device software for SCA.
On top of that I edited the ecc256 keygen serial file to split loading of OTBN IMEM and DMEM, as discussed in the SCA WG meeting. This speeds up trace capture by ca. 10%.
In the future, when capturing traces for ecc256 sign, this modification probably has to be repeated.

jadephilipoom and others added 28 commits February 10, 2023 10:57
This is part of a large-scale hardening of ECDSA scalars; all procedures
using k will be modified to accept the extra redundant bits.

Signed-off-by: Jade Philipoom <[email protected]>
Modify the test to randomize k so that handling of the new extra bits is
tested.

Signed-off-by: Jade Philipoom <[email protected]>
Change the way the modular inverse of k is computed; rather than simply
operate on k in plaintext, first multiply k with a random scalar alpha,
compute the inverse (k * alpha)^-1, and multiply by alpha again to get
k^-1.

Signed-off-by: Jade Philipoom <[email protected]>
Similarly to k, all routines handling d will be modified to handle extra
redundant bits.

Signed-off-by: Jade Philipoom <[email protected]>
Randomize first share of d so that the handling of new extra bits is tested.

Signed-off-by: Jade Philipoom <[email protected]>
Randomize both shares of scalars d and k in ECDSA sign test, not just
the first share, to increase test coverage.

Signed-off-by: Jade Philipoom <[email protected]>
Remove some instructions that turn out to be unnecessary due to
bn.mulqacc setting the M flag.

Signed-off-by: Jade Philipoom <[email protected]>
Update the cryptolib implementation and the SCA P-256 code to match new,
longer P-256 scalar inputs.

Also adjust all I/O buffers for scalars to have 512 bits so that reads
don't produce runtime errors (since a 320-bit load on OTBN must be a
512-bit load).

Signed-off-by: Jade Philipoom <[email protected]>
In preparation for changing scalar_mult_int to handle longer scalars,
reduce the register pressure in the inner loop.

Signed-off-by: Jade Philipoom <[email protected]>
Change the scalar_mult_int subroutine for ECDSA-P256 to support 320-bit
hardened scalars.

Signed-off-by: Jade Philipoom <[email protected]>
Modify the P-256 random scalar generation routine to produce extra-long
scalars.

Signed-off-by: Jade Philipoom <[email protected]>
Split loading of OTBN IMEM and DMEM from Ibex side. OTBN app is
loaded for every trace, but only DMEM is really needed.
This speeds up trace capture.

Signed-off-by: Moritz Wettermann <[email protected]>
@wettermo wettermo requested a review from a team as a code owner February 13, 2023 10:06
@wettermo wettermo removed the request for review from a team February 13, 2023 10:06
@wettermo
Copy link
Contributor Author

After consultation with @jadephilipoom, this PR doesn't make any sense, as #16953 already contains a lot of code which is also in this PR.
I'll merge my modifications into Jade's OT fork so that she can open another PR into the lowrisc repository.

@wettermo wettermo closed this Feb 13, 2023
@wettermo wettermo deleted the p256-key-from-seed-sca branch February 27, 2023 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants