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

Renamed dss->dsa.

Rev: src/dsa_keygen.c:1.5
Rev: src/dsa_keygen.h:1.2
Rev: src/lsh.c:1.39
Rev: src/lsh_keygen.c:1.9
Rev: src/lsh_writekey.c:1.3
Rev: src/lshd.c:1.33
Rev: src/publickey_crypto.c:1.23
Rev: src/publickey_crypto.h:1.15
parent 19f56b89
/* dss_keygen.c
/* dsa_keygen.c
*
* Generate dss key pairs..
* Generate dsa key pairs..
*
* $Id$
*/
......@@ -24,7 +24,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dss_keygen.h"
#include "dsa_keygen.h"
#include "randomness.h"
......@@ -56,7 +56,7 @@ static void hash(mpz_t x, UINT8 *digest)
sha_digest(&ctx, digest);
}
void dss_nist_gen(mpz_t p, mpz_t q, struct randomness *r, unsigned l)
void dsa_nist_gen(mpz_t p, mpz_t q, struct randomness *r, unsigned l)
{
unsigned L;
unsigned n, b;
......@@ -145,7 +145,7 @@ void dss_nist_gen(mpz_t p, mpz_t q, struct randomness *r, unsigned l)
}
}
void dss_find_generator(mpz_t g, struct randomness *r, mpz_t p, mpz_t q)
void dsa_find_generator(mpz_t g, struct randomness *r, mpz_t p, mpz_t q)
{
mpz_t e;
mpz_t n;
......
/* dss_keygen.h
/* dsa_keygen.h
*
* Generate dss key pairs..
* Generate dsa key pairs..
*
* $Id$
*/
......@@ -29,7 +29,7 @@
#include "bignum.h"
void dss_nist_gen(mpz_t p, mpz_t q, struct randomness *r, unsigned l);
void dss_find_generator(mpz_t g, struct randomness *r, mpz_t p, mpz_t q);
void dsa_nist_gen(mpz_t p, mpz_t q, struct randomness *r, unsigned l);
void dsa_find_generator(mpz_t g, struct randomness *r, mpz_t p, mpz_t q);
#endif /* LSH_DSS_KEYGEN_H_INCLUDED */
......@@ -140,12 +140,12 @@ int main(int argc, char **argv)
dh = make_dh1(r);
/* No randomness is needed for verifying signatures */
lookup = make_fake_host_db(make_dss_algorithm(NULL));
lookup = make_fake_host_db(make_dsa_algorithm(NULL));
kex = make_dh_client(dh, lookup);
algorithms = many_algorithms(2,
ATOM_DIFFIE_HELLMAN_GROUP1_SHA1, kex,
ATOM_SSH_DSS, make_dss_algorithm(r),
ATOM_SSH_DSS, make_dsa_algorithm(r),
-1);
not = 0;
......
......@@ -26,7 +26,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dss_keygen.h"
#include "dsa_keygen.h"
#include "blocking_write.h"
#include "crypto.h"
......@@ -48,7 +48,7 @@ static void usage(void) NORETURN;
static void usage(void)
{
wwrite("Usage: lsh_keygen [-o style] [-l nist-level] [-a dss] [-q] [-d] [-v]\n");
wwrite("Usage: lsh_keygen [-o style] [-l nist-level] [-a dsa] [-q] [-d] [-v]\n");
exit(1);
}
......@@ -58,7 +58,7 @@ int main(int argc, char **argv)
long l = 4;
int style = SEXP_TRANSPORT;
struct dss_public public;
struct dsa_public public;
mpz_t x;
mpz_t t;
......@@ -84,9 +84,9 @@ int main(int argc, char **argv)
break;
}
case 'a':
if (strcmp(optarg, "dss"))
if (strcmp(optarg, "dsa"))
{
wwrite("lsh_keygen: Sorry, doesn't support any algorithm but dss.\n");
wwrite("lsh_keygen: Sorry, doesn't support any algorithm but dsa.\n");
usage();
}
break;
......@@ -132,7 +132,7 @@ int main(int argc, char **argv)
mpz_init(t);
r = make_poor_random(&sha_algorithm, NULL);
dss_nist_gen(public.p, public.q, r, l);
dsa_nist_gen(public.p, public.q, r, l);
debug_mpz(public.p);
debug("\n");
......@@ -159,7 +159,7 @@ int main(int argc, char **argv)
return 1;
}
dss_find_generator(public.g, r, public.p, public.q);
dsa_find_generator(public.g, r, public.p, public.q);
r = make_reasonably_random();
mpz_set(t, public.q);
......@@ -176,7 +176,7 @@ int main(int argc, char **argv)
struct lsh_string *key = sexp_format
(sexp_l(2, sexp_z("private-key"),
sexp_l(6, sexp_z("dss"),
sexp_l(6, sexp_z("dsa"),
sexp_l(2, sexp_z("p"), sexp_un(public.p), -1),
sexp_l(2, sexp_z("q"), sexp_un(public.q), -1),
sexp_l(2, sexp_z("g"), sexp_un(public.g), -1),
......
......@@ -45,7 +45,7 @@
/* FIXME: Should support encryption of the private key. */
static struct sexp *dss_private2public(struct sexp_iterator *i)
static struct sexp *dsa_private2public(struct sexp_iterator *i)
{
struct sexp *p;
struct sexp *q;
......@@ -83,7 +83,7 @@ static struct sexp *dss_private2public(struct sexp_iterator *i)
return NULL;
return sexp_l(2, sexp_z("public-key"),
sexp_l(5, sexp_z("dss"), p, q, g, y, -1), -1);
sexp_l(5, sexp_z("dsa"), p, q, g, y, -1), -1);
}
/* CLASS:
......@@ -112,16 +112,16 @@ static int do_write_key(struct sexp_handler *h, struct sexp *private)
}
e = SEXP_GET(i);
if (! (e && sexp_check_type(e, "dss", &i)))
if (! (e && sexp_check_type(e, "dsa", &i)))
{
werror("lsh_writekey: Unknown key type (only dss is supported)\n");
werror("lsh_writekey: Unknown key type (only dsa is supported)\n");
return LSH_FAIL | LSH_DIE;
}
public = dss_private2public(i);
public = dsa_private2public(i);
if (!public)
{
werror("lsh_writekey: Invalid dss key\n");
werror("lsh_writekey: Invalid dsa key\n");
return LSH_FAIL | LSH_DIE;
}
......
......@@ -127,7 +127,7 @@ static void init_host_key(struct randomness *r)
public_key = ssh_format("%a%n%n%n%n", ATOM_SSH_DSS, p, q, g, y);
s = ssh_format("%n", a);
secret_key = MAKE_SIGNER(make_dss_algorithm(r),
secret_key = MAKE_SIGNER(make_dsa_algorithm(r),
public_key->length, public_key->data,
s->length, s->data);
......@@ -171,9 +171,9 @@ static int do_read_key(struct sexp_handler *h, struct sexp *private)
}
e = SEXP_GET(i);
if (! (e && sexp_check_type(e, "dss", &i)))
if (! (e && sexp_check_type(e, "dsa", &i)))
{
werror("lshd: Unknown key type (only dss is supported)\n");
werror("lshd: Unknown key type (only dsa is supported)\n");
return LSH_FAIL | LSH_DIE;
}
......@@ -211,7 +211,7 @@ static int do_read_key(struct sexp_handler *h, struct sexp *private)
s = ssh_format("%n", x);
secret = MAKE_SIGNER(make_dss_algorithm(closure->random),
secret = MAKE_SIGNER(make_dsa_algorithm(closure->random),
public->length, public->data,
s->length, s->data);
assert(secret);
......@@ -323,7 +323,7 @@ int main(int argc, char **argv)
dh = make_dh1(r);
algorithms = many_algorithms(1,
ATOM_SSH_DSS, make_dss_algorithm(r),
ATOM_SSH_DSS, make_dsa_algorithm(r),
-1);
while(1)
......
......@@ -45,31 +45,31 @@
/* DSS signatures */
/* CLASS:
(class
(name dss_signer)
(name dsa_signer)
(super signer)
(vars
(random object randomness)
(public struct dss_public)
(public struct dsa_public)
(a bignum)))
*/
/* CLASS:
(class
(name dss_verifier)
(name dsa_verifier)
(super verifier)
(vars
(public struct dss_public)))
(public struct dsa_public)))
*/
/* CLASS:
(class
(name dss_algorithm)
(name dsa_algorithm)
(super signature_algorithm)
(vars
(random object randomness)))
*/
static void dss_hash(mpz_t h, UINT32 length, UINT8 *msg)
static void dsa_hash(mpz_t h, UINT32 length, UINT8 *msg)
{
/* Compute hash */
struct hash_instance *hash = MAKE_HASH(&sha_algorithm);
......@@ -86,11 +86,11 @@ static void dss_hash(mpz_t h, UINT32 length, UINT8 *msg)
KILL(hash);
}
static struct lsh_string *do_dss_sign(struct signer *c,
static struct lsh_string *do_dsa_sign(struct signer *c,
UINT32 length,
UINT8 *msg)
{
CAST(dss_signer, closure, c);
CAST(dsa_signer, closure, c);
mpz_t k, r, s, tmp;
struct lsh_string *signature;
......@@ -102,7 +102,7 @@ static struct lsh_string *do_dss_sign(struct signer *c,
bignum_random(k, closure->random, tmp);
mpz_add_ui(k, k, 1);
debug("do_dss_sign, k: ");
debug("do_dsa_sign, k: ");
debug_mpz(k);
debug("\n");
......@@ -110,23 +110,23 @@ static struct lsh_string *do_dss_sign(struct signer *c,
mpz_init(r);
mpz_powm(r, closure->public.g, k, closure->public.p);
debug("do_dss_sign, group element: ");
debug("do_dsa_sign, group element: ");
debug_mpz(r);
debug("\n");
mpz_fdiv_r(r, r, closure->public.q);
debug("do_dss_sign, r: ");
debug("do_dsa_sign, r: ");
debug_mpz(r);
debug("\n");
/* Compute hash */
dss_hash(tmp, length, msg);
dsa_hash(tmp, length, msg);
/* Compute k^-1 (mod q) */
if (!mpz_invert(k, k, closure->public.q))
{
werror("do_dss_sign: k non-invertible\n");
werror("do_dsa_sign: k non-invertible\n");
mpz_clear(tmp);
mpz_clear(k);
mpz_clear(r);
......@@ -141,7 +141,7 @@ static struct lsh_string *do_dss_sign(struct signer *c,
mpz_mul(s, s, k);
mpz_fdiv_r(s, s, closure->public.q);
debug("do_dss_sign, s: ");
debug("do_dsa_sign, s: ");
debug_mpz(s);
debug("\n");
......@@ -157,20 +157,20 @@ static struct lsh_string *do_dss_sign(struct signer *c,
}
#if 0
static struct lsh_string *dss_public_key(struct signer *dss)
static struct lsh_string *dsa_public_key(struct signer *dsa)
{
return ssh_format("%a%n%n%n%n",
ATOM_SSH_DSS, dss->p, dss->q, dss->g, dss->y);
ATOM_SSH_DSS, dsa->p, dsa->q, dsa->g, dsa->y);
}
#endif
static int do_dss_verify(struct verifier *c,
static int do_dsa_verify(struct verifier *c,
UINT32 length,
UINT8 *msg,
UINT32 signature_length,
UINT8 * signature_data)
{
CAST(dss_verifier, closure, c);
CAST(dsa_verifier, closure, c);
struct simple_buffer buffer;
int res;
......@@ -200,11 +200,11 @@ static int do_dss_verify(struct verifier *c,
return 0;
}
debug("do_dss_verify, r: ");
debug("do_dsa_verify, r: ");
debug_mpz(r);
debug("\n");
debug("do_dss_verify, s: ");
debug("do_dsa_verify, s: ");
debug_mpz(s);
debug("\n");
......@@ -214,20 +214,20 @@ static int do_dss_verify(struct verifier *c,
/* FIXME: mpz_invert generates negative inverses. Is this a problem? */
if (!mpz_invert(w, s, closure->public.q))
{
werror("do_dss_verify: s non-invertible.\n");
werror("do_dsa_verify: s non-invertible.\n");
mpz_clear(r);
mpz_clear(s);
mpz_clear(w);
return 0;
}
debug("do_dss_verify, w: ");
debug("do_dsa_verify, w: ");
debug_mpz(w);
debug("\n");
/* Compute hash */
mpz_init(tmp);
dss_hash(tmp, length, msg);
dsa_hash(tmp, length, msg);
/* g^{w * h (mod q)} (mod p) */
......@@ -256,13 +256,13 @@ static int do_dss_verify(struct verifier *c,
mpz_mul(v, v, tmp);
mpz_fdiv_r(v, v, closure->public.p);
debug("do_dss_verify, group element: ");
debug("do_dsa_verify, group element: ");
debug_mpz(v);
debug("\n");
mpz_fdiv_r(v, v, closure->public.q);
debug("do_dss_verify, v: ");
debug("do_dsa_verify, v: ");
debug_mpz(v);
debug("\n");
......@@ -277,8 +277,8 @@ static int do_dss_verify(struct verifier *c,
return !res;
}
static int parse_dss_public(struct simple_buffer *buffer,
struct dss_public *public)
static int parse_dsa_public(struct simple_buffer *buffer,
struct dsa_public *public)
{
return (parse_bignum(buffer, public->p)
&& (mpz_sgn(public->p) == 1)
......@@ -295,14 +295,14 @@ static int parse_dss_public(struct simple_buffer *buffer,
/* FIXME: Outside of the protocol transactions, keys should be stored
* in SPKI-style S-expressions. */
static struct signer *make_dss_signer(struct signature_algorithm *c,
static struct signer *make_dsa_signer(struct signature_algorithm *c,
UINT32 public_length,
UINT8 *public,
UINT32 private_length,
UINT8 *private)
{
CAST(dss_algorithm, closure, c);
NEW(dss_signer, res);
CAST(dsa_algorithm, closure, c);
NEW(dsa_signer, res);
struct simple_buffer public_buffer;
struct simple_buffer private_buffer;
......@@ -325,7 +325,7 @@ static struct signer *make_dss_signer(struct signature_algorithm *c,
}
simple_buffer_init(&private_buffer, private_length, private);
if (! (parse_dss_public(&public_buffer, &res->public)
if (! (parse_dsa_public(&public_buffer, &res->public)
&& parse_bignum(&private_buffer, res->a)
/* FIXME: Perhaps do some more sanity checks? */
&& (mpz_sgn(res->a) == 1)
......@@ -335,18 +335,18 @@ static struct signer *make_dss_signer(struct signature_algorithm *c,
return NULL;
}
res->super.sign = do_dss_sign;
res->super.sign = do_dsa_sign;
res->random = closure->random;
return &res->super;
}
static struct verifier *
make_dss_verifier(struct signature_algorithm *closure UNUSED,
make_dsa_verifier(struct signature_algorithm *closure UNUSED,
UINT32 public_length,
UINT8 *public)
{
NEW(dss_verifier, res);
NEW(dsa_verifier, res);
struct simple_buffer buffer;
int atom;
......@@ -365,26 +365,26 @@ make_dss_verifier(struct signature_algorithm *closure UNUSED,
return 0;
}
if (!parse_dss_public(&buffer, &res->public))
if (!parse_dsa_public(&buffer, &res->public))
/* FIXME: Perhaps do some more sanity checks? */
{
KILL(res);
return NULL;
}
res->super.verify = do_dss_verify;
res->super.verify = do_dsa_verify;
return &res->super;
}
struct signature_algorithm *make_dss_algorithm(struct randomness *random)
struct signature_algorithm *make_dsa_algorithm(struct randomness *random)
{
NEW(dss_algorithm, dss);
NEW(dsa_algorithm, dsa);
dss->super.make_signer = make_dss_signer;
dss->super.make_verifier = make_dss_verifier;
dss->random = random;
dsa->super.make_signer = make_dsa_signer;
dsa->super.make_verifier = make_dsa_verifier;
dsa->random = random;
return &dss->super;
return &dsa->super;
}
/* Groups */
......
......@@ -34,7 +34,7 @@
#include "publickey_crypto.h.x"
#undef CLASS_DECLARE
struct signature_algorithm *make_dss_algorithm(struct randomness *random);
struct signature_algorithm *make_dsa_algorithm(struct randomness *random);
/* FIXME: Groups could use "non-virtual" methods */
......@@ -63,7 +63,7 @@ struct group *make_zn(mpz_t p);
/* CLASS:
(struct
(name dss_public)
(name dsa_public)
(vars
(p bignum)
(q bignum)
......
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