Merge pull request #6426 from jpbland1/invariant-mp-size

add check to sp_invmod_mont_ct to make sure the
This commit is contained in:
Sean Parkinson
2023-05-22 08:14:39 +10:00
committed by GitHub

View File

@ -12467,6 +12467,10 @@ int sp_invmod_mont_ct(const sp_int* a, const sp_int* m, sp_int* r,
else if (m->used * 2 >= SP_INT_DIGITS) {
err = MP_VAL;
}
/* check that r can hold the range of the modulus result */
else if (m->used > r->size) {
err = MP_VAL;
}
/* 0 != n*m + 1 (+ve m), r*a mod 0 is always 0 (never 1) */
if ((err == MP_OKAY) && (sp_iszero(a) || sp_iszero(m) ||