Skip to content

Commit 0ffb586

Browse files
Merge pull request #7032 from SparkiDev/sp_int_neg_mont_red
SP int neg sp_mont_red_ex: disallow negative numbers
2 parents 2c9208b + cf8a6ef commit 0ffb586

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

wolfcrypt/src/sp_int.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17524,6 +17524,11 @@ int sp_mont_red_ex(sp_int* a, const sp_int* m, sp_int_digit mp, int ct)
1752417524
if ((a == NULL) || (m == NULL) || sp_iszero(m)) {
1752517525
err = MP_VAL;
1752617526
}
17527+
#ifdef WOLFSSL_SP_INT_NEGATIVE
17528+
else if ((a->sign == MP_NEG) || (m->sign == MP_NEG)) {
17529+
err = MP_VAL;
17530+
}
17531+
#endif
1752717532
/* Ensure a has enough space for calculation. */
1752817533
else if (a->size < m->used * 2 + 1) {
1752917534
err = MP_VAL;

0 commit comments

Comments
 (0)