mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Add in clamp for mp_sqrtmod_prime
This commit is contained in:
@ -14710,6 +14710,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