From bc4236d90ff670fbb132164f48ff55037d94ed50 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Sun, 11 Jun 2017 21:12:14 +0200 Subject: [PATCH] tuning dh_make_key --- src/pk/dh/dh.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pk/dh/dh.c b/src/pk/dh/dh.c index 6239c7a..f832e01 100644 --- a/src/pk/dh/dh.c +++ b/src/pk/dh/dh.c @@ -119,7 +119,6 @@ int dh_make_key(prng_state *prng, int wprng, int groupsize, dh_key *key) LTC_ARGCHK(key != NULL); LTC_ARGCHK(prng != NULL); - LTC_ARGCHK(groupsize >= 32); /* good prng? */ if ((err = prng_is_valid(wprng)) != CRYPT_OK) { @@ -183,8 +182,8 @@ int dh_make_key(prng_state *prng, int wprng, int groupsize, dh_key *key) if ((err = mp_read_unsigned_bin(key->x, buf, keysize)) != CRYPT_OK) { goto error; } /* compute the y value - public key */ if ((err = mp_exptmod(g, key->x, p, key->y)) != CRYPT_OK) { goto error; } - /* avoid: y == 1 OR y == p-1 */ - } while (mp_cmp(key->y, p_minus1) != LTC_MP_LT || mp_cmp_d(key->y, 1) != LTC_MP_GT); + /* avoid: y <= 1 OR y >= p-1 */ + } while (mp_cmp(key->y, p_minus1) != LTC_MP_LT || mp_cmp_d(key->y, 1) != LTC_MP_GT); /* success */ key->idx = idx;