From 40506a6ddf7a8ea49040fd54c66966a2917214b4 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Thu, 7 Aug 2025 10:14:02 -0500 Subject: [PATCH 1/2] Revert "SP int: modular exponentiation constant time" (fixes regression in benchmark "RSA,2048,public"). This reverts commit 219509d7d9874e0d25c65c7c1e620bcb19adf898. --- wolfcrypt/src/sp_int.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index cd1db57eb..b5c832d3e 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -14207,6 +14207,9 @@ static int _sp_exptmod_nct(const sp_int* b, const sp_int* e, const sp_int* m, if (bits > 450) { winBits = 6; } + else if (bits <= 21) { + winBits = 1; + } else if (bits <= 36) { winBits = 3; } From 2dfc7eee89f9798d00c9f710b84f3868a3b30ae3 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Thu, 7 Aug 2025 10:26:34 -0500 Subject: [PATCH 2/2] wolfcrypt/src/sp_int.c: in _sp_exptmod_nct(), use 2 bit window if bits <= 21. --- 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 b5c832d3e..5a8222a52 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -14208,7 +14208,7 @@ static int _sp_exptmod_nct(const sp_int* b, const sp_int* e, const sp_int* m, winBits = 6; } else if (bits <= 21) { - winBits = 1; + winBits = 2; } else if (bits <= 36) { winBits = 3;