From 0c23fc39c3425c945f472b21b682c95e90bafbb0 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 23 Mar 2022 12:20:01 +0800 Subject: [PATCH] fix various guards issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 18 ++++++------------ library/ssl_tls13_generic.c | 7 +++++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 0caaa28e5..7fbf9f81c 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -2055,31 +2055,25 @@ static inline int mbedtls_ssl_sig_alg_is_supported( MBEDTLS_ECDSA_C */ #if defined(MBEDTLS_SHA256_C) && \ - defined(MBEDTLS_PKCS1_V21) && \ - defined(MBEDTLS_RSA_C) + defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA256: break; #endif /* MBEDTLS_SHA256_C && \ - MBEDTLS_PKCS1_V21 && \ - MBEDTLS_RSA_C */ + MBEDTLS_X509_RSASSA_PSS_SUPPORT */ #if defined(MBEDTLS_SHA384_C) && \ - defined(MBEDTLS_PKCS1_V21) && \ - defined(MBEDTLS_RSA_C) + defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA384: break; #endif /* MBEDTLS_SHA384_C && \ - MBEDTLS_PKCS1_V21 && \ - MBEDTLS_RSA_C */ + MBEDTLS_X509_RSASSA_PSS_SUPPORT */ #if defined(MBEDTLS_SHA512_C) && \ - defined(MBEDTLS_PKCS1_V21) && \ - defined(MBEDTLS_RSA_C) + defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA512: break; #endif /* MBEDTLS_SHA512_C && \ - MBEDTLS_PKCS1_V21 && \ - MBEDTLS_RSA_C */ + MBEDTLS_X509_RSASSA_PSS_SUPPORT */ #if defined(MBEDTLS_SHA256_C) && \ defined(MBEDTLS_PKCS1_V15) && \ diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index d1dcaed4d..e71456e1a 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -338,6 +338,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, /* We currently only support ECDSA-based signatures */ switch( algorithm ) { +#if defined(MBEDTLS_ECDSA_C) case MBEDTLS_TLS1_3_SIG_ECDSA_SECP256R1_SHA256: md_alg = MBEDTLS_MD_SHA256; sig_alg = MBEDTLS_PK_ECDSA; @@ -350,7 +351,9 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, md_alg = MBEDTLS_MD_SHA512; sig_alg = MBEDTLS_PK_ECDSA; break; -#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_PKCS1_V21) +#endif /* MBEDTLS_ECDSA_C */ + +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) #if defined(MBEDTLS_SHA256_C) case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA256: md_alg = MBEDTLS_MD_SHA256; @@ -371,7 +374,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, sig_alg = MBEDTLS_PK_RSASSA_PSS; break; #endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_RSA_C && MBEDTLS_PKCS1_V21 */ +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ default: MBEDTLS_SSL_DEBUG_MSG( 1, ( "Certificate Verify: Unknown signature algorithm." ) ); goto error;