From 2a9449182c2e4e8182d2b7e067577c5807f310ba Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 15 Nov 2019 12:07:08 -0800 Subject: [PATCH] * Make the `wc_Stm32_Aes_Init` API always available for STM32. ZD 9503 * Fix for SHA256 hash context to only be included for `STM32_HASH_SHA2`. ZD 9503 --- wolfcrypt/src/port/st/stm32.c | 2 -- wolfssl/wolfcrypt/port/st/stm32.h | 18 ++++++++---------- wolfssl/wolfcrypt/sha256.h | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/wolfcrypt/src/port/st/stm32.c b/wolfcrypt/src/port/st/stm32.c index 75588ef6a..2108a0cba 100644 --- a/wolfcrypt/src/port/st/stm32.c +++ b/wolfcrypt/src/port/st/stm32.c @@ -263,7 +263,6 @@ int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo, #ifdef STM32_CRYPTO #ifndef NO_AES -#if defined(WOLFSSL_AES_DIRECT) || defined(HAVE_AESGCM) || defined(HAVE_AESCCM) #ifdef WOLFSSL_STM32_CUBEMX int wc_Stm32_Aes_Init(Aes* aes, CRYP_HandleTypeDef* hcryp) { @@ -359,7 +358,6 @@ int wc_Stm32_Aes_Init(Aes* aes, CRYP_InitTypeDef* cryptInit, return 0; } #endif /* WOLFSSL_STM32_CUBEMX */ -#endif /* WOLFSSL_AES_DIRECT || HAVE_AESGCM || HAVE_AESCCM */ #endif /* !NO_AES */ #endif /* STM32_CRYPTO */ diff --git a/wolfssl/wolfcrypt/port/st/stm32.h b/wolfssl/wolfcrypt/port/st/stm32.h index 22c68d91f..849f2fdb2 100644 --- a/wolfssl/wolfcrypt/port/st/stm32.h +++ b/wolfssl/wolfcrypt/port/st/stm32.h @@ -108,7 +108,7 @@ int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo, #define STM32_HAL_V2 #endif - /* Thee datatype for STM32 CubeMX HAL Crypt calls */ + /* The datatype for STM32 CubeMX HAL Crypt calls */ #ifdef STM32_HAL_V2 #define STM_CRYPT_TYPE uint32_t #else @@ -118,15 +118,13 @@ int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo, /* CRYPT_AES_GCM starts the IV with 2 */ #define STM32_GCM_IV_START 2 - #if defined(WOLFSSL_AES_DIRECT) || defined(HAVE_AESGCM) || defined(HAVE_AESCCM) - struct Aes; - #ifdef WOLFSSL_STM32_CUBEMX - int wc_Stm32_Aes_Init(struct Aes* aes, CRYP_HandleTypeDef* hcryp); - #else /* STD_PERI_LIB */ - int wc_Stm32_Aes_Init(struct Aes* aes, CRYP_InitTypeDef* cryptInit, - CRYP_KeyInitTypeDef* keyInit); - #endif /* WOLFSSL_STM32_CUBEMX */ - #endif /* WOLFSSL_AES_DIRECT || HAVE_AESGCM || HAVE_AESCCM */ + struct Aes; + #ifdef WOLFSSL_STM32_CUBEMX + int wc_Stm32_Aes_Init(struct Aes* aes, CRYP_HandleTypeDef* hcryp); + #else /* STD_PERI_LIB */ + int wc_Stm32_Aes_Init(struct Aes* aes, CRYP_InitTypeDef* cryptInit, + CRYP_KeyInitTypeDef* keyInit); + #endif /* WOLFSSL_STM32_CUBEMX */ #endif /* !NO_AES */ #endif /* STM32_CRYPTO */ diff --git a/wolfssl/wolfcrypt/sha256.h b/wolfssl/wolfcrypt/sha256.h index cf7b546f2..1d84a8481 100644 --- a/wolfssl/wolfcrypt/sha256.h +++ b/wolfssl/wolfcrypt/sha256.h @@ -132,7 +132,7 @@ enum { struct wc_Sha256 { #ifdef FREESCALE_LTC_SHA ltc_hash_ctx_t ctx; -#elif defined(STM32_HASH) +#elif defined(STM32_HASH_SHA2) STM32_HASH_Context stmCtx; #else /* alignment on digest and buffer speeds up ARMv8 crypto operations */