Skip to content

Commit 4fd51d8

Browse files
committed
Peer review feedback
1 parent 581af9e commit 4fd51d8

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

wolfcrypt/src/port/st/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ To disable portions of the hardware acceleration you can optionally define:
4141
#define NO_STM32_RNG
4242
#define NO_STM32_CRYPTO
4343
#define NO_STM32_HASH
44+
#define NO_STM32_HMAC
4445
```
4546

4647
### Coding

wolfcrypt/src/port/st/stm32.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ static void wc_Stm32_Hash_RestoreContext(STM32_HASH_Context* ctx, word32 algo,
184184
);
185185

186186
/* configure algorithm, mode and data type
187-
* mode is HASH_ALGOMODE_HASH or HASH_ALGOMODE_HMAC
188-
* (may include HASH_CR_LKEY for HMAC with long key) */
187+
* mode is HASH_ALGOMODE_HASH or HASH_ALGOMODE_HMAC */
189188
HASH->CR |= (algo | mode | HASH_DATATYPE_8B);
190189

191190
/* reset HASH processor */
@@ -560,13 +559,10 @@ int wc_Stm32_Hmac_SetKey(STM32_HASH_Context* stmCtx, int macType,
560559
/* turn on hash clock */
561560
STM32_HASH_CLOCK_ENABLE(stmCtx);
562561

563-
/* initialize hardware for HMAC mode */
562+
/* initialize hardware for HMAC mode.
563+
* Keys are always pre-hashed in software before reaching this point
564+
* (see hmac.c), so keySz will always be <= blockSize here. */
564565
mode = HASH_ALGOMODE_HMAC;
565-
#ifdef HASH_CR_LKEY
566-
if (keySz > blockSize) {
567-
mode |= HASH_CR_LKEY;
568-
}
569-
#endif
570566
wc_Stm32_Hash_RestoreContext(stmCtx, algo, mode);
571567

572568
/* Phase 1: Feed key into HASH->DIN */

0 commit comments

Comments
 (0)