Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Commit b7e3195

Browse files
authored
Merge pull request #35 from mped-oticon/issue30_vla
portabillity: Make unnecessary VLA into statically sized array
2 parents 8a3b3f7 + 7c4ab60 commit b7e3195

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/source/hmac.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,19 @@ static void rekey(uint8_t *key, const uint8_t *new_key, unsigned int key_size)
5252
int tc_hmac_set_key(TCHmacState_t ctx, const uint8_t *key,
5353
unsigned int key_size)
5454
{
55-
56-
/* input sanity check: */
55+
/* Input sanity check */
5756
if (ctx == (TCHmacState_t) 0 ||
5857
key == (const uint8_t *) 0 ||
5958
key_size == 0) {
6059
return TC_CRYPTO_FAIL;
6160
}
6261

63-
const uint8_t dummy_key[key_size];
62+
const uint8_t dummy_key[TC_SHA256_BLOCK_SIZE];
6463
struct tc_hmac_state_struct dummy_state;
6564

6665
if (key_size <= TC_SHA256_BLOCK_SIZE) {
6766
/*
68-
* The next three lines consist of dummy calls just to avoid
67+
* The next three calls are dummy calls just to avoid
6968
* certain timing attacks. Without these dummy calls,
7069
* adversaries would be able to learn whether the key_size is
7170
* greater than TC_SHA256_BLOCK_SIZE by measuring the time

0 commit comments

Comments
 (0)