Skip to content

Commit fff8320

Browse files
committed
ecc_sign_hash max_iterations
1 parent cdf04b6 commit fff8320

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/pk/ecc/ecc_sign_hash.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen,
2222
{
2323
ecc_key pubkey;
2424
void *r, *s, *e, *p;
25-
int err;
25+
int err, max_iterations = 20;
2626
unsigned long pbits, pbytes, i, shift_right;
2727
unsigned char ch, buf[MAXBLOCKSIZE];
2828

@@ -71,7 +71,7 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen,
7171
}
7272

7373
/* make up a key and export the public copy */
74-
for (;;) {
74+
do {
7575
if ((err = ecc_make_key_ex(prng, wprng, &pubkey, key->dp)) != CRYPT_OK) {
7676
goto errnokey;
7777
}
@@ -93,6 +93,10 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen,
9393
break;
9494
}
9595
}
96+
} while (--max_iterations > 0);
97+
98+
if (max_iterations == 0) {
99+
goto errnokey;
96100
}
97101

98102
if (sigformat == 1) {

0 commit comments

Comments
 (0)