From 6a5e802cc420be4ecdb84785d7b6b0f5d09033d5 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Tue, 5 Jan 2021 13:49:13 +1000 Subject: [PATCH] Disable algs: fix code to compile with various algs off/on benchmark.c: Only X25519/Ed25519/X448/Ed448 now compiles asn.c/asn.h: Only DSA now compiles --- wolfcrypt/benchmark/benchmark.c | 5 +---- wolfcrypt/src/asn.c | 6 ++++-- wolfcrypt/src/sp_int.c | 2 +- wolfssl/wolfcrypt/asn.h | 9 ++++++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 08c3b4ea5..97b5b4ddb 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -584,13 +584,11 @@ static const char* bench_result_words1[][4] = { #endif }; -#if !defined(NO_RSA) || defined(WOLFSSL_KEY_GEN) || defined(HAVE_NTRU) || \ +#if !defined(NO_RSA) || defined(HAVE_NTRU) || \ defined(HAVE_ECC) || !defined(NO_DH) || defined(HAVE_ECC_ENCRYPT) || \ defined(HAVE_CURVE25519) || defined(HAVE_CURVE25519_SHARED_SECRET) || \ defined(HAVE_ED25519) || defined(HAVE_CURVE448) || \ defined(HAVE_CURVE448_SHARED_SECRET) || defined(HAVE_ED448) -#if defined(HAVE_ECC) || defined(WOLFSSL_PUBLIC_MP) || !defined(NO_DH) || \ - (!defined(NO_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) static const char* bench_desc_words[][9] = { /* 0 1 2 3 4 5 6 7 8 */ @@ -600,7 +598,6 @@ static const char* bench_desc_words[][9] = { #endif }; -#endif #endif #if defined(__GNUC__) && defined(__x86_64__) && !defined(NO_ASM) && !defined(WOLFSSL_SGX) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 2c4536921..f1eb9022b 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -15958,8 +15958,9 @@ int DecodeECC_DSA_Sig_Bin(const byte* sig, word32 sigLen, byte* r, word32* rLen, return ret; } +#endif - +#if defined(HAVE_ECC) || !defined(NO_DSA) int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen, mp_int* r, mp_int* s) { word32 idx = 0; @@ -15992,8 +15993,9 @@ int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen, mp_int* r, mp_int* s) return 0; } +#endif - +#ifdef HAVE_ECC int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key, word32 inSz) { diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 5828d4446..d2af6a1d8 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -2220,7 +2220,7 @@ void sp_forcezero(sp_int* a) #endif /* !WOLFSSL_RSA_VERIFY_ONLY || !NO_DH || HAVE_ECC */ #if defined(WOLSSL_SP_MATH_ALL) || !defined(NO_DH) || defined(HAVE_ECC) || \ - !defined(NO_RSA) + !defined(NO_RSA) || defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY) /* Copy value of multi-precision number a into r. * * @param [in] a SP integer - source. diff --git a/wolfssl/wolfcrypt/asn.h b/wolfssl/wolfcrypt/asn.h index 90350ea0e..e7dec24ec 100644 --- a/wolfssl/wolfcrypt/asn.h +++ b/wolfssl/wolfcrypt/asn.h @@ -682,7 +682,8 @@ struct SignatureCtx { #if !(defined(NO_RSA) && defined(NO_DSA)) byte* sigCpy; #endif -#if defined(HAVE_ECC) || defined(HAVE_ED25519) || defined(HAVE_ED448) || !defined(NO_DSA) +#if defined(HAVE_ECC) || defined(HAVE_ED25519) || defined(HAVE_ED448) || \ + !defined(NO_DSA) int verify; #endif union { @@ -1209,11 +1210,13 @@ WOLFSSL_LOCAL int FlattenAltNames( byte*, word32, const DNS_entry*); mp_int* s); WOLFSSL_LOCAL int StoreECC_DSA_Sig_Bin(byte* out, word32* outLen, const byte* r, word32 rLen, const byte* s, word32 sLen); - WOLFSSL_LOCAL int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen, - mp_int* r, mp_int* s); WOLFSSL_LOCAL int DecodeECC_DSA_Sig_Bin(const byte* sig, word32 sigLen, byte* r, word32* rLen, byte* s, word32* sLen); #endif +#if defined(HAVE_ECC) || !defined(NO_DSA) + WOLFSSL_LOCAL int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen, + mp_int* r, mp_int* s); +#endif #if defined HAVE_ECC && (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) WOLFSSL_API int EccEnumToNID(int n); #endif