Skip to content

[crypto] Add masked SHA2 and hkdf OTBN binaries - #31237

Open
siemen11 wants to merge 5 commits into
lowRISC:masterfrom
siemen11:otbn_masked_sha256
Open

siemen11 wants to merge 5 commits into
lowRISC:masterfrom
siemen11:otbn_masked_sha256

Conversation

@siemen11

@siemen11 siemen11 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Add masked SHA2 OTBN binaries and create TVLA scripts for their simulated security

@siemen11

siemen11 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author
Algorithm Cycles IMEM (.text) DMEM (.data)
SHA-256 23,023 1,024 B 288 B
SHA-384 65,458 1,496 B 736 B
SHA-512 65,456 1,496 B 736 B

@siemen11
siemen11 force-pushed the otbn_masked_sha256 branch 2 times, most recently from 5e6da8a to 277b849 Compare September 17, 2026 14:43
@siemen11 siemen11 changed the title [crypto] Add a masked SHA256 OTBN binary [crypto] Add masked SHA2 OTBN binaries Sep 17, 2026
@siemen11
siemen11 requested a review from a team as a code owner September 17, 2026 18:06
@siemen11
siemen11 requested review from alees24 and removed request for a team September 17, 2026 18:06
@siemen11
siemen11 requested a review from cfrantz as a code owner September 17, 2026 19:43
@siemen11 siemen11 changed the title [crypto] Add masked SHA2 OTBN binaries [crypto] Add masked SHA2 and hkdf OTBN binaries Sep 17, 2026
@siemen11

siemen11 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Algorithm │ Cycles (N=1 ) │ IMEM │ DMEM

HKDF-SHA256 │ 151,250 │ 2,392 B │ 1,824 B
HKDF-SHA384 │ 391,618 │ 3,144 B │ 2,912 B
HKDF-SHA512 │ 391,234 │ 2,960 B │ 2,912 B

@andrea-caforio andrea-caforio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is great @siemen11. I've not yet looked at HDKF but will do ASAP.

Comment thread sw/otbn/crypto/sha256_masked.s Outdated
Comment thread sw/otbn/crypto/sha256_masked.s Outdated
Comment thread sw/otbn/crypto/sha256_masked.s Outdated
Comment thread sw/otbn/crypto/sha256_masked.s Outdated
Comment thread sw/otbn/crypto/sha256_masked.s Outdated
Comment thread sw/otbn/crypto/sha2/sha256_masked.s
Comment thread sw/otbn/crypto/sha256_masked.s Outdated
* and register wiping with MAI execution.
* Computes (w0, w1) = (w0, w1) + (w2, w3) mod 2^64 across 4 64-bit lanes.
*/
sec_add64:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Holy moly...the monster gadget...haha!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yo @h-filali, check this out. :-)

Comment thread sw/otbn/crypto/tests/sha256_masked_test.exp Outdated
Comment thread sw/otbn/crypto/sha2/sha256_masked.s
@siemen11
siemen11 force-pushed the otbn_masked_sha256 branch 2 times, most recently from fc51e3e to 15c0413 Compare September 18, 2026 07:58
@siemen11
siemen11 requested a review from a team as a code owner September 18, 2026 10:48
@siemen11
siemen11 requested review from timothytrippel and removed request for a team and timothytrippel September 18, 2026 10:48
@siemen11
siemen11 force-pushed the otbn_masked_sha256 branch 3 times, most recently from f9f0b5a to 36c59bb Compare September 20, 2026 09:46
@@ -141,6 +143,53 @@ sec_add_8x32:

ret

/**

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that if we pull in this isw and, we also pull in all the other gadgets from this file thus increasing IMEM

Use the MAI to create SHA2 maskings on OTBN.
Add tvla sim tests for them.
Also connect them to the c interface and add a functest.

Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
Also add tvla sim tests for them.

Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
@siemen11
siemen11 requested a review from vogelpi as a code owner September 20, 2026 10:57
@siemen11
siemen11 removed the request for review from vogelpi September 20, 2026 10:57
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