Skip to content

Commit 9b81b0b

Browse files
author
Andras Fekete
committed
Add in clamp for mp_sqrtmod_prime
1 parent c9b72d7 commit 9b81b0b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

wolfcrypt/src/ecc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14710,6 +14710,12 @@ int mp_sqrtmod_prime(mp_int* n, mp_int* prime, mp_int* ret)
1471014710
/* Z = Z + 1 */
1471114711
if (res == MP_OKAY)
1471214712
res = mp_add_d(Z, 1, Z);
14713+
14714+
if ((res == MP_OKAY) && (mp_cmp(Z,prime) == MP_EQ)) {
14715+
/* This is to clamp the loop in case 'prime' is not really prime */
14716+
res = MP_VAL;
14717+
break;
14718+
}
1471314719
}
1471414720

1471514721
/* C = Z ^ Q mod prime */

0 commit comments

Comments
 (0)