From d4a5d461de75b91e59fb691ae0699f6cffaa0fa5 Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Wed, 5 Apr 2023 18:19:01 +0200 Subject: [PATCH] library: add remaining changes for the new ECP_LIGHT symbol Signed-off-by: Valerio Setti --- include/mbedtls/oid.h | 4 ++-- include/psa/crypto_extra.h | 4 ++-- library/ecp_curves.c | 4 ++-- library/oid.c | 4 ++-- library/psa_crypto.c | 4 ++-- library/ssl_client.c | 4 ++-- library/ssl_misc.h | 4 ++-- library/ssl_tls.c | 4 ++-- library/x509_crt.c | 18 +++++++++--------- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/mbedtls/oid.h b/include/mbedtls/oid.h index a592e63c4f..a72f51c4f7 100644 --- a/include/mbedtls/oid.h +++ b/include/mbedtls/oid.h @@ -509,7 +509,7 @@ int mbedtls_oid_get_pk_alg(const mbedtls_asn1_buf *oid, mbedtls_pk_type_t *pk_al int mbedtls_oid_get_oid_by_pk_alg(mbedtls_pk_type_t pk_alg, const char **oid, size_t *olen); -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) /** * \brief Translate NamedCurve OID into an EC group identifier * @@ -531,7 +531,7 @@ int mbedtls_oid_get_ec_grp(const mbedtls_asn1_buf *oid, mbedtls_ecp_group_id *gr */ int mbedtls_oid_get_oid_by_ec_grp(mbedtls_ecp_group_id grp_id, const char **oid, size_t *olen); -#endif /* MBEDTLS_ECP_C */ +#endif /* MBEDTLS_ECP_LIGHT */ /** * \brief Translate SignatureAlgorithm OID into md_type and pk_type diff --git a/include/psa/crypto_extra.h b/include/psa/crypto_extra.h index 7ff90ebe3a..e8cecf7415 100644 --- a/include/psa/crypto_extra.h +++ b/include/psa/crypto_extra.h @@ -573,7 +573,7 @@ psa_status_t psa_get_key_domain_parameters( * @{ */ -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) #include /** Convert an ECC curve identifier from the Mbed TLS encoding to PSA. @@ -660,7 +660,7 @@ static inline psa_ecc_family_t mbedtls_ecc_group_to_psa(mbedtls_ecp_group_id grp mbedtls_ecp_group_id mbedtls_ecc_group_of_psa(psa_ecc_family_t curve, size_t bits, int bits_is_sloppy); -#endif /* MBEDTLS_ECP_C */ +#endif /* MBEDTLS_ECP_LIGHT */ /**@}*/ diff --git a/library/ecp_curves.c b/library/ecp_curves.c index 30ae79e277..5d72245551 100644 --- a/library/ecp_curves.c +++ b/library/ecp_curves.c @@ -19,7 +19,7 @@ #include "common.h" -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) #include "mbedtls/ecp.h" #include "mbedtls/platform_util.h" @@ -5837,4 +5837,4 @@ int mbedtls_ecp_modulus_setup(mbedtls_mpi_mod_modulus *N, } #endif /* MBEDTLS_TEST_HOOKS */ #endif /* !MBEDTLS_ECP_ALT */ -#endif /* MBEDTLS_ECP_C */ +#endif /* MBEDTLS_ECP_LIGHT */ diff --git a/library/oid.c b/library/oid.c index 622e793ed5..80cadcd536 100644 --- a/library/oid.c +++ b/library/oid.c @@ -531,7 +531,7 @@ FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_pk_alg, mbedtls_pk_type_t, pk_alg) -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) /* * For namedCurve (RFC 5480) */ @@ -621,7 +621,7 @@ FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_ec_grp, oid_ecp_grp, mbedtls_ecp_group_id, grp_id) -#endif /* MBEDTLS_ECP_C */ +#endif /* MBEDTLS_ECP_LIGHT */ #if defined(MBEDTLS_CIPHER_C) /* diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 9cccf53c3a..ec12a3f21a 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -378,7 +378,7 @@ static void psa_wipe_tag_output_buffer(uint8_t *output_buffer, psa_status_t stat /* Key management */ /****************************************************************/ -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) mbedtls_ecp_group_id mbedtls_ecc_group_of_psa(psa_ecc_family_t curve, size_t bits, int bits_is_sloppy) @@ -470,7 +470,7 @@ mbedtls_ecp_group_id mbedtls_ecc_group_of_psa(psa_ecc_family_t curve, (void) bits_is_sloppy; return MBEDTLS_ECP_DP_NONE; } -#endif /* defined(MBEDTLS_ECP_C) */ +#endif /* MBEDTLS_ECP_LIGHT */ psa_status_t psa_validate_unstructured_key_bit_size(psa_key_type_t type, size_t bits) diff --git a/library/ssl_client.c b/library/ssl_client.c index eb52e70cf2..e84c28a1a6 100644 --- a/library/ssl_client.c +++ b/library/ssl_client.c @@ -257,7 +257,7 @@ static int ssl_write_supported_groups_ext(mbedtls_ssl_context *ssl, for (; *group_list != 0; group_list++) { MBEDTLS_SSL_DEBUG_MSG(1, ("got supported group(%04x)", *group_list)); -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) if ((mbedtls_ssl_conf_is_tls13_enabled(ssl->conf) && mbedtls_ssl_tls13_named_group_is_ecdhe(*group_list)) || (mbedtls_ssl_conf_is_tls12_enabled(ssl->conf) && @@ -273,7 +273,7 @@ static int ssl_write_supported_groups_ext(mbedtls_ssl_context *ssl, mbedtls_ssl_get_curve_name_from_tls_id(*group_list), *group_list)); } -#endif /* MBEDTLS_ECP_C */ +#endif /* MBEDTLS_ECP_LIGHT */ /* Add DHE groups here */ } diff --git a/library/ssl_misc.h b/library/ssl_misc.h index fccac85a47..d7c47e661c 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1553,10 +1553,10 @@ int mbedtls_ssl_set_calc_verify_md(mbedtls_ssl_context *ssl, int md); MBEDTLS_CHECK_RETURN_CRITICAL int mbedtls_ssl_check_curve_tls_id(const mbedtls_ssl_context *ssl, uint16_t tls_id); -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) MBEDTLS_CHECK_RETURN_CRITICAL int mbedtls_ssl_check_curve(const mbedtls_ssl_context *ssl, mbedtls_ecp_group_id grp_id); -#endif +#endif /* MBEDTLS_ECP_LIGHT */ /** * \brief Return PSA EC info for the specified TLS ID. diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 5ee80373eb..755a5a742b 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5555,7 +5555,7 @@ int mbedtls_ssl_check_curve_tls_id(const mbedtls_ssl_context *ssl, uint16_t tls_ return -1; } -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) /* * Same as mbedtls_ssl_check_curve_tls_id() but with a mbedtls_ecp_group_id. */ @@ -5569,7 +5569,7 @@ int mbedtls_ssl_check_curve(const mbedtls_ssl_context *ssl, mbedtls_ecp_group_id return mbedtls_ssl_check_curve_tls_id(ssl, tls_id); } -#endif /* MBEDTLS_ECP_C */ +#endif /* MBEDTLS_ECP_LIGHT */ #if defined(MBEDTLS_DEBUG_C) #define EC_NAME(_name_) _name_ diff --git a/library/x509_crt.c b/library/x509_crt.c index cf62532f28..faf862364e 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -101,7 +101,7 @@ const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default = MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA384) | MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA512), 0xFFFFFFF, /* Any PK alg */ -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) /* Curves at or above 128-bit security level. Note that this selection * should be aligned with ssl_preset_default_curves in ssl_tls.c. */ MBEDTLS_X509_ID_FLAG(MBEDTLS_ECP_DP_SECP256R1) | @@ -111,9 +111,9 @@ const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default = MBEDTLS_X509_ID_FLAG(MBEDTLS_ECP_DP_BP384R1) | MBEDTLS_X509_ID_FLAG(MBEDTLS_ECP_DP_BP512R1) | 0, -#else +#else /* MBEDTLS_ECP_LIGHT */ 0, -#endif +#endif /* MBEDTLS_ECP_LIGHT */ 2048, }; @@ -152,13 +152,13 @@ const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb = /* Only ECDSA */ MBEDTLS_X509_ID_FLAG(MBEDTLS_PK_ECDSA) | MBEDTLS_X509_ID_FLAG(MBEDTLS_PK_ECKEY), -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) /* Only NIST P-256 and P-384 */ MBEDTLS_X509_ID_FLAG(MBEDTLS_ECP_DP_SECP256R1) | MBEDTLS_X509_ID_FLAG(MBEDTLS_ECP_DP_SECP384R1), -#else +#else /* MBEDTLS_ECP_LIGHT */ 0, -#endif +#endif /* MBEDTLS_ECP_LIGHT */ 0, }; @@ -226,9 +226,9 @@ static int x509_profile_check_key(const mbedtls_x509_crt_profile *profile, return -1; } -#endif +#endif /* MBEDTLS_RSA_C */ -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_LIGHT) if (pk_alg == MBEDTLS_PK_ECDSA || pk_alg == MBEDTLS_PK_ECKEY || pk_alg == MBEDTLS_PK_ECKEY_DH) { @@ -244,7 +244,7 @@ static int x509_profile_check_key(const mbedtls_x509_crt_profile *profile, return -1; } -#endif +#endif /* MBEDTLS_ECP_LIGHT */ return -1; }