From 53585eeb1765ee61ae28fa548f663b19bb40b841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 25 Jun 2015 08:52:25 +0200 Subject: [PATCH] Remove test DHM params from certs.c certs.c belongs to the X.509 library, while DHM belongs to the crypto lib. --- ChangeLog | 1 + include/mbedtls/certs.h | 5 ----- library/certs.c | 10 ---------- library/dhm.c | 21 +++++++++++---------- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40b2d26f9..2ca6d636a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -105,6 +105,7 @@ Removals (use generic functions from md.h) * Removed mbedtls_timing_msleep(). Use mbedtls_net_usleep() or a custom waiting function. + * Removed test DHM parameters from the test certs module. * Removed the PBKDF2 module (use PKCS5). * Removed POLARSSL_ERROR_STRERROR_BC (use mbedtls_strerror()). * Removed compat-1.2.h (helper for migrating from 1.2 to 1.3). diff --git a/include/mbedtls/certs.h b/include/mbedtls/certs.h index ee4d3a6a4..d0aa555c9 100644 --- a/include/mbedtls/certs.h +++ b/include/mbedtls/certs.h @@ -93,11 +93,6 @@ extern const char mbedtls_test_cli_key_rsa[]; extern const size_t mbedtls_test_cli_key_rsa_len; #endif -#if defined(MBEDTLS_DHM_C) -extern const char mbedtls_test_dhm_params[]; -extern const size_t mbedtls_test_dhm_params_len; -#endif - #ifdef __cplusplus } #endif diff --git a/library/certs.c b/library/certs.c index 012e47217..2dd7eba6a 100644 --- a/library/certs.c +++ b/library/certs.c @@ -291,16 +291,6 @@ const size_t mbedtls_test_cli_key_rsa_len = sizeof( mbedtls_test_cli_key_rsa ); #define TEST_CA_CRT_RSA #endif /* MBEDTLS_RSA_C */ -#if defined(MBEDTLS_DHM_C) -const char mbedtls_test_dhm_params[] = -"-----BEGIN DH PARAMETERS-----\r\n" -"MIGHAoGBAJ419DBEOgmQTzo5qXl5fQcN9TN455wkOL7052HzxxRVMyhYmwQcgJvh\r\n" -"1sa18fyfR9OiVEMYglOpkqVoGLN7qd5aQNNi5W7/C+VBdHTBJcGZJyyP5B3qcz32\r\n" -"9mLJKudlVudV0Qxk5qUJaPZ/xupz0NyoVpviuiBOI1gNi8ovSXWzAgEC\r\n" -"-----END DH PARAMETERS-----\r\n"; -const size_t mbedtls_test_dhm_params_len = sizeof( mbedtls_test_dhm_params ); -#endif - #if defined(MBEDTLS_PEM_PARSE_C) /* Concatenation of all available CA certificates */ const char mbedtls_test_cas_pem[] = TEST_CA_CRT_RSA TEST_CA_CRT_EC; diff --git a/library/dhm.c b/library/dhm.c index 979fd07fe..ac6261fbe 100644 --- a/library/dhm.c +++ b/library/dhm.c @@ -578,14 +578,20 @@ int mbedtls_dhm_parse_dhmfile( mbedtls_dhm_context *dhm, const char *path ) #if defined(MBEDTLS_SELF_TEST) -#include "mbedtls/certs.h" +static const char mbedtls_test_dhm_params[] = +"-----BEGIN DH PARAMETERS-----\r\n" +"MIGHAoGBAJ419DBEOgmQTzo5qXl5fQcN9TN455wkOL7052HzxxRVMyhYmwQcgJvh\r\n" +"1sa18fyfR9OiVEMYglOpkqVoGLN7qd5aQNNi5W7/C+VBdHTBJcGZJyyP5B3qcz32\r\n" +"9mLJKudlVudV0Qxk5qUJaPZ/xupz0NyoVpviuiBOI1gNi8ovSXWzAgEC\r\n" +"-----END DH PARAMETERS-----\r\n"; + +static const size_t mbedtls_test_dhm_params_len = sizeof( mbedtls_test_dhm_params ); /* * Checkup routine */ int mbedtls_dhm_self_test( int verbose ) { -#if defined(MBEDTLS_CERTS_C) int ret; mbedtls_dhm_context dhm; @@ -594,8 +600,9 @@ int mbedtls_dhm_self_test( int verbose ) if( verbose != 0 ) mbedtls_printf( " DHM parameter load: " ); - if( ( ret = mbedtls_dhm_parse_dhm( &dhm, (const unsigned char *) mbedtls_test_dhm_params, - mbedtls_test_dhm_params_len ) ) != 0 ) + if( ( ret = mbedtls_dhm_parse_dhm( &dhm, + (const unsigned char *) mbedtls_test_dhm_params, + mbedtls_test_dhm_params_len ) ) != 0 ) { if( verbose != 0 ) mbedtls_printf( "failed\n" ); @@ -611,12 +618,6 @@ exit: mbedtls_dhm_free( &dhm ); return( ret ); -#else - if( verbose != 0 ) - mbedtls_printf( " DHM parameter load: skipped\n" ); - - return( 0 ); -#endif /* MBEDTLS_CERTS_C */ } #endif /* MBEDTLS_SELF_TEST */