From 5d331610320ff3de8a26505d8c5b62995299db26 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 4 Jun 2021 13:32:59 -0700 Subject: [PATCH] Fixes for RSA keygen with SP (no DH). Thanks Sean. --- wolfcrypt/src/sp_int.c | 8 ++++---- wolfssl/wolfcrypt/sp_int.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index a507c7501..558eaa232 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -68,8 +68,8 @@ This library provides single precision (SP) integer math functions. * WOLFSSL_SP_PPC Enable PPC assembly speedups * WOLFSSL_SP_MIPS64 Enable MIPS64 assembly speedups * WOLFSSL_SP_MIPS Enable MIPS assembly speedups - * WOLFSSL_SP_RISCV64 Enable RISCV64 assmebly speedups - * WOLFSSL_SP_RISCV32 Enable RISCV32 assmebly speedups + * WOLFSSL_SP_RISCV64 Enable RISCV64 assembly speedups + * WOLFSSL_SP_RISCV32 Enable RISCV32 assembly speedups * WOLFSSL_SP_S390X Enable S390X assembly speedups * SP_WORD_SIZE Force 32 or 64 bit mode * WOLFSSL_SP_NONBLOCK Enables "non blocking" mode for SP math, which @@ -8621,8 +8621,8 @@ int sp_exptmod_ex(sp_int* b, sp_int* e, int digits, sp_int* m, sp_int* r) if ((!done) && (err == MP_OKAY)) { /* Use code optimized for specific sizes if possible */ -#if defined(WOLFSSL_SP_MATH_ALL) && (defined(WOLFSSL_HAVE_SP_RSA) || \ - defined(WOLFSSL_HAVE_SP_DH)) +#if (defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \ + (defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH)) #ifndef WOLFSSL_SP_NO_2048 if ((mBits == 1024) && sp_isodd(m) && (bBits <= 1024) && (eBits <= 1024)) { diff --git a/wolfssl/wolfcrypt/sp_int.h b/wolfssl/wolfcrypt/sp_int.h index a32810e49..8e5164d05 100644 --- a/wolfssl/wolfcrypt/sp_int.h +++ b/wolfssl/wolfcrypt/sp_int.h @@ -383,7 +383,8 @@ typedef struct sp_ecc_ctx { #define SP_INT_DIGITS (((3072 + SP_WORD_SIZE) / SP_WORD_SIZE) + 1) #endif #else - #if defined(WOLFSSL_HAVE_SP_DH) + #if defined(WOLFSSL_HAVE_SP_DH) || \ + (defined(WOLFSSL_HAVE_SP_RSA) && defined(WOLFSSL_KEY_GEN)) #define SP_INT_DIGITS (((4096 + SP_WORD_SIZE) / SP_WORD_SIZE) + 1) #else #define SP_INT_DIGITS (((2048 + SP_WORD_SIZE) / SP_WORD_SIZE) + 1)