From 703d143619dcb740b5da71953e57d2ec5bf535ca Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 17 Aug 2017 15:48:43 +1000 Subject: [PATCH] hwcrypto: Fix bug with concurrent SHA access If two different types of SHA hashes were active in the hardware concurrently, a race condition meant the SHA unit could be incorrectly reset leading to all-zero results. --- components/esp32/hwcrypto/sha.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp32/hwcrypto/sha.c b/components/esp32/hwcrypto/sha.c index 0c0c8ddb5..305b476a8 100644 --- a/components/esp32/hwcrypto/sha.c +++ b/components/esp32/hwcrypto/sha.c @@ -172,10 +172,10 @@ static void esp_sha_lock_engine_inner(sha_engine_state *engine) DPORT_STALL_OTHER_CPU_END(); } - _lock_release(&state_change_lock); - assert( !engine->in_use && "in_use flag should be cleared" ); engine->in_use = true; + + _lock_release(&state_change_lock); }