Skip to content

Commit 5965d75

Browse files
committed
[crypto] Harden otbn_write function
As secret information is written by this function into DMEM, randomize the write order using `random_order` to mitigate SCA. Harden the loop against FI by checking the loop counter afterwards. Signed-off-by: Pascal Nasahl <[email protected]> (cherry picked from commit 3be9202)
1 parent 7e54a21 commit 5965d75

File tree

1 file changed

+1
-0
lines changed
  • sw/device/lib/crypto/drivers

1 file changed

+1
-0
lines changed

sw/device/lib/crypto/drivers/otbn.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ status_t otbn_dmem_write(size_t num_words, const uint32_t *src,
130130
random_order_init(&order, num_words);
131131

132132
size_t count = 0;
133+
size_t expected_count = random_order_len(&order);
133134

134135
for (; launderw(count) < num_words; count = launderw(count) + 1) {
135136
// The value obtained from `advance()` is laundered, to prevent

0 commit comments

Comments
 (0)