Skip to content

Commit

Permalink
core: ltc: configure internal SHA-1 and SHA-224
Browse files Browse the repository at this point in the history
Adds _CFG_CORE_LTC_SHA1_DESC and _CFG_CORE_LTC_SHA224_DESC to allow
enabling support for SHA-1 and SHA-224 internally in LTC.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-By: Jerome Forissier <jerome.forissier@linaro.org>
  • Loading branch information
jenswi-linaro committed Oct 6, 2023
1 parent 0e48a6e commit 2b0d0c5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions core/crypto.mk
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ endif
# libtomcrypt (LTC) specifics, phase #2
###############################################################

_CFG_CORE_LTC_SHA1_DESC := $(call cfg-one-enabled, _CFG_CORE_LTC_SHA1_DESC \
_CFG_CORE_LTC_SHA1)
_CFG_CORE_LTC_SHA224_DESC := $(call cfg-one-enabled, _CFG_CORE_LTC_SHA224_DESC \
_CFG_CORE_LTC_SHA224)
_CFG_CORE_LTC_SHA256_DESC := $(call cfg-one-enabled, _CFG_CORE_LTC_SHA256_DESC \
_CFG_CORE_LTC_SHA224 \
_CFG_CORE_LTC_SHA256)
Expand Down
10 changes: 5 additions & 5 deletions core/lib/libtomcrypt/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
static TEE_Result tee_algo_to_ltc_hashindex(uint32_t algo, int *ltc_hashindex)
{
switch (algo) {
#if defined(_CFG_CORE_LTC_SHA1)
#if defined(_CFG_CORE_LTC_SHA1_DESC)
case TEE_ALG_RSASSA_PKCS1_V1_5_SHA1:
case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1:
case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1:
Expand All @@ -43,28 +43,28 @@ static TEE_Result tee_algo_to_ltc_hashindex(uint32_t algo, int *ltc_hashindex)
*ltc_hashindex = find_hash("md5");
break;
#endif
#if defined(_CFG_CORE_LTC_SHA224)
#if defined(_CFG_CORE_LTC_SHA224_DESC)
case TEE_ALG_RSASSA_PKCS1_V1_5_SHA224:
case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224:
case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224:
*ltc_hashindex = find_hash("sha224");
break;
#endif
#if defined(_CFG_CORE_LTC_SHA256)
#if defined(_CFG_CORE_LTC_SHA256_DESC)
case TEE_ALG_RSASSA_PKCS1_V1_5_SHA256:
case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256:
case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256:
*ltc_hashindex = find_hash("sha256");
break;
#endif
#if defined(_CFG_CORE_LTC_SHA384)
#if defined(_CFG_CORE_LTC_SHA384_DESC)
case TEE_ALG_RSASSA_PKCS1_V1_5_SHA384:
case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384:
case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384:
*ltc_hashindex = find_hash("sha384");
break;
#endif
#if defined(_CFG_CORE_LTC_SHA512)
#if defined(_CFG_CORE_LTC_SHA512_DESC)
case TEE_ALG_RSASSA_PKCS1_V1_5_SHA512:
case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512:
case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512:
Expand Down
2 changes: 1 addition & 1 deletion core/lib/libtomcrypt/src/hashes/sha2/sub.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
srcs-$(_CFG_CORE_LTC_SHA224) += sha224.c
srcs-$(_CFG_CORE_LTC_SHA224_DESC) += sha224.c

ifneq ($(_CFG_CORE_LTC_SHA256_ACCEL),y)
srcs-$(_CFG_CORE_LTC_SHA256_DESC) += sha256.c
Expand Down
2 changes: 1 addition & 1 deletion core/lib/libtomcrypt/src/hashes/sub.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
srcs-$(_CFG_CORE_LTC_MD5) += md5.c

ifeq ($(_CFG_CORE_LTC_SHA1),y)
ifeq ($(_CFG_CORE_LTC_SHA1_DESC),y)
ifneq ($(_CFG_CORE_LTC_SHA1_ACCEL),y)
srcs-y += sha1.c
endif
Expand Down
4 changes: 2 additions & 2 deletions core/lib/libtomcrypt/sub.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ cppflags-lib-y += -DLTC_NO_HASHES
ifeq ($(_CFG_CORE_LTC_MD5),y)
cppflags-lib-y += -DLTC_MD5
endif
ifeq ($(_CFG_CORE_LTC_SHA1),y)
ifeq ($(_CFG_CORE_LTC_SHA1_DESC),y)
cppflags-lib-y += -DLTC_SHA1
endif
ifeq ($(_CFG_CORE_LTC_SHA224),y)
ifeq ($(_CFG_CORE_LTC_SHA224_DESC),y)
cppflags-lib-y += -DLTC_SHA224
endif
ifeq ($(_CFG_CORE_LTC_SHA256_DESC),y)
Expand Down
4 changes: 2 additions & 2 deletions core/lib/libtomcrypt/tomcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ static void tee_ltc_reg_algs(void)
#if defined(_CFG_CORE_LTC_MD5)
register_hash(&md5_desc);
#endif
#if defined(_CFG_CORE_LTC_SHA1)
#if defined(_CFG_CORE_LTC_SHA1) || defined(_CFG_CORE_LTC_SHA1_DESC)
register_hash(&sha1_desc);
#endif
#if defined(_CFG_CORE_LTC_SHA224)
#if defined(_CFG_CORE_LTC_SHA224) || defined(_CFG_CORE_LTC_SHA224_DESC)
register_hash(&sha224_desc);
#endif
#if defined(_CFG_CORE_LTC_SHA256) || defined(_CFG_CORE_LTC_SHA256_DESC)
Expand Down

0 comments on commit 2b0d0c5

Please sign in to comment.