From b13848e56884937416acbcd7d32eb8bf8a9f9e91 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 16 Oct 2020 15:53:09 -0700 Subject: [PATCH] Fix tests to handle ECC < 224 not enabled. --- tests/api.c | 35 +++++++++++++++++++---------------- wolfcrypt/test/test.c | 10 +++++----- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/tests/api.c b/tests/api.c index a9c98a41a..ed0b62359 100644 --- a/tests/api.c +++ b/tests/api.c @@ -56,8 +56,9 @@ #ifndef ECC_PRIV_KEY_BUF #define ECC_PRIV_KEY_BUF 66 /* For non user defined curves. */ #endif - #ifdef HAVE_ALL_CURVES - /* ecc key sizes: 14, 16, 20, 24, 28, 30, 32, 40, 48, 64*/ + /* ecc key sizes: 14, 16, 20, 24, 28, 30, 32, 40, 48, 64 */ + /* logic to choose right key ECC size */ + #if defined(HAVE_ALL_CURVES) && defined(ECC_WEAK_CURVES) #ifndef KEY14 #define KEY14 14 #endif @@ -70,6 +71,21 @@ #if !defined(KEY24) #define KEY24 24 #endif + #else + #ifndef KEY14 + #define KEY14 32 + #endif + #if !defined(KEY16) + #define KEY16 32 + #endif + #if !defined(KEY20) + #define KEY20 32 + #endif + #if !defined(KEY24) + #define KEY24 32 + #endif + #endif + #ifdef HAVE_ALL_CURVES #if !defined(KEY28) #define KEY28 28 #endif @@ -88,20 +104,7 @@ #if !defined(KEY64) #define KEY64 64 #endif - #else - /* ecc key sizes: 14, 16, 20, 24, 28, 30, 32, 40, 48, 64*/ - #ifndef KEY14 - #define KEY14 32 - #endif - #if !defined(KEY16) - #define KEY16 32 - #endif - #if !defined(KEY20) - #define KEY20 32 - #endif - #if !defined(KEY24) - #define KEY24 32 - #endif + #else #if !defined(KEY28) #define KEY28 32 #endif diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 566c3adc2..2818f1086 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -21868,31 +21868,31 @@ static int ecc_test(void) return -9900; #endif -#if defined(HAVE_ECC112) || defined(HAVE_ALL_CURVES) +#if (defined(HAVE_ECC112) || defined(HAVE_ALL_CURVES)) && defined(ECC_WEAK_CURVES) ret = ecc_test_curve(&rng, 14); if (ret < 0) { goto done; } #endif /* HAVE_ECC112 */ -#if defined(HAVE_ECC128) || defined(HAVE_ALL_CURVES) +#if (defined(HAVE_ECC128) || defined(HAVE_ALL_CURVES)) && defined(ECC_WEAK_CURVES) ret = ecc_test_curve(&rng, 16); if (ret < 0) { goto done; } #endif /* HAVE_ECC128 */ -#if defined(HAVE_ECC160) || defined(HAVE_ALL_CURVES) +#if (defined(HAVE_ECC160) || defined(HAVE_ALL_CURVES)) && defined(ECC_WEAK_CURVES) ret = ecc_test_curve(&rng, 20); if (ret < 0) { goto done; } #endif /* HAVE_ECC160 */ -#if defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES) +#if (defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)) && defined(ECC_WEAK_CURVES) ret = ecc_test_curve(&rng, 24); if (ret < 0) { goto done; } #endif /* HAVE_ECC192 */ -#if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES) +#if (defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)) && defined(ECC_WEAK_CURVES) ret = ecc_test_curve(&rng, 28); if (ret < 0) { goto done;