Commit 38edca97 authored by Niels Möller's avatar Niels Möller

New functions dsa_params_init and dsa_params_clear.

parent 5549b2f4
2014-03-26 Niels Möller <nisse@lysator.liu.se> 2014-03-26 Niels Möller <nisse@lysator.liu.se>
* dsa.c (dsa_params_init, dsa_params_clear): New functions.
(dsa_public_key_init): Use dsa_params_init.
(dsa_public_key_clear): Use dsa_params_clear.
* sexp2dsa.c (dsa_keypair_from_sexp_alist): Converted to new DSA * sexp2dsa.c (dsa_keypair_from_sexp_alist): Converted to new DSA
interface. Allow q_size == 0, meaning any q < p is allowed. interface. Allow q_size == 0, meaning any q < p is allowed.
Additional validity checks. Additional validity checks.
......
...@@ -31,21 +31,33 @@ ...@@ -31,21 +31,33 @@
#include "bignum.h" #include "bignum.h"
void
dsa_params_init (struct dsa_params *params)
{
mpz_init(params->p);
mpz_init(params->q);
mpz_init(params->g);
}
void
dsa_params_clear (struct dsa_params *params)
{
mpz_clear(params->p);
mpz_clear(params->q);
mpz_clear(params->g);
}
void void
dsa_public_key_init(struct dsa_public_key *key) dsa_public_key_init(struct dsa_public_key *key)
{ {
mpz_init(key->p); dsa_params_init ((struct dsa_params *) key);
mpz_init(key->q);
mpz_init(key->g);
mpz_init(key->y); mpz_init(key->y);
} }
void void
dsa_public_key_clear(struct dsa_public_key *key) dsa_public_key_clear(struct dsa_public_key *key)
{ {
mpz_clear(key->p); dsa_params_clear ((struct dsa_params *) key);
mpz_clear(key->q);
mpz_clear(key->g);
mpz_clear(key->y); mpz_clear(key->y);
} }
......
...@@ -38,6 +38,8 @@ extern "C" { ...@@ -38,6 +38,8 @@ extern "C" {
#endif #endif
/* Name mangling */ /* Name mangling */
#define dsa_params_init nettle_dsa_params_init
#define dsa_params_clear nettle_dsa_params_clear
#define dsa_public_key_init nettle_dsa_public_key_init #define dsa_public_key_init nettle_dsa_public_key_init
#define dsa_public_key_clear nettle_dsa_public_key_clear #define dsa_public_key_clear nettle_dsa_public_key_clear
#define dsa_private_key_init nettle_dsa_private_key_init #define dsa_private_key_init nettle_dsa_private_key_init
...@@ -87,6 +89,12 @@ struct dsa_params ...@@ -87,6 +89,12 @@ struct dsa_params
mpz_t g; mpz_t g;
}; };
void
dsa_params_init (struct dsa_params *params);
void
dsa_params_clear (struct dsa_params *params);
struct dsa_public_key struct dsa_public_key
{ {
/* Modulo */ /* Modulo */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment