From aa7416594884af048ec77d12f42efaba9c4ff7a5 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 13 Feb 2024 13:40:26 +0000 Subject: [PATCH 1/2] Fix IAR cast warning Signed-off-by: Dave Rodgman --- library/pk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/pk.c b/library/pk.c index 1b481e1a2..076d3a833 100644 --- a/library/pk.c +++ b/library/pk.c @@ -385,7 +385,7 @@ static psa_algorithm_t psa_algorithm_for_rsa(const mbedtls_rsa_context *rsa, { if (mbedtls_rsa_get_padding_mode(rsa) == MBEDTLS_RSA_PKCS_V21) { if (want_crypt) { - mbedtls_md_type_t md_type = mbedtls_rsa_get_md_alg(rsa); + mbedtls_md_type_t md_type = (mbedtls_md_type_t) mbedtls_rsa_get_md_alg(rsa); return PSA_ALG_RSA_OAEP(mbedtls_md_psa_alg_from_type(md_type)); } else { return PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_ANY_HASH); From b4cb8bef42c1751a35b839e721aa3c6a2f3dba56 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Fri, 24 Nov 2023 17:08:54 +0000 Subject: [PATCH 2/2] Fix remaining warnings from -Wshorten-64-to-32 Signed-off-by: Dave Rodgman --- library/aesce.c | 2 +- library/lms.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/library/aesce.c b/library/aesce.c index eaaa5b5c3..6a9e0a1c6 100644 --- a/library/aesce.c +++ b/library/aesce.c @@ -334,7 +334,7 @@ static void aesce_setkey_enc(unsigned char *rk, * - Section 5, Nr = Nk + 6 * - Section 5.2, the length of round keys is Nb*(Nr+1) */ - const uint32_t key_len_in_words = key_bit_length / 32; /* Nk */ + const size_t key_len_in_words = key_bit_length / 32; /* Nk */ const size_t round_key_len_in_words = 4; /* Nb */ const size_t rounds_needed = key_len_in_words + 6; /* Nr */ const size_t round_keys_len_in_words = diff --git a/library/lms.c b/library/lms.c index 08fe75300..8d3cae052 100644 --- a/library/lms.c +++ b/library/lms.c @@ -65,7 +65,8 @@ static int local_err_translation(psa_status_t status) #define H_TREE_HEIGHT_MAX 10 #define MERKLE_TREE_NODE_AM(type) ((size_t) 1 << (MBEDTLS_LMS_H_TREE_HEIGHT(type) + 1u)) #define MERKLE_TREE_LEAF_NODE_AM(type) ((size_t) 1 << MBEDTLS_LMS_H_TREE_HEIGHT(type)) -#define MERKLE_TREE_INTERNAL_NODE_AM(type) ((size_t) 1 << MBEDTLS_LMS_H_TREE_HEIGHT(type)) +#define MERKLE_TREE_INTERNAL_NODE_AM(type) ((unsigned int) \ + (1u << MBEDTLS_LMS_H_TREE_HEIGHT(type))) #define D_CONST_LEN (2) static const unsigned char D_LEAF_CONSTANT_BYTES[D_CONST_LEN] = { 0x82, 0x82 };