From 971988528dfcf3efe3c06be9cfd367456ca1f6bb Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 21 Jan 2022 16:16:01 +0800 Subject: [PATCH] fix coding style issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 85 ++++++++++++++++++++++++---------------------- library/ssl_srv.c | 5 +-- 2 files changed, 48 insertions(+), 42 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 2be88d60b0..788fafdd92 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1871,30 +1871,35 @@ static inline int mbedtls_ssl_sig_alg_is_supported( switch( hash ) { - #if defined(MBEDTLS_MD5_C) +#if defined(MBEDTLS_MD5_C) case MBEDTLS_SSL_HASH_MD5: break; - #endif - #if defined(MBEDTLS_SHA1_C) +#endif + +#if defined(MBEDTLS_SHA1_C) case MBEDTLS_SSL_HASH_SHA1: break; - #endif - #if defined(MBEDTLS_SHA224_C) +#endif + +#if defined(MBEDTLS_SHA224_C) case MBEDTLS_SSL_HASH_SHA224: break; - #endif - #if defined(MBEDTLS_SHA256_C) +#endif + +#if defined(MBEDTLS_SHA256_C) case MBEDTLS_SSL_HASH_SHA256: break; - #endif - #if defined(MBEDTLS_SHA384_C) +#endif + +#if defined(MBEDTLS_SHA384_C) case MBEDTLS_SSL_HASH_SHA384: break; - #endif - #if defined(MBEDTLS_SHA512_C) +#endif + +#if defined(MBEDTLS_SHA512_C) case MBEDTLS_SSL_HASH_SHA512: break; - #endif +#endif default: return( 0 ); @@ -1902,15 +1907,15 @@ static inline int mbedtls_ssl_sig_alg_is_supported( switch( sig ) { - #if defined(MBEDTLS_RSA_C) +#if defined(MBEDTLS_RSA_C) case MBEDTLS_SSL_SIG_RSA: break; - #endif +#endif - #if defined(MBEDTLS_ECDSA_C) +#if defined(MBEDTLS_ECDSA_C) case MBEDTLS_SSL_SIG_ECDSA: break; - #endif +#endif default: return( 0 ); @@ -1925,44 +1930,44 @@ static inline int mbedtls_ssl_sig_alg_is_supported( { switch( sig_alg ) { - #if defined(MBEDTLS_SHA256_C) && \ - defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \ - defined(MBEDTLS_ECDSA_C) +#if defined(MBEDTLS_SHA256_C) && \ + defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \ + defined(MBEDTLS_ECDSA_C) case MBEDTLS_TLS1_3_SIG_ECDSA_SECP256R1_SHA256: break; - #endif /* MBEDTLS_SHA256_C && - MBEDTLS_ECP_DP_SECP256R1_ENABLED && - MBEDTLS_ECDSA_C */ +#endif /* MBEDTLS_SHA256_C && + MBEDTLS_ECP_DP_SECP256R1_ENABLED && + MBEDTLS_ECDSA_C */ - #if defined(MBEDTLS_SHA384_C) && \ - defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) && \ - defined(MBEDTLS_ECDSA_C) +#if defined(MBEDTLS_SHA384_C) && \ + defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) && \ + defined(MBEDTLS_ECDSA_C) case MBEDTLS_TLS1_3_SIG_ECDSA_SECP384R1_SHA384: break; - #endif /* MBEDTLS_SHA384_C && - MBEDTLS_ECP_DP_SECP384R1_ENABLED && - MBEDTLS_ECDSA_C */ +#endif /* MBEDTLS_SHA384_C && + MBEDTLS_ECP_DP_SECP384R1_ENABLED && + MBEDTLS_ECDSA_C */ - #if defined(MBEDTLS_SHA512_C) && \ - defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) && \ - defined(MBEDTLS_ECDSA_C) +#if defined(MBEDTLS_SHA512_C) && \ + defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) && \ + defined(MBEDTLS_ECDSA_C) case MBEDTLS_TLS1_3_SIG_ECDSA_SECP521R1_SHA512: break; - #endif /* MBEDTLS_SHA512_C && - MBEDTLS_ECP_DP_SECP521R1_ENABLED && - MBEDTLS_ECDSA_C */ +#endif /* MBEDTLS_SHA512_C && + MBEDTLS_ECP_DP_SECP521R1_ENABLED && + MBEDTLS_ECDSA_C */ - #if defined(MBEDTLS_SHA256_C) && \ - defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) +#if defined(MBEDTLS_SHA256_C) && \ + defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA256: break; - #endif /* MBEDTLS_SHA256_C && - MBEDTLS_X509_RSASSA_PSS_SUPPORT */ +#endif /* MBEDTLS_SHA256_C && + MBEDTLS_X509_RSASSA_PSS_SUPPORT */ - #if defined(MBEDTLS_SHA256_C) && defined(MBEDTLS_RSA_C) +#if defined(MBEDTLS_SHA256_C) && defined(MBEDTLS_RSA_C) case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA256: break; - #endif /* MBEDTLS_SHA256_C && MBEDTLS_RSA_C*/ +#endif /* MBEDTLS_SHA256_C && MBEDTLS_RSA_C*/ default: return( 0 ); diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 5cd9d71612..f189e1d606 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1805,13 +1805,14 @@ read_record_header: { uint16_t sig_algs[] = { MBEDTLS_SSL_SIG_ALG(MBEDTLS_SSL_HASH_SHA1) }; mbedtls_md_type_t md_default = MBEDTLS_MD_NONE; - for( i = 0; i < sizeof(sig_algs)/sizeof(sig_algs[0]) ; i++ ) + for( i = 0; i < sizeof( sig_algs ) / sizeof( sig_algs[0] ) ; i++ ) { if( mbedtls_ssl_sig_alg_is_offered( ssl, sig_algs[ i ] ) ) md_default = MBEDTLS_MD_SHA1; } - mbedtls_ssl_sig_hash_set_const_hash( &ssl->handshake->hash_algs, md_default ); + mbedtls_ssl_sig_hash_set_const_hash( &ssl->handshake->hash_algs, + md_default ); } #endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&