-
Notifications
You must be signed in to change notification settings - Fork 950
[cryptolib] Use hardened_* functions in KMAC driver
#29155
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
Conversation
To avoid leakage when unmasking the digest, switch to the SCA resilient `hardened_xor` function. Signed-off-by: Pascal Nasahl <[email protected]>
| } | ||
| for (size_t i = 0; i * sizeof(uint32_t) < key->len; i++) { | ||
| abs_mmio_write32( | ||
| kBase + KMAC_KEY_SHARE0_0_REG_OFFSET + i * sizeof(uint32_t), |
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.
Hm no I don't think so, we want to access byte 0 of share0:
https://opentitan.org/book/hw/ip/kmac/doc/registers.html#key_share0
Use hardened_memcpy for: - Reading the KMAC state register share 0 and 1 - Writing the KMAC key shares 0 and 1 Signed-off-by: Pascal Nasahl <[email protected]>
9e8ba95 to
5067454
Compare
johannheyszl
left a comment
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 @nasahlpa
siemen11
left a comment
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.
Thank you Pascal, this moves the KMAC more in using the standard cryptolib functions
h-filali
left a comment
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 @nasahlpa LGTM!
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin earlgrey_1.0.0
git worktree add -d .worktree/backport-29155-to-earlgrey_1.0.0 origin/earlgrey_1.0.0
cd .worktree/backport-29155-to-earlgrey_1.0.0
git switch --create backport-29155-to-earlgrey_1.0.0
git cherry-pick -x 159e3d43c916ce2dad8f63879a749d42dda052a3 50674547b2e856edea2309a136befe23d5a191f6 |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin earlgrey_1.0.0
git worktree add -d .worktree/backport-29155-to-earlgrey_1.0.0 origin/earlgrey_1.0.0
cd .worktree/backport-29155-to-earlgrey_1.0.0
git switch --create backport-29155-to-earlgrey_1.0.0
git cherry-pick -x 159e3d43c916ce2dad8f63879a749d42dda052a3 50674547b2e856edea2309a136befe23d5a191f6 |
To mitigate fault injection & SCA attacks, use the
hardened_*functions.