modules: mbedtls: bring back SHA384 support

Before mbedTLS 3.0 there was just SHA512 option, which enabled both SHA384
and SHA512 support. mbedTLS 3.0 introduced SHA384 specific option, which
means that SHA384 got unsupported after merging
commit 4e6cfb67f9 ("modules: mbedTLS: Bump mbedTLS to 3.0").

Introduce SHA384 Kconfig options, so that support for it can be selected in
project configuration if needed. Since SHA384 still depends on SHA512 to be
selected, add such dependency in Kconfig.

Select SHA384 support in non-generic (not configured by Kconfig) mbedTLS
config headers, so that previous (before mbedTLS 3.0 was merged) behavior
is regained.

Fixes: 4e6cfb67f9 ("modules: mbedTLS: Bump mbedTLS to 3.0")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
This commit is contained in:
Marcin Niestroj 2022-06-12 23:49:32 +02:00 committed by Carles Cufí
commit dfe9a91da2
4 changed files with 20 additions and 2 deletions

View file

@ -188,12 +188,18 @@ comment "Supported hash"
config MBEDTLS_HASH_ALL_ENABLED
bool "All available hashes"
select MBEDTLS_HASH_SHA256_ENABLED
select MBEDTLS_HASH_SHA384_ENABLED
select MBEDTLS_HASH_SHA512_ENABLED
config MBEDTLS_HASH_SHA256_ENABLED
bool "SHA256 hash"
default y if !NET_L2_OPENTHREAD
config MBEDTLS_HASH_SHA384_ENABLED
bool "SHA384 hash"
default y if !NET_L2_OPENTHREAD
select MBEDTLS_HASH_SHA512_ENABLED
config MBEDTLS_HASH_SHA512_ENABLED
bool "SHA512 hash"
default y if !NET_L2_OPENTHREAD
@ -271,6 +277,7 @@ config MBEDTLS_MAC_ALL_ENABLED
select MBEDTLS_MAC_MD5_ENABLED
select MBEDTLS_MAC_SHA1_ENABLED
select MBEDTLS_MAC_SHA256_ENABLED
select MBEDTLS_MAC_SHA384_ENABLED
select MBEDTLS_MAC_SHA512_ENABLED
select MBEDTLS_MAC_POLY1305_ENABLED
select MBEDTLS_MAC_CMAC_ENABLED
@ -298,8 +305,12 @@ config MBEDTLS_SHA256_SMALLER
Enable an implementation of SHA-256 that has lower ROM footprint but also
lower performance
config MBEDTLS_MAC_SHA384_ENABLED
bool "SHA-384 hash algorithm"
select MBEDTLS_MAC_SHA512_ENABLED
config MBEDTLS_MAC_SHA512_ENABLED
bool "SHA-384 and SHA-512 hash algorithms"
bool "SHA-512 hash algorithm"
config MBEDTLS_MAC_POLY1305_ENABLED
bool "Poly1305 MAC algorithm"
@ -348,7 +359,7 @@ config MBEDTLS_HAVE_ASM
config MBEDTLS_ENTROPY_ENABLED
bool "MbedTLS generic entropy pool"
depends on MBEDTLS_MAC_SHA256_ENABLED || MBEDTLS_MAC_SHA512_ENABLED
depends on MBEDTLS_MAC_SHA256_ENABLED || MBEDTLS_MAC_SHA384_ENABLED || MBEDTLS_MAC_SHA512_ENABLED
config MBEDTLS_OPENTHREAD_OPTIMIZATIONS_ENABLED
bool "MbedTLS optimizations for OpenThread"

View file

@ -103,6 +103,7 @@
#define MBEDTLS_RSA_C
#define MBEDTLS_SHA224_C
#define MBEDTLS_SHA256_C
#define MBEDTLS_SHA384_C
#define MBEDTLS_SHA512_C
#define MBEDTLS_VERSION_C
#define MBEDTLS_X509_USE_C

View file

@ -92,6 +92,7 @@
#define MBEDTLS_PK_PARSE_C
#define MBEDTLS_SHA224_C
#define MBEDTLS_SHA256_C
#define MBEDTLS_SHA384_C
#define MBEDTLS_SHA512_C
#define MBEDTLS_SSL_CLI_C
#define MBEDTLS_SSL_SRV_C

View file

@ -254,6 +254,11 @@
#define MBEDTLS_SHA256_SMALLER
#endif
#if defined(CONFIG_MBEDTLS_MAC_SHA384_ENABLED) || \
defined(CONFIG_MBEDTLS_HASH_SHA384_ENABLED)
#define MBEDTLS_SHA384_C
#endif
#if defined(CONFIG_MBEDTLS_MAC_SHA512_ENABLED) || \
defined(CONFIG_MBEDTLS_HASH_SHA512_ENABLED)
#define MBEDTLS_SHA512_C