From 1fe9f2d89442f1237c3f437ab1811b83dff48c72 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Wed, 7 Sep 2022 17:22:22 +1000 Subject: [PATCH] SP int: fix for SP_INT_DIGITS calc Implementation of sp_mont_red needs words * 2 + 1. --- wolfssl/wolfcrypt/sp_int.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfssl/wolfcrypt/sp_int.h b/wolfssl/wolfcrypt/sp_int.h index 1c4fe91e4..ab831c4d6 100644 --- a/wolfssl/wolfcrypt/sp_int.h +++ b/wolfssl/wolfcrypt/sp_int.h @@ -425,10 +425,10 @@ typedef struct sp_ecc_ctx { * numbers in bits that will be used. * Double the size to hold multiplication result. * Add one to accommodate extra digit used by sp_mul(), sp_mulmod(), - * sp_sqr(), and sp_sqrmod(). + * sp_sqr(), sp_sqrmod() and sp_mont_red(). */ #define SP_INT_DIGITS \ - (((SP_INT_BITS * 2 + SP_WORD_SIZE - 1) / SP_WORD_SIZE) + 1) + (((SP_INT_BITS + SP_WORD_SIZE - 1) / SP_WORD_SIZE) * 2 + 1) #endif #ifndef SP_INT_MAX_BITS