Merge pull request #6693 from bandi13/ZD16551

Add in clamp for mp_sqrtmod_prime
This commit is contained in:
JacobBarthelmeh 2023-08-11 09:22:53 -06:00 committed by GitHub
commit 46229bb167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14707,6 +14707,12 @@ int mp_sqrtmod_prime(mp_int* n, mp_int* prime, mp_int* ret)
/* Z = Z + 1 */
if (res == MP_OKAY)
res = mp_add_d(Z, 1, Z);
if ((res == MP_OKAY) && (mp_cmp(Z,prime) == MP_EQ)) {
/* This is to clamp the loop in case 'prime' is not really prime */
res = MP_VAL;
break;
}
}
/* C = Z ^ Q mod prime */