Skip to content

Commit d8e4c78

Browse files
authored
Merge pull request #6426 from jpbland1/invariant-mp-size
add check to sp_invmod_mont_ct to make sure the
2 parents a06bd77 + 344c333 commit d8e4c78

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
@@ -12467,6 +12467,10 @@ int sp_invmod_mont_ct(const sp_int* a, const sp_int* m, sp_int* r,
1246712467
else if (m->used * 2 >= SP_INT_DIGITS) {
1246812468
err = MP_VAL;
1246912469
}
12470+
/* check that r can hold the range of the modulus result */
12471+
else if (m->used > r->size) {
12472+
err = MP_VAL;
12473+
}
1247012474

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

0 commit comments

Comments
 (0)