From 0ccb0d5fceb2381b0df0f837804e7221ea120203 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Thu, 28 Jan 2021 09:54:58 +1000 Subject: [PATCH] SP math: fix one word Montgomery Reduction for non-asm Set the word size for x86. --- wolfcrypt/src/sp_int.c | 2 +- wolfssl/wolfcrypt/sp_int.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 30d3d01a8..3f7a2ca6d 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -11986,7 +11986,7 @@ static int _sp_mont_red(sp_int* a, sp_int* m, sp_int_digit mp) a->dp[1] = (sp_int_digit)w; w >>= SP_WORD_SIZE; a->dp[2] = (sp_int_digit)w; - a->used = 2; + a->used = 3; /* mp is SP_WORD_SIZE */ bits = SP_WORD_SIZE; } diff --git a/wolfssl/wolfcrypt/sp_int.h b/wolfssl/wolfcrypt/sp_int.h index 96133133b..00abfdaa7 100644 --- a/wolfssl/wolfcrypt/sp_int.h +++ b/wolfssl/wolfcrypt/sp_int.h @@ -167,6 +167,8 @@ extern "C" { #define SP_WORD_SIZE 16 #undef WOLFSSL_SP_ASM #endif +#elif defined(WOLFSSL_SP_X86) + #define SP_WORD_SIZE 32 #elif defined(WOLFSSL_SP_ARM64_ASM) || defined(WOLFSSL_SP_ARM64) #define SP_WORD_SIZE 64 #elif defined(WOLFSSL_SP_ARM32_ASM) || defined(WOLFSSL_SP_ARM32)