Skip to content

Commit 46229bb

Browse files
Merge pull request #6693 from bandi13/ZD16551
Add in clamp for mp_sqrtmod_prime
2 parents a4152ab + 9b81b0b commit 46229bb

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
@@ -14707,6 +14707,12 @@ int mp_sqrtmod_prime(mp_int* n, mp_int* prime, mp_int* ret)
1470714707
/* Z = Z + 1 */
1470814708
if (res == MP_OKAY)
1470914709
res = mp_add_d(Z, 1, Z);
14710+
14711+
if ((res == MP_OKAY) && (mp_cmp(Z,prime) == MP_EQ)) {
14712+
/* This is to clamp the loop in case 'prime' is not really prime */
14713+
res = MP_VAL;
14714+
break;
14715+
}
1471014716
}
1471114717

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

0 commit comments

Comments
 (0)