From 7ca1318256894226fda7bc5dc72707a86c06df74 Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Fri, 27 Jan 2023 13:22:42 +0100 Subject: [PATCH] pk: add new symbol for generic ECDSA capability Signed-off-by: Valerio Setti --- library/pk.c | 2 +- library/pk_wrap.c | 12 ++++++------ library/pk_wrap.h | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/library/pk.c b/library/pk.c index 4efe479da0..ed3ca41cc7 100644 --- a/library/pk.c +++ b/library/pk.c @@ -114,7 +114,7 @@ const mbedtls_pk_info_t *mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type) case MBEDTLS_PK_ECKEY_DH: return &mbedtls_eckeydh_info; #endif -#if defined(MBEDTLS_PK_CAN_ECDSA_SIGN) || defined(MBEDTLS_PK_CAN_ECDSA_VERIFY) +#if defined(MBEDTLS_PK_CAN_ECDSA_SOME) case MBEDTLS_PK_ECDSA: return &mbedtls_ecdsa_info; #endif diff --git a/library/pk_wrap.c b/library/pk_wrap.c index 3cea351b3e..2415b1614b 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -620,7 +620,7 @@ static size_t eckey_get_bitlen(const void *ctx) return ((mbedtls_ecp_keypair *) ctx)->grp.pbits; } -#if defined(MBEDTLS_PK_CAN_ECDSA_SIGN) || defined(MBEDTLS_PK_CAN_ECDSA_VERIFY) +#if defined(MBEDTLS_PK_CAN_ECDSA_SOME) /* Forward declarations */ static int ecdsa_verify_wrap(void *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, @@ -805,17 +805,17 @@ const mbedtls_pk_info_t mbedtls_eckey_info = { "EC", eckey_get_bitlen, eckey_can_do, -#if defined(MBEDTLS_PK_CAN_ECDSA_SIGN) || defined(MBEDTLS_PK_CAN_ECDSA_VERIFY) +#if defined(MBEDTLS_PK_CAN_ECDSA_SOME) eckey_verify_wrap, eckey_sign_wrap, #if defined(MBEDTLS_ECP_RESTARTABLE) eckey_verify_rs_wrap, eckey_sign_rs_wrap, #endif -#else /* MBEDTLS_PK_CAN_ECDSA_SIGN || MBEDTLS_PK_CAN_ECDSA_VERIFY */ +#else /* MBEDTLS_PK_CAN_ECDSA_SOME */ NULL, NULL, -#endif /* MBEDTLS_PK_CAN_ECDSA_SIGN || MBEDTLS_PK_CAN_ECDSA_VERIFY */ +#endif /* MBEDTLS_PK_CAN_ECDSA_SOME */ NULL, NULL, eckey_check_pair, @@ -861,7 +861,7 @@ const mbedtls_pk_info_t mbedtls_eckeydh_info = { }; #endif /* MBEDTLS_ECP_C */ -#if defined(MBEDTLS_PK_CAN_ECDSA_SIGN) || defined(MBEDTLS_PK_CAN_ECDSA_VERIFY) +#if defined(MBEDTLS_PK_CAN_ECDSA_SOME) static int ecdsa_can_do(mbedtls_pk_type_t type) { return type == MBEDTLS_PK_ECDSA; @@ -1345,7 +1345,7 @@ const mbedtls_pk_info_t mbedtls_ecdsa_info = { #endif eckey_debug, /* Compatible key structures */ }; -#endif /* MBEDTLS_ECDSA_C */ +#endif /* MBEDTLS_PK_CAN_ECDSA_SOME */ #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) /* diff --git a/library/pk_wrap.h b/library/pk_wrap.h index f15359d221..84e300926c 100644 --- a/library/pk_wrap.h +++ b/library/pk_wrap.h @@ -56,6 +56,10 @@ struct mbedtls_pk_info_t { int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); +#if defined(MBEDTLS_PK_CAN_ECDSA_VERIFY) || defined(MBEDTLS_PK_CAN_ECDSA_SIGN) +#define MBEDTLS_PK_CAN_ECDSA_SOME +#endif + #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) /** Verify signature (restartable) */ int (*verify_rs_func)(void *ctx, mbedtls_md_type_t md_alg, @@ -125,7 +129,7 @@ extern const mbedtls_pk_info_t mbedtls_eckey_info; extern const mbedtls_pk_info_t mbedtls_eckeydh_info; #endif -#if defined(MBEDTLS_PK_CAN_ECDSA_SIGN) || defined(MBEDTLS_PK_CAN_ECDSA_VERIFY) +#if defined(MBEDTLS_PK_CAN_ECDSA_SOME) extern const mbedtls_pk_info_t mbedtls_ecdsa_info; #endif