From e487685d7d694f628060870d5aeaf9b7c4a60e40 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 2 May 2025 13:51:46 -0700 Subject: [PATCH] Fix for STM32 Hashing status bit checking logic. ZD 19783. The digest calculation was indicating "not busy" before digest result (DCIS) was finished. This did not show up on most systems because the computation is usually done by the time it reads. --- wolfcrypt/src/port/st/stm32.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/port/st/stm32.c b/wolfcrypt/src/port/st/stm32.c index a732ac73a..98f46f4ce 100644 --- a/wolfcrypt/src/port/st/stm32.c +++ b/wolfcrypt/src/port/st/stm32.c @@ -258,14 +258,14 @@ static int wc_Stm32_Hash_WaitDone(STM32_HASH_Context* stmCtx) (void)stmCtx; /* wait until not busy and hash digest / input block are complete */ - while ((HASH->SR & HASH_SR_BUSY) && + while (((HASH->SR & HASH_SR_BUSY) #ifdef HASH_IMR_DCIE - (HASH->SR & HASH_SR_DCIS) == 0 && + || (HASH->SR & HASH_SR_DCIS) == 0 #endif #ifdef HASH_IMR_DINIE - (HASH->SR & HASH_SR_DINIS) == 0 && + || (HASH->SR & HASH_SR_DINIS) == 0 #endif - ++timeout < STM32_HASH_TIMEOUT) { + ) && ++timeout < STM32_HASH_TIMEOUT) { }; #ifdef DEBUG_STM32_HASH