diff --git a/ChangeLog b/ChangeLog index 47c2068247622adb00def2f97430a54851e48472..9ce03388970259c918306ef5508226de7156dde0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2014-03-26 Niels Möller <nisse@lysator.liu.se> + * dsa2sexp.c (dsa_keypair_to_sexp): Converted to new DSA + interface. + * tools/pkcs1-conv.c: Updated uses of dsa_keypair_to_sexp. + * dsa.h (struct dsa_params): New struct. * dsa-sign.c (dsa_sign): Use struct dsa_params, with key as a diff --git a/dsa.h b/dsa.h index cc1a196128893334f0f0b28b2cf0b1b37b31e6e4..3232c60223135e53326130ffe04552491abeb72a 100644 --- a/dsa.h +++ b/dsa.h @@ -244,8 +244,9 @@ struct nettle_buffer; int dsa_keypair_to_sexp(struct nettle_buffer *buffer, const char *algorithm_name, /* NULL means "dsa" */ - const struct dsa_public_key *pub, - const struct dsa_private_key *priv); + const struct dsa_params *params, + const mpz_t pub, + const mpz_t priv); struct sexp_iterator; diff --git a/dsa2sexp.c b/dsa2sexp.c index 2fc6d29f45b9206a4ca9c3a845768d0a1488af10..03c93b1a375679a6ad42e04eda9244e3f431a865 100644 --- a/dsa2sexp.c +++ b/dsa2sexp.c @@ -4,7 +4,7 @@ /* nettle, low-level cryptographics library * - * Copyright (C) 2002, 2009 Niels Möller, Magnus Holmgren + * Copyright (C) 2002, 2009, 2014 Niels Möller, Magnus Holmgren * * The nettle library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -33,22 +33,24 @@ int dsa_keypair_to_sexp(struct nettle_buffer *buffer, const char *algorithm_name, - const struct dsa_public_key *pub, - const struct dsa_private_key *priv) + const struct dsa_params *params, + const mpz_t pub, + const mpz_t priv) { if (!algorithm_name) algorithm_name = "dsa"; - + if (priv) return sexp_format(buffer, "(private-key(%0s(p%b)(q%b)" "(g%b)(y%b)(x%b)))", - algorithm_name, pub->p, pub->q, - pub->g, pub->y, priv->x); + algorithm_name, params->p, params->q, + params->g, pub, priv); + else return sexp_format(buffer, "(public-key(%0s(p%b)(q%b)" "(g%b)(y%b)))", - algorithm_name, pub->p, pub->q, - pub->g, pub->y); + algorithm_name, params->p, params->q, + params->g, pub); } diff --git a/tools/pkcs1-conv.c b/tools/pkcs1-conv.c index 13b9ba05c156b5df8489ab3ddef470db8b2a81ff..1c73a97cefc62bd47a0b259e1481d564deb010ad 100644 --- a/tools/pkcs1-conv.c +++ b/tools/pkcs1-conv.c @@ -323,7 +323,9 @@ convert_dsa_private_key(struct nettle_buffer *buffer, size_t length, const uint8 { /* Reuses the buffer */ nettle_buffer_reset(buffer); - res = dsa_keypair_to_sexp(buffer, NULL, &pub, &priv); + res = dsa_keypair_to_sexp(buffer, NULL, + (const struct dsa_params *) &pub, + pub.y, priv.x); } else { @@ -413,7 +415,9 @@ convert_public_key(struct nettle_buffer *buffer, size_t length, const uint8_t *d && dsa_public_key_from_der_iterator(&pub, 0, &j)) { nettle_buffer_reset(buffer); - res = dsa_keypair_to_sexp(buffer, NULL, &pub, NULL) > 0; + res = dsa_keypair_to_sexp(buffer, NULL, + (const struct dsa_params *) &pub, + pub.y, NULL) > 0; } dsa_public_key_clear(&pub); }