From 8b52b88b6d5ce7a6bcaf73b2861a9871b9eea2b2 Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Thu, 13 Jul 2023 13:12:40 +0100 Subject: [PATCH 1/9] Add type casts in ssl library Signed-off-by: Agathiyan Bragadeesh --- library/ssl_ciphersuites.c | 2 +- library/ssl_msg.c | 15 ++++++++++----- library/ssl_tls.c | 16 ++++++++-------- library/ssl_tls12_client.c | 6 ++++-- library/ssl_tls12_server.c | 15 ++++++++++----- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/library/ssl_ciphersuites.c b/library/ssl_ciphersuites.c index 793ec6a1c8..b833472224 100644 --- a/library/ssl_ciphersuites.c +++ b/library/ssl_ciphersuites.c @@ -1931,7 +1931,7 @@ size_t mbedtls_ssl_ciphersuite_get_cipher_key_bitlen(const mbedtls_ssl_ciphersui return key_bits; #else const mbedtls_cipher_info_t * const cipher_info = - mbedtls_cipher_info_from_type(info->cipher); + mbedtls_cipher_info_from_type((mbedtls_cipher_type_t) info->cipher); return mbedtls_cipher_info_get_key_bitlen(cipher_info); #endif /* MBEDTLS_USE_PSA_CRYPTO */ diff --git a/library/ssl_msg.c b/library/ssl_msg.c index e9050230b3..be197366be 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -3602,8 +3602,9 @@ static int ssl_parse_record_header(mbedtls_ssl_context const *ssl, */ rec->ver[0] = buf[rec_hdr_version_offset + 0]; rec->ver[1] = buf[rec_hdr_version_offset + 1]; - tls_version = mbedtls_ssl_read_version(buf + rec_hdr_version_offset, - ssl->conf->transport); + tls_version = (mbedtls_ssl_protocol_version) mbedtls_ssl_read_version( + buf + rec_hdr_version_offset, + ssl->conf->transport); if (tls_version > ssl->conf->max_tls_version) { MBEDTLS_SSL_DEBUG_MSG(1, ("TLS version mismatch: got %u, expected max %u", @@ -5849,15 +5850,19 @@ static void ssl_buffering_free_slot(mbedtls_ssl_context *ssl, void mbedtls_ssl_write_version(unsigned char version[2], int transport, mbedtls_ssl_protocol_version tls_version) { + uint16_t tls_version_formatted; #if defined(MBEDTLS_SSL_PROTO_DTLS) if (transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { - tls_version = + tls_version_formatted = ~(tls_version - (tls_version == 0x0302 ? 0x0202 : 0x0201)); - } + } else #else ((void) transport); #endif - MBEDTLS_PUT_UINT16_BE(tls_version, version, 0); + { + tls_version_formatted = (uint16_t) tls_version; + } + MBEDTLS_PUT_UINT16_BE(tls_version_formatted, version, 0); } uint16_t mbedtls_ssl_read_version(const unsigned char version[2], diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 8d90075a41..86f8ac83b2 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -2436,7 +2436,7 @@ mbedtls_ssl_mode_t mbedtls_ssl_get_mode_from_ciphersuite( } #else const mbedtls_cipher_info_t *cipher = - mbedtls_cipher_info_from_type(suite->cipher); + mbedtls_cipher_info_from_type((mbedtls_cipher_type_t) suite->cipher); if (cipher != NULL) { base_mode = mbedtls_ssl_get_base_mode( @@ -3116,12 +3116,12 @@ void mbedtls_ssl_get_dtls_srtp_negotiation_result(const mbedtls_ssl_context *ssl #if !defined(MBEDTLS_DEPRECATED_REMOVED) void mbedtls_ssl_conf_max_version(mbedtls_ssl_config *conf, int major, int minor) { - conf->max_tls_version = (major << 8) | minor; + conf->max_tls_version = (mbedtls_ssl_protocol_version) ((major << 8) | minor); } void mbedtls_ssl_conf_min_version(mbedtls_ssl_config *conf, int major, int minor) { - conf->min_tls_version = (major << 8) | minor; + conf->min_tls_version = (mbedtls_ssl_protocol_version) ((major << 8) | minor); } #endif /* MBEDTLS_DEPRECATED_REMOVED */ @@ -3749,7 +3749,7 @@ static int ssl_session_load(mbedtls_ssl_session *session, if (1 > (size_t) (end - p)) { return MBEDTLS_ERR_SSL_BAD_INPUT_DATA; } - session->tls_version = 0x0300 | *p++; + session->tls_version = (mbedtls_ssl_protocol_version) (0x0300 | *p++); /* Dispatch according to TLS version. */ remaining_len = (end - p); @@ -3852,7 +3852,7 @@ int mbedtls_ssl_handshake_step(mbedtls_ssl_context *ssl) #if defined(MBEDTLS_SSL_CLI_C) if (ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT) { MBEDTLS_SSL_DEBUG_MSG(2, ("client state: %s", - mbedtls_ssl_states_str(ssl->state))); + mbedtls_ssl_states_str((mbedtls_ssl_states) ssl->state))); switch (ssl->state) { case MBEDTLS_SSL_HELLO_REQUEST: @@ -6534,7 +6534,7 @@ int mbedtls_ssl_derive_keys(mbedtls_ssl_context *ssl) /* Set PRF, calc_verify and calc_finished function pointers */ ret = ssl_set_handshake_prfs(ssl->handshake, - ciphersuite_info->mac); + (mbedtls_md_type_t) ciphersuite_info->mac); if (ret != 0) { MBEDTLS_SSL_DEBUG_RET(1, "ssl_set_handshake_prfs", ret); return ret; @@ -8210,7 +8210,7 @@ static int ssl_tls12_populate_transform(mbedtls_ssl_transform *transform, goto end; } #else - cipher_info = mbedtls_cipher_info_from_type(ciphersuite_info->cipher); + cipher_info = mbedtls_cipher_info_from_type((mbedtls_cipher_type_t) ciphersuite_info->cipher); if (cipher_info == NULL) { MBEDTLS_SSL_DEBUG_MSG(1, ("cipher info for %u not found", ciphersuite_info->cipher)); @@ -8226,7 +8226,7 @@ static int ssl_tls12_populate_transform(mbedtls_ssl_transform *transform, return MBEDTLS_ERR_SSL_BAD_INPUT_DATA; } #else - md_info = mbedtls_md_info_from_type(ciphersuite_info->mac); + md_info = mbedtls_md_info_from_type((mbedtls_md_type_t) ciphersuite_info->mac); if (md_info == NULL) { MBEDTLS_SSL_DEBUG_MSG(1, ("mbedtls_md info for %u not found", (unsigned) ciphersuite_info->mac)); diff --git a/library/ssl_tls12_client.c b/library/ssl_tls12_client.c index e4f38212fa..49a17a933f 100644 --- a/library/ssl_tls12_client.c +++ b/library/ssl_tls12_client.c @@ -1271,7 +1271,8 @@ static int ssl_parse_server_hello(mbedtls_ssl_context *ssl) buf += mbedtls_ssl_hs_hdr_len(ssl); MBEDTLS_SSL_DEBUG_BUF(3, "server hello, version", buf, 2); - ssl->tls_version = mbedtls_ssl_read_version(buf, ssl->conf->transport); + ssl->tls_version = (mbedtls_ssl_protocol_version) mbedtls_ssl_read_version(buf, + ssl->conf->transport); ssl->session_negotiate->tls_version = ssl->tls_version; if (ssl->tls_version < ssl->conf->min_tls_version || @@ -3141,7 +3142,8 @@ ecdh_calc_secret: #if !defined(MBEDTLS_USE_PSA_CRYPTO) if ((ret = mbedtls_ssl_psk_derive_premaster(ssl, - ciphersuite_info->key_exchange)) != 0) { + (mbedtls_key_exchange_type_t) ciphersuite_info-> + key_exchange)) != 0) { MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_psk_derive_premaster", ret); return ret; diff --git a/library/ssl_tls12_server.c b/library/ssl_tls12_server.c index bebc5d9049..5983ddeea7 100644 --- a/library/ssl_tls12_server.c +++ b/library/ssl_tls12_server.c @@ -1166,7 +1166,8 @@ read_record_header: */ MBEDTLS_SSL_DEBUG_BUF(3, "client hello, version", buf, 2); - ssl->tls_version = mbedtls_ssl_read_version(buf, ssl->conf->transport); + ssl->tls_version = (mbedtls_ssl_protocol_version) mbedtls_ssl_read_version(buf, + ssl->conf->transport); ssl->session_negotiate->tls_version = ssl->tls_version; if (ssl->tls_version != MBEDTLS_SSL_VERSION_TLS1_2) { @@ -3798,7 +3799,8 @@ static int ssl_parse_client_key_exchange(mbedtls_ssl_context *ssl) #if !defined(MBEDTLS_USE_PSA_CRYPTO) if ((ret = mbedtls_ssl_psk_derive_premaster(ssl, - ciphersuite_info->key_exchange)) != 0) { + (mbedtls_key_exchange_type_t) ciphersuite_info-> + key_exchange)) != 0) { MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_psk_derive_premaster", ret); return ret; } @@ -3830,7 +3832,8 @@ static int ssl_parse_client_key_exchange(mbedtls_ssl_context *ssl) #if !defined(MBEDTLS_USE_PSA_CRYPTO) if ((ret = mbedtls_ssl_psk_derive_premaster(ssl, - ciphersuite_info->key_exchange)) != 0) { + (mbedtls_key_exchange_type_t) ciphersuite_info-> + key_exchange)) != 0) { MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_psk_derive_premaster", ret); return ret; } @@ -3871,7 +3874,8 @@ static int ssl_parse_client_key_exchange(mbedtls_ssl_context *ssl) MBEDTLS_SSL_DEBUG_MPI(3, "DHM: K ", &ssl->handshake->dhm_ctx.K); #else if ((ret = mbedtls_ssl_psk_derive_premaster(ssl, - ciphersuite_info->key_exchange)) != 0) { + (mbedtls_key_exchange_type_t) ciphersuite_info-> + key_exchange)) != 0) { MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_psk_derive_premaster", ret); return ret; } @@ -3971,7 +3975,8 @@ static int ssl_parse_client_key_exchange(mbedtls_ssl_context *ssl) MBEDTLS_DEBUG_ECDH_QP); if ((ret = mbedtls_ssl_psk_derive_premaster(ssl, - ciphersuite_info->key_exchange)) != 0) { + (mbedtls_key_exchange_type_t) ciphersuite_info-> + key_exchange)) != 0) { MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_psk_derive_premaster", ret); return ret; } From be3ad4aed34a51f52e9e0860e917461590acf004 Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Fri, 14 Jul 2023 17:29:43 +0100 Subject: [PATCH 2/9] Add type casts in psa_exercise_key Signed-off-by: Agathiyan Bragadeesh --- tests/src/psa_exercise_key.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/src/psa_exercise_key.c b/tests/src/psa_exercise_key.c index 7f93496e7c..d9228f4423 100644 --- a/tests/src/psa_exercise_key.c +++ b/tests/src/psa_exercise_key.c @@ -692,7 +692,7 @@ int mbedtls_test_psa_exported_key_sanity_check( TEST_EQUAL(mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED), 0); - TEST_EQUAL(len, end - p); + TEST_EQUAL(len, (uintptr_t) end - (uintptr_t) p); if (!mbedtls_test_asn1_skip_integer(&p, end, 0, 0, 0)) { goto exit; } @@ -722,7 +722,7 @@ int mbedtls_test_psa_exported_key_sanity_check( if (!mbedtls_test_asn1_skip_integer(&p, end, 1, bits / 2 + 1, 0)) { goto exit; } - TEST_EQUAL(p - end, 0); + TEST_EQUAL((uintptr_t) p - (uintptr_t) end, 0); TEST_ASSERT(exported_length <= PSA_EXPORT_KEY_PAIR_MAX_SIZE); } else @@ -748,14 +748,14 @@ int mbedtls_test_psa_exported_key_sanity_check( MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED), 0); - TEST_EQUAL(len, end - p); + TEST_EQUAL(len, (uintptr_t) end - (uintptr_t) p); if (!mbedtls_test_asn1_skip_integer(&p, end, bits, bits, 1)) { goto exit; } if (!mbedtls_test_asn1_skip_integer(&p, end, 2, bits, 1)) { goto exit; } - TEST_EQUAL(p - end, 0); + TEST_EQUAL((uintptr_t) p - (uintptr_t) end, 0); TEST_ASSERT(exported_length <= From 01ed84a1f3a4e21e97cf3469b127376bfeb08166 Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Thu, 13 Jul 2023 11:42:41 +0100 Subject: [PATCH 3/9] Add type casts in rsa.c Signed-off-by: Agathiyan Bragadeesh --- library/rsa.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/rsa.c b/library/rsa.c index 8126ae9cf0..6a74befe9e 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -1266,13 +1266,13 @@ int mbedtls_rsa_rsaes_oaep_encrypt(mbedtls_rsa_context *ctx, /* maskedDB: Apply dbMask to DB */ if ((ret = mgf_mask(output + hlen + 1, olen - hlen - 1, output + 1, hlen, - ctx->hash_id)) != 0) { + (mbedtls_md_type_t) ctx->hash_id)) != 0) { return ret; } /* maskedSeed: Apply seedMask to seed */ if ((ret = mgf_mask(output + 1, hlen, output + hlen + 1, olen - hlen - 1, - ctx->hash_id)) != 0) { + (mbedtls_md_type_t) ctx->hash_id)) != 0) { return ret; } @@ -1420,10 +1420,10 @@ int mbedtls_rsa_rsaes_oaep_decrypt(mbedtls_rsa_context *ctx, */ /* seed: Apply seedMask to maskedSeed */ if ((ret = mgf_mask(buf + 1, hlen, buf + hlen + 1, ilen - hlen - 1, - ctx->hash_id)) != 0 || + (mbedtls_md_type_t) ctx->hash_id)) != 0 || /* DB: Apply dbMask to maskedDB */ (ret = mgf_mask(buf + hlen + 1, ilen - hlen - 1, buf + 1, hlen, - ctx->hash_id)) != 0) { + (mbedtls_md_type_t) ctx->hash_id)) != 0) { goto cleanup; } @@ -1649,7 +1649,7 @@ static int rsa_rsassa_pss_sign(mbedtls_rsa_context *ctx, p += slen; /* Generate H = Hash( M' ) */ - ret = hash_mprime(hash, hashlen, salt, slen, p, ctx->hash_id); + ret = hash_mprime(hash, hashlen, salt, slen, p, (mbedtls_md_type_t) ctx->hash_id); if (ret != 0) { return ret; } @@ -1661,7 +1661,7 @@ static int rsa_rsassa_pss_sign(mbedtls_rsa_context *ctx, /* maskedDB: Apply dbMask to DB */ ret = mgf_mask(sig + offset, olen - hlen - 1 - offset, p, hlen, - ctx->hash_id); + (mbedtls_md_type_t) ctx->hash_id); if (ret != 0) { return ret; } From 2f017a8356c7e91c1bfb9f8bd551f84206faf00d Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Wed, 12 Jul 2023 11:21:54 +0100 Subject: [PATCH 4/9] Add enum casts in ssl_helpers.c Signed-off-by: Agathiyan Bragadeesh --- tests/src/test_helpers/ssl_helpers.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/src/test_helpers/ssl_helpers.c b/tests/src/test_helpers/ssl_helpers.c index e8bbc78d1e..12218634e7 100644 --- a/tests/src/test_helpers/ssl_helpers.c +++ b/tests/src/test_helpers/ssl_helpers.c @@ -1020,10 +1020,10 @@ static void set_ciphersuite(mbedtls_ssl_config *conf, const char *cipher, TEST_ASSERT(ciphersuite_info->max_tls_version >= conf->min_tls_version); if (conf->max_tls_version > ciphersuite_info->max_tls_version) { - conf->max_tls_version = ciphersuite_info->max_tls_version; + conf->max_tls_version = (mbedtls_ssl_protocol_version) ciphersuite_info->max_tls_version; } if (conf->min_tls_version < ciphersuite_info->min_tls_version) { - conf->min_tls_version = ciphersuite_info->min_tls_version; + conf->min_tls_version = (mbedtls_ssl_protocol_version) ciphersuite_info->min_tls_version; } mbedtls_ssl_conf_ciphersuites(conf, forced_ciphersuite); @@ -1140,7 +1140,7 @@ int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in, maclen = 0; /* Pick cipher */ - cipher_info = mbedtls_cipher_info_from_type(cipher_type); + cipher_info = mbedtls_cipher_info_from_type((mbedtls_cipher_type_t) cipher_type); CHK(cipher_info != NULL); CHK(cipher_info->iv_size <= 16); CHK(cipher_info->key_bitlen % 8 == 0); @@ -1198,10 +1198,10 @@ int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in, if (cipher_info->mode == MBEDTLS_MODE_CBC || cipher_info->mode == MBEDTLS_MODE_STREAM) { #if !defined(MBEDTLS_USE_PSA_CRYPTO) - mbedtls_md_info_t const *md_info = mbedtls_md_info_from_type(hash_id); + mbedtls_md_info_t const *md_info = mbedtls_md_info_from_type((mbedtls_md_type_t) hash_id); CHK(md_info != NULL); #endif - maclen = mbedtls_md_get_size_from_type(hash_id); + maclen = mbedtls_md_get_size_from_type((mbedtls_md_type_t) hash_id); CHK(maclen != 0); /* Pick hash keys */ CHK((md0 = mbedtls_calloc(1, maclen)) != NULL); From 10b6775aeb127a844ea676477ed768b978b6d051 Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Wed, 12 Jul 2023 11:19:17 +0100 Subject: [PATCH 5/9] Add enum type casts in lmots.c and lms.c The IAR compiler throws an error when trying to assign an int to an enum so these casts have been added. Signed-off-by: Agathiyan Bragadeesh --- library/lmots.c | 6 ++++-- library/lms.c | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/library/lmots.c b/library/lmots.c index 4ef2c5178e..e30511b0c1 100644 --- a/library/lmots.c +++ b/library/lmots.c @@ -438,8 +438,10 @@ int mbedtls_lmots_import_public_key(mbedtls_lmots_public_t *ctx, } ctx->params.type = - mbedtls_lms_network_bytes_to_unsigned_int(MBEDTLS_LMOTS_TYPE_LEN, - key + MBEDTLS_LMOTS_SIG_TYPE_OFFSET); + (mbedtls_lmots_algorithm_type_t) mbedtls_lms_network_bytes_to_unsigned_int( + MBEDTLS_LMOTS_TYPE_LEN, + key + + MBEDTLS_LMOTS_SIG_TYPE_OFFSET); if (key_len != MBEDTLS_LMOTS_PUBLIC_KEY_LEN(ctx->params.type)) { return MBEDTLS_ERR_LMS_BAD_INPUT_DATA; diff --git a/library/lms.c b/library/lms.c index 823ce09f89..0469a592bb 100644 --- a/library/lms.c +++ b/library/lms.c @@ -249,8 +249,10 @@ int mbedtls_lms_import_public_key(mbedtls_lms_public_t *ctx, mbedtls_lms_algorithm_type_t type; mbedtls_lmots_algorithm_type_t otstype; - type = mbedtls_lms_network_bytes_to_unsigned_int(MBEDTLS_LMS_TYPE_LEN, - key + PUBLIC_KEY_TYPE_OFFSET); + type = (mbedtls_lms_algorithm_type_t) mbedtls_lms_network_bytes_to_unsigned_int( + MBEDTLS_LMS_TYPE_LEN, + key + + PUBLIC_KEY_TYPE_OFFSET); if (type != MBEDTLS_LMS_SHA256_M32_H10) { return MBEDTLS_ERR_LMS_BAD_INPUT_DATA; } @@ -260,8 +262,10 @@ int mbedtls_lms_import_public_key(mbedtls_lms_public_t *ctx, return MBEDTLS_ERR_LMS_BAD_INPUT_DATA; } - otstype = mbedtls_lms_network_bytes_to_unsigned_int(MBEDTLS_LMOTS_TYPE_LEN, - key + PUBLIC_KEY_OTSTYPE_OFFSET); + otstype = (mbedtls_lmots_algorithm_type_t) mbedtls_lms_network_bytes_to_unsigned_int( + MBEDTLS_LMOTS_TYPE_LEN, + key + + PUBLIC_KEY_OTSTYPE_OFFSET); if (otstype != MBEDTLS_LMOTS_SHA256_N32_W8) { return MBEDTLS_ERR_LMS_BAD_INPUT_DATA; } From 387bfa5b84a3bafac56a57f2bc0396767556d099 Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Mon, 17 Jul 2023 17:01:33 +0100 Subject: [PATCH 6/9] Add cast in psa_crypto Signed-off-by: Agathiyan Bragadeesh --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 2b9c8a29ff..d8ccb8a5a5 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -7960,7 +7960,7 @@ static psa_crypto_driver_pake_step_t convert_jpake_computation_stage_to_driver_s } else { return PSA_JPAKE_STEP_INVALID; } - return key_share_step + stage->step - PSA_PAKE_STEP_KEY_SHARE; + return (psa_crypto_driver_pake_step_t) (key_share_step + stage->step - PSA_PAKE_STEP_KEY_SHARE); } #endif /* PSA_WANT_ALG_JPAKE */ From 2d310deace082ab51a9bad3b368bcb4c8989cfc6 Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Mon, 17 Jul 2023 18:27:03 +0100 Subject: [PATCH 7/9] Add cast in test macros.h Signed-off-by: Agathiyan Bragadeesh --- tests/include/test/macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/include/test/macros.h b/tests/include/test/macros.h index ae84ec2363..c61f4fde65 100644 --- a/tests/include/test/macros.h +++ b/tests/include/test/macros.h @@ -73,7 +73,7 @@ #define TEST_EQUAL(expr1, expr2) \ do { \ if (!mbedtls_test_equal( #expr1 " == " #expr2, __LINE__, __FILE__, \ - expr1, expr2)) \ + (unsigned long long) (expr1), (unsigned long long) (expr2))) \ goto exit; \ } while (0) From d298b76421f4a4ea4603db0fa82f9ea8d59af17d Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Tue, 25 Jul 2023 11:33:00 +0100 Subject: [PATCH 8/9] Remove redundant casts Signed-off-by: Agathiyan Bragadeesh --- tests/src/psa_exercise_key.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/psa_exercise_key.c b/tests/src/psa_exercise_key.c index d9228f4423..1ef26221bb 100644 --- a/tests/src/psa_exercise_key.c +++ b/tests/src/psa_exercise_key.c @@ -692,7 +692,7 @@ int mbedtls_test_psa_exported_key_sanity_check( TEST_EQUAL(mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED), 0); - TEST_EQUAL(len, (uintptr_t) end - (uintptr_t) p); + TEST_EQUAL(len, end - p); if (!mbedtls_test_asn1_skip_integer(&p, end, 0, 0, 0)) { goto exit; } @@ -722,7 +722,7 @@ int mbedtls_test_psa_exported_key_sanity_check( if (!mbedtls_test_asn1_skip_integer(&p, end, 1, bits / 2 + 1, 0)) { goto exit; } - TEST_EQUAL((uintptr_t) p - (uintptr_t) end, 0); + TEST_EQUAL(p - end, 0); TEST_ASSERT(exported_length <= PSA_EXPORT_KEY_PAIR_MAX_SIZE); } else From 93a859341b20aae2a2f2f1ad76f49c1a6481d157 Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Tue, 25 Jul 2023 12:28:59 +0100 Subject: [PATCH 9/9] Remove remaining redundant casts Signed-off-by: Agathiyan Bragadeesh --- tests/src/psa_exercise_key.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/psa_exercise_key.c b/tests/src/psa_exercise_key.c index 1ef26221bb..7f93496e7c 100644 --- a/tests/src/psa_exercise_key.c +++ b/tests/src/psa_exercise_key.c @@ -748,14 +748,14 @@ int mbedtls_test_psa_exported_key_sanity_check( MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED), 0); - TEST_EQUAL(len, (uintptr_t) end - (uintptr_t) p); + TEST_EQUAL(len, end - p); if (!mbedtls_test_asn1_skip_integer(&p, end, bits, bits, 1)) { goto exit; } if (!mbedtls_test_asn1_skip_integer(&p, end, 2, bits, 1)) { goto exit; } - TEST_EQUAL((uintptr_t) p - (uintptr_t) end, 0); + TEST_EQUAL(p - end, 0); TEST_ASSERT(exported_length <=