From 4f0ed552327d6420367042f4c7bd2af37c0fb026 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Mon, 25 Jan 2021 10:15:20 +1000 Subject: [PATCH] SP math all: fix 1 word Montgomery Reduce May have 3 words in partial result before shifting down. --- wolfcrypt/src/sp_int.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 07c8f4ad8..30d3d01a8 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -12065,7 +12065,7 @@ static int _sp_mont_red(sp_int* a, sp_int* m, sp_int_digit mp) a->dp[1] = w; w >>= SP_WORD_SIZE; a->dp[2] = w; - a->used = m->used * 2; + a->used = m->used * 2 + 1; /* mp is SP_WORD_SIZE */ bits = SP_WORD_SIZE; }