From fff832091f35ee481111e8bf1dca1ea7ffe1d0c0 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Wed, 21 Jun 2017 13:25:06 +0200 Subject: [PATCH] ecc_sign_hash max_iterations --- src/pk/ecc/ecc_sign_hash.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pk/ecc/ecc_sign_hash.c b/src/pk/ecc/ecc_sign_hash.c index c62c774..65d2a8c 100644 --- a/src/pk/ecc/ecc_sign_hash.c +++ b/src/pk/ecc/ecc_sign_hash.c @@ -22,7 +22,7 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen, { ecc_key pubkey; void *r, *s, *e, *p; - int err; + int err, max_iterations = 20; unsigned long pbits, pbytes, i, shift_right; unsigned char ch, buf[MAXBLOCKSIZE]; @@ -71,7 +71,7 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen, } /* make up a key and export the public copy */ - for (;;) { + do { if ((err = ecc_make_key_ex(prng, wprng, &pubkey, key->dp)) != CRYPT_OK) { goto errnokey; } @@ -93,6 +93,10 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen, break; } } + } while (--max_iterations > 0); + + if (max_iterations == 0) { + goto errnokey; } if (sigformat == 1) {