From dbeaefd65b478505fb8c03d926a8e45a456194d2 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 4 Jul 2017 10:13:59 +0200 Subject: [PATCH] remove LTC_{DH,DSA}_KEY_INITIALIZER --- demos/timing.c | 4 ++-- src/headers/tomcrypt_pk.h | 4 ---- src/pk/dh/dh_check_pubkey.c | 3 --- src/pk/dh/dh_make_key.c | 4 ---- src/pk/dh/dh_set.c | 16 ---------------- src/pk/dsa/dsa_generate_pqg.c | 6 ------ src/pk/dsa/dsa_make_key.c | 5 ----- src/pk/dsa/dsa_set.c | 17 ----------------- tests/dh_test.c | 9 +++------ tests/dsa_test.c | 5 ++--- 10 files changed, 7 insertions(+), 66 deletions(-) diff --git a/demos/timing.c b/demos/timing.c index d075958..81e8f9c 100644 --- a/demos/timing.c +++ b/demos/timing.c @@ -646,7 +646,7 @@ static void time_prng(void) /* time various DSA operations */ static void time_dsa(void) { - dsa_key key = LTC_DSA_KEY_INITIALIZER; + dsa_key key; ulong64 t1, t2; unsigned long x, y; int err; @@ -893,7 +893,7 @@ static void time_katja(void) { fprintf(stderr, "NO Katja\n"); } /* time various DH operations */ static void time_dh(void) { - dh_key key = LTC_DH_KEY_INITIALIZER; + dh_key key; ulong64 t1, t2; unsigned long i, x, y; int err; diff --git a/src/headers/tomcrypt_pk.h b/src/headers/tomcrypt_pk.h index 49a5c6b3..88c2cab 100644 --- a/src/headers/tomcrypt_pk.h +++ b/src/headers/tomcrypt_pk.h @@ -213,8 +213,6 @@ typedef struct { void *prime; } dh_key; -#define LTC_DH_KEY_INITIALIZER { PK_PUBLIC, NULL, NULL, NULL, NULL } - int dh_get_groupsize(dh_key *key); int dh_export(unsigned char *out, unsigned long *outlen, int type, dh_key *key); @@ -442,8 +440,6 @@ typedef struct { void *y; } dsa_key; -#define LTC_DSA_KEY_INITIALIZER { PK_PUBLIC, 0, NULL, NULL, NULL, NULL, NULL } - int dsa_make_key(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key); int dsa_set_pqg(const unsigned char *p, unsigned long plen, diff --git a/src/pk/dh/dh_check_pubkey.c b/src/pk/dh/dh_check_pubkey.c index c77e4bd..fb4f37b 100644 --- a/src/pk/dh/dh_check_pubkey.c +++ b/src/pk/dh/dh_check_pubkey.c @@ -23,9 +23,6 @@ int dh_check_pubkey(dh_key *key) int i, digit_count, bits_set = 0, err; LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->y != NULL); - LTC_ARGCHK(key->base != NULL); - LTC_ARGCHK(key->prime != NULL); if ((err = mp_init(&p_minus1)) != CRYPT_OK) { return err; diff --git a/src/pk/dh/dh_make_key.c b/src/pk/dh/dh_make_key.c index 69eaf3c..549a244 100644 --- a/src/pk/dh/dh_make_key.c +++ b/src/pk/dh/dh_make_key.c @@ -49,10 +49,6 @@ int dh_make_key(prng_state *prng, int wprng, dh_key *key) int err, max_iterations = PK_MAX_RETRIES; LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->x != NULL); - LTC_ARGCHK(key->y != NULL); - LTC_ARGCHK(key->base != NULL); - LTC_ARGCHK(key->prime != NULL); LTC_ARGCHK(ltc_mp.name != NULL); LTC_ARGCHK(prng != NULL); diff --git a/src/pk/dh/dh_set.c b/src/pk/dh/dh_set.c index aeac01e..4e0cf0b 100644 --- a/src/pk/dh/dh_set.c +++ b/src/pk/dh/dh_set.c @@ -28,10 +28,6 @@ int dh_set_pg(const unsigned char *p, unsigned long plen, int err; LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->x == NULL); - LTC_ARGCHK(key->y == NULL); - LTC_ARGCHK(key->base == NULL); - LTC_ARGCHK(key->prime == NULL); LTC_ARGCHK(p != NULL); LTC_ARGCHK(g != NULL); LTC_ARGCHK(ltc_mp.name != NULL); @@ -65,10 +61,6 @@ int dh_set_pg_dhparam(const unsigned char *dhparam, unsigned long dhparamlen, dh int err; LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->x == NULL); - LTC_ARGCHK(key->y == NULL); - LTC_ARGCHK(key->base == NULL); - LTC_ARGCHK(key->prime == NULL); LTC_ARGCHK(ltc_mp.name != NULL); LTC_ARGCHK(dhparam != NULL); LTC_ARGCHK(dhparamlen > 0); @@ -102,10 +94,6 @@ int dh_set_pg_groupsize(int groupsize, dh_key *key) int err, i; LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->x == NULL); - LTC_ARGCHK(key->y == NULL); - LTC_ARGCHK(key->base == NULL); - LTC_ARGCHK(key->prime == NULL); LTC_ARGCHK(ltc_mp.name != NULL); LTC_ARGCHK(groupsize > 0); @@ -142,10 +130,6 @@ int dh_set_key(const unsigned char *pub, unsigned long publen, int err; LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->x != NULL); - LTC_ARGCHK(key->y != NULL); - LTC_ARGCHK(key->base != NULL); - LTC_ARGCHK(key->prime != NULL); LTC_ARGCHK(ltc_mp.name != NULL); if(priv == NULL) { diff --git a/src/pk/dsa/dsa_generate_pqg.c b/src/pk/dsa/dsa_generate_pqg.c index d6e3ac7..bcf9e34 100644 --- a/src/pk/dsa/dsa_generate_pqg.c +++ b/src/pk/dsa/dsa_generate_pqg.c @@ -216,12 +216,6 @@ int dsa_generate_pqg(prng_state *prng, int wprng, int group_size, int modulus_si int err; LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->x == NULL); - LTC_ARGCHK(key->y == NULL); - LTC_ARGCHK(key->p == NULL); - LTC_ARGCHK(key->g == NULL); - LTC_ARGCHK(key->q == NULL); - LTC_ARGCHK(key->qord == 0); LTC_ARGCHK(ltc_mp.name != NULL); /* init mp_ints */ diff --git a/src/pk/dsa/dsa_make_key.c b/src/pk/dsa/dsa_make_key.c index b7ccdd5..708eb08 100644 --- a/src/pk/dsa/dsa_make_key.c +++ b/src/pk/dsa/dsa_make_key.c @@ -27,11 +27,6 @@ int dsa_make_key_ex(prng_state *prng, int wprng, dsa_key *key) int err; LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->x != NULL); - LTC_ARGCHK(key->y != NULL); - LTC_ARGCHK(key->p != NULL); - LTC_ARGCHK(key->g != NULL); - LTC_ARGCHK(key->q != NULL); LTC_ARGCHK(ltc_mp.name != NULL); /* so now we have our DH structure, generator g, order q, modulus p diff --git a/src/pk/dsa/dsa_set.c b/src/pk/dsa/dsa_set.c index 5203ed7..3f28b56 100755 --- a/src/pk/dsa/dsa_set.c +++ b/src/pk/dsa/dsa_set.c @@ -33,12 +33,6 @@ int dsa_set_pqg(const unsigned char *p, unsigned long plen, LTC_ARGCHK(q != NULL); LTC_ARGCHK(g != NULL); LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->x == NULL); - LTC_ARGCHK(key->y == NULL); - LTC_ARGCHK(key->p == NULL); - LTC_ARGCHK(key->g == NULL); - LTC_ARGCHK(key->q == NULL); - LTC_ARGCHK(key->qord == 0); LTC_ARGCHK(ltc_mp.name != NULL); /* init key */ @@ -80,12 +74,6 @@ int dsa_set_pqg_dsaparam(const unsigned char *dsaparam, unsigned long dsaparamle LTC_ARGCHK(dsaparam != NULL); LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->x == NULL); - LTC_ARGCHK(key->y == NULL); - LTC_ARGCHK(key->p == NULL); - LTC_ARGCHK(key->g == NULL); - LTC_ARGCHK(key->q == NULL); - LTC_ARGCHK(key->qord == 0); LTC_ARGCHK(ltc_mp.name != NULL); /* init key */ @@ -130,11 +118,6 @@ int dsa_set_key(const unsigned char *pub, unsigned long publen, int err; LTC_ARGCHK(key != NULL); - LTC_ARGCHK(key->x != NULL); - LTC_ARGCHK(key->y != NULL); - LTC_ARGCHK(key->p != NULL); - LTC_ARGCHK(key->g != NULL); - LTC_ARGCHK(key->q != NULL); LTC_ARGCHK(ltc_mp.name != NULL); if ((err = mp_read_unsigned_bin(key->y, (unsigned char *)pub , publen)) != CRYPT_OK) { goto LBL_ERR; } diff --git a/tests/dh_test.c b/tests/dh_test.c index d9ddfee..2558fc0 100644 --- a/tests/dh_test.c +++ b/tests/dh_test.c @@ -60,7 +60,7 @@ done: static int _dhparam_test(void) { - dh_key k = LTC_DH_KEY_INITIALIZER; + dh_key k; unsigned char buf[1024]; /* generated by: openssl dhparam -outform der -out dhparam.der 2048 */ unsigned char dhparam_der[] = { @@ -150,9 +150,7 @@ static int _dhparam_test(void) static int _set_test(void) { - dh_key k1 = LTC_DH_KEY_INITIALIZER; - dh_key k2 = LTC_DH_KEY_INITIALIZER; - dh_key k3 = LTC_DH_KEY_INITIALIZER; + dh_key k1, k2, k3; unsigned char buf[4096]; unsigned long len; int i; @@ -368,8 +366,7 @@ static int _basic_test(void) unsigned char buf[3][4096]; unsigned long x, y, z; int size; - dh_key usera = LTC_DH_KEY_INITIALIZER; - dh_key userb = LTC_DH_KEY_INITIALIZER; + dh_key usera, userb; /* make up two keys */ DO(dh_set_pg_groupsize(KEYSIZE/8, &usera)); diff --git a/tests/dsa_test.c b/tests/dsa_test.c index ef5f4ab..7c01ee7 100644 --- a/tests/dsa_test.c +++ b/tests/dsa_test.c @@ -131,7 +131,7 @@ static unsigned char dsaparam_der[] = { static int _dsa_compat_test(void) { - dsa_key key = LTC_DSA_KEY_INITIALIZER; + dsa_key key; unsigned char tmp[1024], buf[1024]; unsigned long x, len; unsigned char key_parts[5][256]; @@ -251,8 +251,7 @@ int dsa_test(void) unsigned char msg[16], out[1024], out2[1024], ch; unsigned long x, y; int stat1, stat2; - dsa_key key = LTC_DSA_KEY_INITIALIZER; - dsa_key key2 = LTC_DSA_KEY_INITIALIZER; + dsa_key key, key2; DO(_dsa_compat_test());