remove LTC_{DH,DSA}_KEY_INITIALIZER
This commit is contained in:
parent
d1ecd82a42
commit
dbeaefd65b
@ -646,7 +646,7 @@ static void time_prng(void)
|
|||||||
/* time various DSA operations */
|
/* time various DSA operations */
|
||||||
static void time_dsa(void)
|
static void time_dsa(void)
|
||||||
{
|
{
|
||||||
dsa_key key = LTC_DSA_KEY_INITIALIZER;
|
dsa_key key;
|
||||||
ulong64 t1, t2;
|
ulong64 t1, t2;
|
||||||
unsigned long x, y;
|
unsigned long x, y;
|
||||||
int err;
|
int err;
|
||||||
@ -893,7 +893,7 @@ static void time_katja(void) { fprintf(stderr, "NO Katja\n"); }
|
|||||||
/* time various DH operations */
|
/* time various DH operations */
|
||||||
static void time_dh(void)
|
static void time_dh(void)
|
||||||
{
|
{
|
||||||
dh_key key = LTC_DH_KEY_INITIALIZER;
|
dh_key key;
|
||||||
ulong64 t1, t2;
|
ulong64 t1, t2;
|
||||||
unsigned long i, x, y;
|
unsigned long i, x, y;
|
||||||
int err;
|
int err;
|
||||||
|
@ -213,8 +213,6 @@ typedef struct {
|
|||||||
void *prime;
|
void *prime;
|
||||||
} dh_key;
|
} dh_key;
|
||||||
|
|
||||||
#define LTC_DH_KEY_INITIALIZER { PK_PUBLIC, NULL, NULL, NULL, NULL }
|
|
||||||
|
|
||||||
int dh_get_groupsize(dh_key *key);
|
int dh_get_groupsize(dh_key *key);
|
||||||
|
|
||||||
int dh_export(unsigned char *out, unsigned long *outlen, int type, 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;
|
void *y;
|
||||||
} dsa_key;
|
} 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_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,
|
int dsa_set_pqg(const unsigned char *p, unsigned long plen,
|
||||||
|
@ -23,9 +23,6 @@ int dh_check_pubkey(dh_key *key)
|
|||||||
int i, digit_count, bits_set = 0, err;
|
int i, digit_count, bits_set = 0, err;
|
||||||
|
|
||||||
LTC_ARGCHK(key != NULL);
|
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) {
|
if ((err = mp_init(&p_minus1)) != CRYPT_OK) {
|
||||||
return err;
|
return err;
|
||||||
|
@ -49,10 +49,6 @@ int dh_make_key(prng_state *prng, int wprng, dh_key *key)
|
|||||||
int err, max_iterations = PK_MAX_RETRIES;
|
int err, max_iterations = PK_MAX_RETRIES;
|
||||||
|
|
||||||
LTC_ARGCHK(key != NULL);
|
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(ltc_mp.name != NULL);
|
||||||
LTC_ARGCHK(prng != NULL);
|
LTC_ARGCHK(prng != NULL);
|
||||||
|
|
||||||
|
@ -28,10 +28,6 @@ int dh_set_pg(const unsigned char *p, unsigned long plen,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
LTC_ARGCHK(key != NULL);
|
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(p != NULL);
|
||||||
LTC_ARGCHK(g != NULL);
|
LTC_ARGCHK(g != NULL);
|
||||||
LTC_ARGCHK(ltc_mp.name != 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;
|
int err;
|
||||||
|
|
||||||
LTC_ARGCHK(key != NULL);
|
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(ltc_mp.name != NULL);
|
||||||
LTC_ARGCHK(dhparam != NULL);
|
LTC_ARGCHK(dhparam != NULL);
|
||||||
LTC_ARGCHK(dhparamlen > 0);
|
LTC_ARGCHK(dhparamlen > 0);
|
||||||
@ -102,10 +94,6 @@ int dh_set_pg_groupsize(int groupsize, dh_key *key)
|
|||||||
int err, i;
|
int err, i;
|
||||||
|
|
||||||
LTC_ARGCHK(key != NULL);
|
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(ltc_mp.name != NULL);
|
||||||
LTC_ARGCHK(groupsize > 0);
|
LTC_ARGCHK(groupsize > 0);
|
||||||
|
|
||||||
@ -142,10 +130,6 @@ int dh_set_key(const unsigned char *pub, unsigned long publen,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
LTC_ARGCHK(key != NULL);
|
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(ltc_mp.name != NULL);
|
||||||
|
|
||||||
if(priv == NULL) {
|
if(priv == NULL) {
|
||||||
|
@ -216,12 +216,6 @@ int dsa_generate_pqg(prng_state *prng, int wprng, int group_size, int modulus_si
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
LTC_ARGCHK(key != 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);
|
LTC_ARGCHK(ltc_mp.name != NULL);
|
||||||
|
|
||||||
/* init mp_ints */
|
/* init mp_ints */
|
||||||
|
@ -27,11 +27,6 @@ int dsa_make_key_ex(prng_state *prng, int wprng, dsa_key *key)
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
LTC_ARGCHK(key != 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(ltc_mp.name != NULL);
|
LTC_ARGCHK(ltc_mp.name != NULL);
|
||||||
|
|
||||||
/* so now we have our DH structure, generator g, order q, modulus p
|
/* so now we have our DH structure, generator g, order q, modulus p
|
||||||
|
@ -33,12 +33,6 @@ int dsa_set_pqg(const unsigned char *p, unsigned long plen,
|
|||||||
LTC_ARGCHK(q != NULL);
|
LTC_ARGCHK(q != NULL);
|
||||||
LTC_ARGCHK(g != NULL);
|
LTC_ARGCHK(g != NULL);
|
||||||
LTC_ARGCHK(key != 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);
|
LTC_ARGCHK(ltc_mp.name != NULL);
|
||||||
|
|
||||||
/* init key */
|
/* init key */
|
||||||
@ -80,12 +74,6 @@ int dsa_set_pqg_dsaparam(const unsigned char *dsaparam, unsigned long dsaparamle
|
|||||||
|
|
||||||
LTC_ARGCHK(dsaparam != NULL);
|
LTC_ARGCHK(dsaparam != NULL);
|
||||||
LTC_ARGCHK(key != 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);
|
LTC_ARGCHK(ltc_mp.name != NULL);
|
||||||
|
|
||||||
/* init key */
|
/* init key */
|
||||||
@ -130,11 +118,6 @@ int dsa_set_key(const unsigned char *pub, unsigned long publen,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
LTC_ARGCHK(key != 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(ltc_mp.name != NULL);
|
LTC_ARGCHK(ltc_mp.name != NULL);
|
||||||
|
|
||||||
if ((err = mp_read_unsigned_bin(key->y, (unsigned char *)pub , publen)) != CRYPT_OK) { goto LBL_ERR; }
|
if ((err = mp_read_unsigned_bin(key->y, (unsigned char *)pub , publen)) != CRYPT_OK) { goto LBL_ERR; }
|
||||||
|
@ -60,7 +60,7 @@ done:
|
|||||||
|
|
||||||
static int _dhparam_test(void)
|
static int _dhparam_test(void)
|
||||||
{
|
{
|
||||||
dh_key k = LTC_DH_KEY_INITIALIZER;
|
dh_key k;
|
||||||
unsigned char buf[1024];
|
unsigned char buf[1024];
|
||||||
/* generated by: openssl dhparam -outform der -out dhparam.der 2048 */
|
/* generated by: openssl dhparam -outform der -out dhparam.der 2048 */
|
||||||
unsigned char dhparam_der[] = {
|
unsigned char dhparam_der[] = {
|
||||||
@ -150,9 +150,7 @@ static int _dhparam_test(void)
|
|||||||
|
|
||||||
static int _set_test(void)
|
static int _set_test(void)
|
||||||
{
|
{
|
||||||
dh_key k1 = LTC_DH_KEY_INITIALIZER;
|
dh_key k1, k2, k3;
|
||||||
dh_key k2 = LTC_DH_KEY_INITIALIZER;
|
|
||||||
dh_key k3 = LTC_DH_KEY_INITIALIZER;
|
|
||||||
unsigned char buf[4096];
|
unsigned char buf[4096];
|
||||||
unsigned long len;
|
unsigned long len;
|
||||||
int i;
|
int i;
|
||||||
@ -368,8 +366,7 @@ static int _basic_test(void)
|
|||||||
unsigned char buf[3][4096];
|
unsigned char buf[3][4096];
|
||||||
unsigned long x, y, z;
|
unsigned long x, y, z;
|
||||||
int size;
|
int size;
|
||||||
dh_key usera = LTC_DH_KEY_INITIALIZER;
|
dh_key usera, userb;
|
||||||
dh_key userb = LTC_DH_KEY_INITIALIZER;
|
|
||||||
|
|
||||||
/* make up two keys */
|
/* make up two keys */
|
||||||
DO(dh_set_pg_groupsize(KEYSIZE/8, &usera));
|
DO(dh_set_pg_groupsize(KEYSIZE/8, &usera));
|
||||||
|
@ -131,7 +131,7 @@ static unsigned char dsaparam_der[] = {
|
|||||||
|
|
||||||
static int _dsa_compat_test(void)
|
static int _dsa_compat_test(void)
|
||||||
{
|
{
|
||||||
dsa_key key = LTC_DSA_KEY_INITIALIZER;
|
dsa_key key;
|
||||||
unsigned char tmp[1024], buf[1024];
|
unsigned char tmp[1024], buf[1024];
|
||||||
unsigned long x, len;
|
unsigned long x, len;
|
||||||
unsigned char key_parts[5][256];
|
unsigned char key_parts[5][256];
|
||||||
@ -251,8 +251,7 @@ int dsa_test(void)
|
|||||||
unsigned char msg[16], out[1024], out2[1024], ch;
|
unsigned char msg[16], out[1024], out2[1024], ch;
|
||||||
unsigned long x, y;
|
unsigned long x, y;
|
||||||
int stat1, stat2;
|
int stat1, stat2;
|
||||||
dsa_key key = LTC_DSA_KEY_INITIALIZER;
|
dsa_key key, key2;
|
||||||
dsa_key key2 = LTC_DSA_KEY_INITIALIZER;
|
|
||||||
|
|
||||||
DO(_dsa_compat_test());
|
DO(_dsa_compat_test());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user