[base/hardened_memory] Add a hardened_add, hardened_sub, and hardened_range_check#29667
Merged
nasahlpa merged 2 commits intolowRISC:earlgrey_1.0.0from Apr 9, 2026
Merged
[base/hardened_memory] Add a hardened_add, hardened_sub, and hardened_range_check#29667nasahlpa merged 2 commits intolowRISC:earlgrey_1.0.0from
nasahlpa merged 2 commits intolowRISC:earlgrey_1.0.0from
Conversation
The OTBN calculates with shared keys using arithmetic masking. When we require the same operation on Ibex, we implement the hardened_add and the hardened_sub. Note that due to the addition/subtraction nature, this loop is not randomized against SCA. Implement a test that the hardened_sub of the hardened_add comes back to the same result. hardened_xor's test was missing, implement the same reversibility test for that as well. Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
andrea-caforio
approved these changes
Apr 7, 2026
Contributor
andrea-caforio
left a comment
There was a problem hiding this comment.
This is nice @siemen11. I will try to make use of these functions in the testcases for the ECC raw key import.
johannheyszl
reviewed
Apr 7, 2026
johannheyszl
approved these changes
Apr 7, 2026
Contributor
johannheyszl
left a comment
There was a problem hiding this comment.
Thanks @siemen11 this is helpful for some integrations.
Add a function that can check whether a value is between 0 and a given value N. The function works on word buffers and is protected against fault injections and is made to be constant time. However, the function is not protected against side-channel attacks as it operates on non-masked values. The function expects buffers in little-endian format. Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
nasahlpa
approved these changes
Apr 9, 2026
|
Successfully created backport PR for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The OTBN calculates with shared keys using arithmetic masking. When we require the same operation on Ibex, we implement the hardened_add and the hardened_sub.
Note that due to the addition/subtraction nature, this loop is not randomized against SCA.
We also provide a range check function to check whether a buffer is between a value N and 0. Again, this is not hardened against SCA but it provides fault countermeasures.
Implement a test that the hardened_sub of the hardened_add comes back to the same result.
hardened_xor's test was missing, implement the same reversibility test for that as well.
Tests are also added for the range check.