Commit b72b9e6a authored by Niels Möller's avatar Niels Möller
Browse files

Bug fixes.

Rev: src/publickey_crypto.c:1.12
parent a7a44140
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "publickey_crypto.h"
#include "atoms.h" #include "atoms.h"
#include "bignum.h" #include "bignum.h"
#include "crypto.h" #include "crypto.h"
...@@ -36,14 +38,6 @@ ...@@ -36,14 +38,6 @@
/* DSS signatures */ /* DSS signatures */
struct dss_public
{
mpz_t p;
mpz_t q;
mpz_t g;
mpz_t y;
};
struct dss_signer struct dss_signer
{ {
struct signer super; struct signer super;
...@@ -84,6 +78,8 @@ static struct lsh_string *do_dss_sign(struct signer *c, ...@@ -84,6 +78,8 @@ static struct lsh_string *do_dss_sign(struct signer *c,
struct dss_signer *closure = (struct dss_signer *) c; struct dss_signer *closure = (struct dss_signer *) c;
mpz_t k, r, s, tmp; mpz_t k, r, s, tmp;
struct lsh_string *signature; struct lsh_string *signature;
MDEBUG(closure);
/* Select k, 0<k<q, randomly */ /* Select k, 0<k<q, randomly */
mpz_init_set(tmp, closure->public.q); mpz_init_set(tmp, closure->public.q);
...@@ -138,13 +134,13 @@ static struct lsh_string *dss_public_key(struct signer *dss) ...@@ -138,13 +134,13 @@ static struct lsh_string *dss_public_key(struct signer *dss)
} }
#endif #endif
int do_dss_verify(struct verifier *c, static int do_dss_verify(struct verifier *c,
UINT32 length, UINT32 length,
UINT8 *msg, UINT8 *msg,
UINT32 signature_length, UINT32 signature_length,
UINT8 * signature_data) UINT8 * signature_data)
{ {
struct dss_signer *closure = (struct dss_signer *) c; struct dss_verifier *closure = (struct dss_verifier *) c;
struct simple_buffer buffer; struct simple_buffer buffer;
int res; int res;
...@@ -153,6 +149,8 @@ int do_dss_verify(struct verifier *c, ...@@ -153,6 +149,8 @@ int do_dss_verify(struct verifier *c,
mpz_t r, s; mpz_t r, s;
mpz_t w, tmp, v; mpz_t w, tmp, v;
MDEBUG(closure);
simple_buffer_init(&buffer, signature_length, signature_data); simple_buffer_init(&buffer, signature_length, signature_data);
if (!parse_atom(&buffer, &atom) if (!parse_atom(&buffer, &atom)
...@@ -218,10 +216,9 @@ int do_dss_verify(struct verifier *c, ...@@ -218,10 +216,9 @@ int do_dss_verify(struct verifier *c,
return !res; return !res;
} }
int parse_dss_public(struct simple_buffer *buffer, struct dss_public *public) static int parse_dss_public(struct simple_buffer *buffer, struct dss_public *public)
{ {
return (parse_bignum(buffer, public->p) return (parse_bignum(buffer, public->p)
&& parse_bignum(buffer, public->p)
&& (mpz_sgn(public->p) == 1) && (mpz_sgn(public->p) == 1)
&& parse_bignum(buffer, public->q) && parse_bignum(buffer, public->q)
&& (mpz_sgn(public->q) == 1) && (mpz_sgn(public->q) == 1)
...@@ -236,17 +233,21 @@ int parse_dss_public(struct simple_buffer *buffer, struct dss_public *public) ...@@ -236,17 +233,21 @@ int parse_dss_public(struct simple_buffer *buffer, struct dss_public *public)
/* FIXME: Outside of the protocol transactions, keys should be stored /* FIXME: Outside of the protocol transactions, keys should be stored
* in SPKI-style S-expressions. */ * in SPKI-style S-expressions. */
struct signer *make_dss_signer(struct signature_algorithm *closure, static struct signer *make_dss_signer(struct signature_algorithm *c,
UINT32 public_length, UINT32 public_length,
UINT8 *public, UINT8 *public,
UINT32 private_length, UINT32 private_length,
UINT8 *private) UINT8 *private)
{ {
struct dss_algorithm *closure = (struct dss_algorithm *) c;
struct dss_signer *res; struct dss_signer *res;
struct simple_buffer public_buffer; struct simple_buffer public_buffer;
struct simple_buffer private_buffer; struct simple_buffer private_buffer;
int atom; int atom;
MDEBUG(closure);
simple_buffer_init(&public_buffer, public_length, public); simple_buffer_init(&public_buffer, public_length, public);
if (!parse_atom(&public_buffer, &atom) if (!parse_atom(&public_buffer, &atom)
|| (atom != ATOM_SSH_DSS) ) || (atom != ATOM_SSH_DSS) )
...@@ -278,12 +279,14 @@ struct signer *make_dss_signer(struct signature_algorithm *closure, ...@@ -278,12 +279,14 @@ struct signer *make_dss_signer(struct signature_algorithm *closure,
} }
res->super.sign = do_dss_sign; res->super.sign = do_dss_sign;
res->random = closure->random;
return &res->super; return &res->super;
} }
struct verifier *make_dss_verifier(struct signature_algorithm *closure, static struct verifier *make_dss_verifier(struct signature_algorithm *closure,
UINT32 public_length, UINT32 public_length,
UINT8 *public) UINT8 *public)
{ {
struct dss_verifier *res; struct dss_verifier *res;
struct simple_buffer buffer; struct simple_buffer buffer;
...@@ -416,6 +419,7 @@ void init_diffie_hellman_instance(struct diffie_hellman_method *m, ...@@ -416,6 +419,7 @@ void init_diffie_hellman_instance(struct diffie_hellman_method *m,
c->literal_kexinits[CONNECTION_CLIENT] = NULL; c->literal_kexinits[CONNECTION_CLIENT] = NULL;
} }
#if 0
struct diffie_hellman_instance * struct diffie_hellman_instance *
make_diffie_hellman_instance(struct diffie_hellman_method *m, make_diffie_hellman_instance(struct diffie_hellman_method *m,
struct ssh_connection *c) struct ssh_connection *c)
...@@ -427,6 +431,7 @@ make_diffie_hellman_instance(struct diffie_hellman_method *m, ...@@ -427,6 +431,7 @@ make_diffie_hellman_instance(struct diffie_hellman_method *m,
return res; return res;
} }
#endif
struct diffie_hellman_method *make_dh1(struct randomness *r) struct diffie_hellman_method *make_dh1(struct randomness *r)
{ {
......
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