From e61514d70d3987fa750c3e3a63d7e19c6444d2b6 Mon Sep 17 00:00:00 2001 From: Brendan Shanks Date: Thu, 8 Mar 2018 17:40:56 -0800 Subject: [PATCH 1/2] benchmark: Fix incompatibility with C89 compilers Initializing arrays using non-constant expressions is not permitted in C89, and was causing errors when compiling with Metrowerks CodeWarrior (for classic MacOS) in C89 mode. Clang also produces a warning when compiling with '-Wc99-extensions': test/benchmark.c:670:42: warning: initializer for aggregate is not a compile-time constant [-Wc99-extensions] const unsigned char *dhm_P[] = { dhm_P_2048, dhm_P_3072 }; ^~~~~~~~~~ test/benchmark.c:674:42: warning: initializer for aggregate is not a compile-time constant [-Wc99-extensions] const unsigned char *dhm_G[] = { dhm_G_2048, dhm_G_3072 }; ^~~~~~~~~~ Declaring the arrays as 'static' makes them constant expressions. fixes #1353 --- programs/test/benchmark.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c index 2864caf84..1945b30d9 100644 --- a/programs/test/benchmark.c +++ b/programs/test/benchmark.c @@ -658,13 +658,13 @@ int main( int argc, char *argv[] ) if( todo.dhm ) { int dhm_sizes[] = { 2048, 3072 }; - const unsigned char dhm_P_2048[] = + static const unsigned char dhm_P_2048[] = MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN; - const unsigned char dhm_P_3072[] = + static const unsigned char dhm_P_3072[] = MBEDTLS_DHM_RFC3526_MODP_3072_P_BIN; - const unsigned char dhm_G_2048[] = + static const unsigned char dhm_G_2048[] = MBEDTLS_DHM_RFC3526_MODP_2048_G_BIN; - const unsigned char dhm_G_3072[] = + static const unsigned char dhm_G_3072[] = MBEDTLS_DHM_RFC3526_MODP_3072_G_BIN; const unsigned char *dhm_P[] = { dhm_P_2048, dhm_P_3072 }; From d49ab3ee60290b00f952e9d1aca364385c0d6e78 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 21 Mar 2018 17:03:44 +0100 Subject: [PATCH 2/2] Add ChangeLog entry. Fixes #1353 --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 68fb6f5e9..b88048d21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,8 @@ Bugfix In the context of SSL, this resulted in handshake failure. Reported by daniel in the Mbed TLS forum. #1351 * Fix Windows x64 builds with the included mbedTLS.sln file. #1347 + * Fix C89 incompatibility in benchmark.c. Contributed by Brendan Shanks. + #1353 Changes * Fix tag lengths and value ranges in the documentation of CCM encryption.