Skip to content

Commit 344c333

Browse files
committed
add check to sp_invmod_mont_ct to make sure the
result integer can hold the range of the modulus
1 parent 5f1ce09 commit 344c333

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

wolfcrypt/src/sp_int.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12445,6 +12445,10 @@ int sp_invmod_mont_ct(const sp_int* a, const sp_int* m, sp_int* r,
1244512445
else if (m->used * 2 >= SP_INT_DIGITS) {
1244612446
err = MP_VAL;
1244712447
}
12448+
/* check that r can hold the range of the modulus result */
12449+
else if (m->used > r->size) {
12450+
err = MP_VAL;
12451+
}
1244812452

1244912453
/* 0 != n*m + 1 (+ve m), r*a mod 0 is always 0 (never 1) */
1245012454
if ((err == MP_OKAY) && (sp_iszero(a) || sp_iszero(m) ||

0 commit comments

Comments
 (0)