forked from wolfSSL/wolfssl
Merge pull request #6693 from bandi13/ZD16551
Add in clamp for mp_sqrtmod_prime
This commit is contained in:
@@ -14707,6 +14707,12 @@ int mp_sqrtmod_prime(mp_int* n, mp_int* prime, mp_int* ret)
|
|||||||
/* Z = Z + 1 */
|
/* Z = Z + 1 */
|
||||||
if (res == MP_OKAY)
|
if (res == MP_OKAY)
|
||||||
res = mp_add_d(Z, 1, Z);
|
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 */
|
/* C = Z ^ Q mod prime */
|
||||||
|
Reference in New Issue
Block a user