From be2ad82e6d5b31db143531c8c5d81666b5b6a2bf Mon Sep 17 00:00:00 2001 From: elms Date: Wed, 25 Aug 2021 14:59:51 -0700 Subject: [PATCH] sp_math: error on multiplier larger than curve order zd 12674 --- wolfcrypt/src/ecc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index c5be45d08..0ff14a63d 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -3121,6 +3121,11 @@ exit: (void)a; + /* k can't have more bits than modulus count plus 1 */ + if (mp_count_bits(k) > mp_count_bits(modulus) + 1) { + return ECC_OUT_OF_RANGE_E; + } + #ifdef WOLFSSL_HAVE_SP_ECC #ifndef WOLFSSL_SP_NO_256 if (mp_count_bits(modulus) == 256) {