From dbf18b85321a7aa5e443d9163180887e239d5e40 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Fri, 25 Sep 2020 09:43:10 -0700 Subject: [PATCH] Test ECC-521 Only Update benchmark and wolfcrypt test to support using only ECC-521 in a custom curve list. --- wolfcrypt/benchmark/benchmark.c | 2 ++ wolfcrypt/test/test.c | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 5dc960634..b342f8fd7 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -5236,6 +5236,8 @@ void bench_ntruKeyGen(void) #define BENCH_ECC_SIZE 48 #elif defined(HAVE_ECC224) #define BENCH_ECC_SIZE 28 + #elif defined(HAVE_ECC521) + #define BENCH_ECC_SIZE 66 #else #error No ECC keygen size defined for benchmark #endif diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 164ec4228..2c8e5c5c3 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -10503,7 +10503,7 @@ byte GetEntropy(ENTROPY_CMD cmd, byte* out) static const char* dsaKey = CERT_ROOT "dsa2048.der"; #endif #endif /* !USE_CERT_BUFFER_* */ -#if !defined(USE_CERT_BUFFERS_256) +#if !defined(USE_CERT_BUFFERS_256) && !defined(NO_ECC256) #ifdef HAVE_ECC /* cert files to be used in rsa cert gen test, check if RSA enabled */ #ifdef HAVE_ECC_KEY_IMPORT @@ -18239,6 +18239,8 @@ static int x963kdf_test(void) #define ECC_KEYGEN_SIZE 48 #elif defined(HAVE_ECC224) #define ECC_KEYGEN_SIZE 28 + #elif defined(HAVE_ECC521) + #define ECC_KEYGEN_SIZE 66 #else #error No ECC keygen size defined for test #endif @@ -18796,9 +18798,6 @@ static int ecc_test_make_pub(WC_RNG* rng) #ifdef HAVE_ECC_VERIFY int verify = 0; #endif -#ifndef USE_CERT_BUFFERS_256 - XFILE file; -#endif #ifdef WOLFSSL_SMALL_STACK if ((key == NULL) || @@ -18822,13 +18821,15 @@ static int ecc_test_make_pub(WC_RNG* rng) XMEMCPY(tmp, ecc_key_der_256, (size_t)sizeof_ecc_key_der_256); tmpSz = (size_t)sizeof_ecc_key_der_256; #else - file = XFOPEN(eccKeyDerFile, "rb"); - if (!file) { - ERROR_OUT(-9617, done); - } + { + XFILE file = XFOPEN(eccKeyDerFile, "rb"); + if (!file) { + ERROR_OUT(-9617, done); + } - tmpSz = (word32)XFREAD(tmp, 1, ECC_BUFSIZE, file); - XFCLOSE(file); + tmpSz = (word32)XFREAD(tmp, 1, ECC_BUFSIZE, file); + XFCLOSE(file); + } #endif /* USE_CERT_BUFFERS_256 */ /* import private only then test with */