Skip to content

Commit afd0d07

Browse files
Merge pull request #6706 from bandi13/ZD16551
Add in another clamp to prevent infinite loops
2 parents ac90fa8 + 437c202 commit afd0d07

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

wolfcrypt/src/ecc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14749,6 +14749,11 @@ int mp_sqrtmod_prime(mp_int* n, mp_int* prime, mp_int* ret)
1474914749
if (mp_cmp_d(t1, 1) == MP_EQ)
1475014750
break;
1475114751
res = mp_exptmod(t1, two, prime, t1);
14752+
if ((res == MP_OKAY) && (mp_cmp_d(M,i) == MP_EQ)) {
14753+
/* This is to clamp the loop in case 'prime' is not really prime */
14754+
res = MP_VAL;
14755+
break;
14756+
}
1475214757
if (res == MP_OKAY)
1475314758
i++;
1475414759
}

0 commit comments

Comments
 (0)