Skip to content

Commit f4d0944

Browse files
siemen11nasahlpa
authored andcommitted
[crypto/drbg] Maximize value_words size
The drbg creates a buffer value_words with a user chosen input length. However, the length is checked to be at most a certain size. Make that temporary buffer max sized. Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
1 parent 63c0775 commit f4d0944

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • sw/device/lib/crypto/impl

sw/device/lib/crypto/impl/drbg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ static otcrypto_status_t seed_material_xor(
8989
// Copy into a word-aligned buffer. This allows us to use a XOR that is more
9090
// resilient against SCA leakage.
9191
size_t nwords = ceil_div(value->len, sizeof(uint32_t));
92-
uint32_t value_words[nwords];
93-
value_words[nwords - 1] = 0;
92+
uint32_t value_words[kEntropySeedWords];
93+
memset(value_words, 0, sizeof(value_words));
9494
HARDENED_TRY(randomized_bytecopy(value_words, value->data, value->len));
9595
// Check whether a FI tampered copying the bytes.
9696
HARDENED_CHECK_EQ(consttime_memeq_byte(value->data, value_words, value->len),

0 commit comments

Comments
 (0)