better detection of invalid ecc keys

This commit is contained in:
toddouska
2015-05-01 14:44:43 -07:00
parent 46eca67336
commit 6db33051d3
6 changed files with 91 additions and 3 deletions

View File

@@ -866,7 +866,7 @@ int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c)
{
mp_int x, y, u, v, B, D;
int res, neg;
int res, neg, loop_check = 0;
/* 2. [modified] b must be odd */
if (mp_iseven (b) == 1) {
@@ -958,6 +958,10 @@ top:
/* if not zero goto step 4 */
if (mp_iszero (&u) == 0) {
if (++loop_check > 1024) {
res = MP_VAL;
goto LBL_ERR;
}
goto top;
}