Fix bug in benchmark.c with DHM params

This commit is contained in:
Manuel Pégourié-Gonnard 2015-07-19 15:01:28 +02:00
parent e88b49323e
commit 4f3368e31e
2 changed files with 9 additions and 6 deletions

View File

@ -1,5 +1,10 @@
mbed TLS ChangeLog (Sorted per branch, date) mbed TLS ChangeLog (Sorted per branch, date)
= mbed TLS 2 branch
Bugfix
* Fix segfault in the benchmark program when benchmarking DHM.
= mbed TLS 2.0.0 released 2015-07-13 = mbed TLS 2.0.0 released 2015-07-13
Features Features

View File

@ -91,8 +91,6 @@ int main( void )
#define HEADER_FORMAT " %-24s : " #define HEADER_FORMAT " %-24s : "
#define TITLE_LEN 25 #define TITLE_LEN 25
#define DHM_SIZES 3
#define OPTIONS \ #define OPTIONS \
"md4, md5, ripemd160, sha1, sha256, sha512,\n" \ "md4, md5, ripemd160, sha1, sha256, sha512,\n" \
"arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish,\n" \ "arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish,\n" \
@ -611,19 +609,19 @@ int main( int argc, char *argv[] )
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_BIGNUM_C) #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_BIGNUM_C)
if( todo.dhm ) if( todo.dhm )
{ {
int dhm_sizes[DHM_SIZES] = { 2048, 3072 }; int dhm_sizes[] = { 2048, 3072 };
const char *dhm_P[DHM_SIZES] = { const char *dhm_P[] = {
MBEDTLS_DHM_RFC3526_MODP_2048_P, MBEDTLS_DHM_RFC3526_MODP_2048_P,
MBEDTLS_DHM_RFC3526_MODP_3072_P, MBEDTLS_DHM_RFC3526_MODP_3072_P,
}; };
const char *dhm_G[DHM_SIZES] = { const char *dhm_G[] = {
MBEDTLS_DHM_RFC3526_MODP_2048_G, MBEDTLS_DHM_RFC3526_MODP_2048_G,
MBEDTLS_DHM_RFC3526_MODP_3072_G, MBEDTLS_DHM_RFC3526_MODP_3072_G,
}; };
mbedtls_dhm_context dhm; mbedtls_dhm_context dhm;
size_t olen; size_t olen;
for( i = 0; i < DHM_SIZES; i++ ) for( i = 0; (size_t) i < sizeof( dhm_sizes ) / sizeof( dhm_sizes[0] ); i++ )
{ {
mbedtls_dhm_init( &dhm ); mbedtls_dhm_init( &dhm );