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

add check to sp_invmod_mont_ct to make sure the
pull/6432/head
Sean Parkinson 2023-05-22 08:14:39 +10:00 committed by GitHub
commit d8e4c78960
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

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) ||