From cd3c8451578d7a6ca14b7db92670b2f2750ea4dc Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 9 May 2017 14:57:45 +0200 Subject: [PATCH] Allow SHA-1 in SSL renegotiation tests In the TLS test client, allow SHA-1 as a signature hash algorithm. Without this, the renegotation tests failed. A previous commit had allowed SHA-1 via the certificate profile but that only applied before the initial negotiation which includes the signature_algorithms extension. --- library/ssl_cli.c | 4 ++-- programs/ssl/ssl_client2.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 7da91e62a..fcc7f5ff1 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -2134,8 +2134,8 @@ static int ssl_parse_signature_algorithm( mbedtls_ssl_context *ssl, */ if( mbedtls_ssl_check_sig_hash( ssl, *md_alg ) != 0 ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "server used HashAlgorithm " - "that was not offered" ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "server used HashAlgorithm %d that was not offered", + *(p)[0] ) ); return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); } diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index bdaae3130..c8eb14553 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -395,6 +395,22 @@ static int my_verify( void *data, mbedtls_x509_crt *crt, int depth, uint32_t *fl return( 0 ); } + +static int ssl_sig_hashes_for_test[] = { +#if defined(MBEDTLS_SHA512_C) + MBEDTLS_MD_SHA512, + MBEDTLS_MD_SHA384, +#endif +#if defined(MBEDTLS_SHA256_C) + MBEDTLS_MD_SHA256, + MBEDTLS_MD_SHA224, +#endif +#if defined(MBEDTLS_SHA1_C) + /* Allow SHA-1 as we use it extensively in tests. */ + MBEDTLS_MD_SHA1, +#endif + MBEDTLS_MD_NONE +}; #endif /* MBEDTLS_X509_CRT_PARSE_C */ int main( int argc, char *argv[] ) @@ -1096,6 +1112,7 @@ int main( int argc, char *argv[] ) rely on it heavily. */ crt_profile_for_test.allowed_mds |= MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA1 ); mbedtls_ssl_conf_cert_profile( &conf, &crt_profile_for_test ); + mbedtls_ssl_conf_sig_hashes( &conf, ssl_sig_hashes_for_test ); if( opt.debug_level > 0 ) mbedtls_ssl_conf_verify( &conf, my_verify, NULL );