From aefddaf2b86f369d6c5d1abd052054c68cff8bcf Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Mon, 8 Feb 2021 10:07:15 +1000 Subject: [PATCH] SP int: mont_red - check size of a relative to m --- 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 30d3d01a8..691d48920 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -12246,6 +12246,9 @@ int sp_mont_red(sp_int* a, sp_int* m, sp_int_digit mp) if ((a == NULL) || (m == NULL) || sp_iszero(m)) { err = MP_VAL; } + else if (a->size < m->used * 2 + 1) { + err = MP_VAL; + } else { err = _sp_mont_red(a, m, mp); }