From aad7ff813c92c55bbe46017b88f620cd0f782d10 Mon Sep 17 00:00:00 2001 From: makejian Date: Wed, 13 Mar 2024 20:47:11 +0800 Subject: [PATCH] opteeos/libmbedtls: support alloc ctx about sha3 series optee support using mbedtls sha3 series Signed-off-by: makejian --- lib/libmbedtls/core/hash.c | 28 ++++++++++++++++++++++++++++ lib/libmbedtls/core/hmac.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/lib/libmbedtls/core/hash.c b/lib/libmbedtls/core/hash.c index d2977c513..2c5dd2f16 100644 --- a/lib/libmbedtls/core/hash.c +++ b/lib/libmbedtls/core/hash.c @@ -177,6 +177,34 @@ TEE_Result crypto_sha512_alloc_ctx(struct crypto_hash_ctx **ctx) } #endif +#if defined(CFG_CRYPTO_SHA3_224) +TEE_Result crypto_sha3_224_alloc_ctx(struct crypto_hash_ctx **ctx) +{ + return mbed_hash_alloc_ctx(ctx, MBEDTLS_MD_SHA3_224); +} +#endif + +#if defined(CFG_CRYPTO_SHA3_256) +TEE_Result crypto_sha3_256_alloc_ctx(struct crypto_hash_ctx **ctx) +{ + return mbed_hash_alloc_ctx(ctx, MBEDTLS_MD_SHA3_256); +} +#endif + +#if defined(CFG_CRYPTO_SHA3_384) +TEE_Result crypto_sha3_384_alloc_ctx(struct crypto_hash_ctx **ctx) +{ + return mbed_hash_alloc_ctx(ctx, MBEDTLS_MD_SHA3_384); +} +#endif + +#if defined(CFG_CRYPTO_SHA3_512) +TEE_Result crypto_sha3_512_alloc_ctx(struct crypto_hash_ctx **ctx) +{ + return mbed_hash_alloc_ctx(ctx, MBEDTLS_MD_SHA3_512); +} +#endif + #if defined(CFG_CRYPTO_SHA256) TEE_Result hash_sha256_check(const uint8_t *hash, const uint8_t *data, size_t data_size) diff --git a/lib/libmbedtls/core/hmac.c b/lib/libmbedtls/core/hmac.c index 895ced1e8..34cce4885 100644 --- a/lib/libmbedtls/core/hmac.c +++ b/lib/libmbedtls/core/hmac.c @@ -175,3 +175,31 @@ TEE_Result crypto_hmac_sha512_alloc_ctx(struct crypto_mac_ctx **ctx) return mbed_hmac_alloc_ctx(ctx, MBEDTLS_MD_SHA512); } #endif + +#if defined(CFG_CRYPTO_SHA3_224) +TEE_Result crypto_hmac_sha3_224_alloc_ctx(struct crypto_mac_ctx **ctx) +{ + return mbed_hmac_alloc_ctx(ctx, MBEDTLS_MD_SHA3_224); +} +#endif + +#if defined(CFG_CRYPTO_SHA3_256) +TEE_Result crypto_hmac_sha3_256_alloc_ctx(struct crypto_mac_ctx **ctx) +{ + return mbed_hmac_alloc_ctx(ctx, MBEDTLS_MD_SHA3_256); +} +#endif + +#if defined(CFG_CRYPTO_SHA3_384) +TEE_Result crypto_hmac_sha3_384_alloc_ctx(struct crypto_mac_ctx **ctx) +{ + return mbed_hmac_alloc_ctx(ctx, MBEDTLS_MD_SHA3_384); +} +#endif + +#if defined(CFG_CRYPTO_SHA3_512) +TEE_Result crypto_hmac_sha3_512_alloc_ctx(struct crypto_mac_ctx **ctx) +{ + return mbed_hmac_alloc_ctx(ctx, MBEDTLS_MD_SHA3_512); +} +#endif