Commit 2ee5e341 authored by Niels Möller's avatar Niels Möller

Deleted class hash_algorithm.

Rev: ChangeLog:1.1035
Rev: src/algorithms.c:1.43
Rev: src/crypto.c:1.43
Rev: src/crypto.h:1.41
Rev: src/dh_exchange.c:1.24
Rev: src/keyexchange.c:1.103
Rev: src/keyexchange.h:1.64
Rev: src/lsh-export-key.c:1.25
Rev: src/lsh-transport.c:1.21
Rev: src/lshd.c:1.188
Rev: src/pkcs5-test.c:1.8
Rev: src/spki.c:1.66
Rev: src/spki.h:1.37
Rev: src/srp-gen.c:1.29
Rev: src/srp.h:1.10
Rev: src/srp_exchange.c:1.24
Rev: src/testsuite/md5-test.c:1.2
Rev: src/testsuite/sha1-test.c:1.2
Rev: src/testsuite/testutils.c:1.13
Rev: src/testsuite/testutils.h:1.10
Rev: src/transport.c:1.17
Rev: src/transport.h:1.13
parent 982a0798
2010-01-12 Niels Mller <nisse@lysator.liu.se>
* src/lshd-userauth.c (handle_password): New function, currently
untested and #if:ed out.
* src/crypto.h (hash_algorithm): Deleted class, just use the
corresponding struct nettle_hash.
2009-10-25 Niels Mller <nisse@lysator.liu.se>
* configure.ac: Updated URL for liboop, it's now
......
......@@ -63,9 +63,9 @@ all_symmetric_algorithms()
ATOM_3DES_CBC, &crypto_des3_cbc_algorithm,
ATOM_CAST128_CBC, &crypto_cast128_cbc_algorithm,
ATOM_HMAC_SHA1,
make_hmac_algorithm(&crypto_sha1_algorithm),
make_hmac_algorithm(&nettle_sha1),
ATOM_HMAC_MD5,
make_hmac_algorithm(&crypto_md5_algorithm),
make_hmac_algorithm(&nettle_md5),
#if WITH_ZLIB
ATOM_ZLIB, make_zlib(),
#endif
......
......@@ -563,25 +563,17 @@ hash_copy(struct hash_instance *self)
}
struct hash_instance *
make_hash(const struct hash_algorithm *self)
make_hash(const struct nettle_hash *algorithm)
{
NEW_VAR_OBJECT(hash_instance, instance,
HASH_INSTANCE_SIZE(self->type));
HASH_INSTANCE_SIZE(algorithm));
instance->type = self->type;
self->type->init(instance->ctx);
instance->type = algorithm;
algorithm->init(instance->ctx);
return instance;
}
const struct hash_algorithm
crypto_md5_algorithm =
{ STATIC_HEADER, &nettle_md5 };
const struct hash_algorithm
crypto_sha1_algorithm =
{ STATIC_HEADER, &nettle_sha1 };
/* HMAC */
/* GABA:
......@@ -650,17 +642,17 @@ make_hmac_instance(struct mac_algorithm *s,
}
struct mac_algorithm *
make_hmac_algorithm(const struct hash_algorithm *h)
make_hmac_algorithm(const struct nettle_hash *h)
{
NEW(hmac_algorithm, self);
self->super.mac_size = h->type->digest_size;
self->super.mac_size = h->digest_size;
/* Recommended in RFC-2104 */
self->super.key_size = h->type->digest_size;
self->super.key_size = h->digest_size;
self->super.make_mac = make_hmac_instance;
self->type = h->type;
self->type = h;
return &self->super;
}
......@@ -669,7 +661,7 @@ make_hmac_algorithm(const struct hash_algorithm *h)
/* Utility functions */
struct lsh_string *
hash_string_l(const struct hash_algorithm *a,
hash_string_l(const struct nettle_hash *a,
uint32_t length, const uint8_t *data)
{
struct hash_instance *hash = make_hash(a);
......@@ -684,7 +676,7 @@ hash_string_l(const struct hash_algorithm *a,
}
struct lsh_string *
hash_string(const struct hash_algorithm *a,
hash_string(const struct nettle_hash *a,
const struct lsh_string *in,
int free)
{
......
......@@ -102,7 +102,6 @@ extern struct crypto_algorithm crypto_twofish256_cbc_algorithm;
(ctx var-array char)))
*/
/* Happens to work for both hash_instance and hash_algorithm. */
#define HASH_SIZE(h) ((h)->type->digest_size)
void
......@@ -116,20 +115,8 @@ hash_digest_string(struct hash_instance *self);
struct hash_instance *
hash_copy(struct hash_instance *self);
/* FIXME: We don't need a class for this, we can just pass around a
pointer to the corresponding nettle_hash. */
/* GABA:
(class
(name hash_algorithm)
(vars
(type . "const struct nettle_hash *")))
*/
struct hash_instance *
make_hash(const struct hash_algorithm *self);
extern const struct hash_algorithm crypto_sha1_algorithm;
extern const struct hash_algorithm crypto_md5_algorithm;
make_hash(const struct nettle_hash *algorithm);
/* GABA:
(class
......@@ -165,7 +152,7 @@ MAC_DIGEST((instance), lsh_string_alloc((instance)->mac_size), 0)
#define MAKE_MAC(m, l, key) ((m)->make_mac((m), (l), (key)))
struct mac_algorithm *
make_hmac_algorithm(const struct hash_algorithm *h);
make_hmac_algorithm(const struct nettle_hash *algorithm);
/* 10 million iterations would take 5 hours on my machine */
#define PKCS5_MAX_ITERATIONS 10000000
......@@ -280,18 +267,18 @@ make_keypair(uint32_t type,
(modulo bignum)
; Generator for the multiplicative group of order modulo - 1
(generator bignum)
(H const object hash_algorithm)))
(H . "const struct nettle_hash *")))
*/
const struct dh_params *
make_dh_params(const char *modulo, unsigned generator,
const struct hash_algorithm *H);
const struct nettle_hash *H);
const struct dh_params *
make_dh_group1(const struct hash_algorithm *H);
make_dh_group1(const struct nettle_hash *H);
const struct dh_params *
make_dh_group14(const struct hash_algorithm *H);
make_dh_group14(const struct nettle_hash *H);
/* State common for both all DH variants, for both client and
server. */
......@@ -330,11 +317,11 @@ dh_hash_digest(struct dh_state *self);
/* Utility functions */
struct lsh_string *
hash_string_l(const struct hash_algorithm *a,
hash_string_l(const struct nettle_hash *a,
uint32_t length, const uint8_t *data);
struct lsh_string *
hash_string(const struct hash_algorithm *a,
hash_string(const struct nettle_hash *a,
const struct lsh_string *in,
int free);
......
......@@ -42,7 +42,7 @@
const struct dh_params *
make_dh_params(const char *modulo, unsigned generator,
const struct hash_algorithm *H)
const struct nettle_hash *H)
{
NEW(dh_params, self);
mpz_init_set_str(self->modulo, modulo, 16);
......@@ -56,7 +56,7 @@ make_dh_params(const char *modulo, unsigned generator,
/* The group for diffie-hellman-group1-sha1, also "Well known group 2"
in RFC 2412. */
const struct dh_params *
make_dh_group1(const struct hash_algorithm *H)
make_dh_group1(const struct nettle_hash *H)
{
/* 2^1024 - 2^960 - 1 + 2^64 * { [2^894 pi] + 129093 } */
return make_dh_params("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
......@@ -71,7 +71,7 @@ make_dh_group1(const struct hash_algorithm *H)
/* The group for diffie-hellman-group14-sha1, also "Well known group
14" in RFC 3526. */
const struct dh_params *
make_dh_group14(const struct hash_algorithm *H)
make_dh_group14(const struct nettle_hash *H)
{
/* 2^2048 - 2^1984 - 1 + 2^64 * { [2^1918 pi] + 124476 } */
return make_dh_params("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
......
......@@ -347,7 +347,7 @@ make_kexinit(struct kexinit_info *self)
/* Taking keys into use */
/* Returns a hash instance for generating various session keys. Consumes K. */
static struct hash_instance *
kex_build_secret(const struct hash_algorithm *H,
kex_build_secret(const struct nettle_hash *H,
struct lsh_string *exchange_hash,
struct lsh_string *K)
{
......@@ -567,7 +567,7 @@ kex_make_inflate(struct object_list *algorithms,
/* NOTE: Consumes K */
int
keyexchange_finish(struct transport_connection *connection,
const struct hash_algorithm *H,
const struct nettle_hash *H,
struct lsh_string *exchange_hash,
struct lsh_string *K)
{
......
......@@ -175,7 +175,7 @@ make_client_dh_exchange(const struct dh_params *params,
int
keyexchange_finish(struct transport_connection *connection,
const struct hash_algorithm *H,
const struct nettle_hash *H,
struct lsh_string *exchange_hash,
struct lsh_string *K);
......
......@@ -199,14 +199,14 @@ sexp_to_ssh2_key(struct lsh_string *expr,
{
struct lsh_string *hash
= ssh_format("%lfxS",
hash_string(&crypto_md5_algorithm, key, 0));
hash_string(&nettle_md5, key, 0));
struct lsh_string *output
= ssh_format("MD5 fingerprint: %lfS\n"
"Bubble Babble: %lfS\n",
lsh_string_colonize(hash, 2, 1),
lsh_string_bubblebabble(
hash_string(&crypto_sha1_algorithm, key, 0), 1));
hash_string(&nettle_sha1, key, 0), 1));
lsh_string_free(key);
return output;
}
......
......@@ -153,10 +153,10 @@ make_lsh_transport_config(void)
self->host_db = make_lsh_transport_lookup_verifier(self);
ALIST_SET(self->super.algorithms, ATOM_DIFFIE_HELLMAN_GROUP14_SHA1,
&make_client_dh_exchange(make_dh_group14(&crypto_sha1_algorithm),
&make_client_dh_exchange(make_dh_group14(&nettle_sha1),
&self->host_db->super)->super);
ALIST_SET(self->super.algorithms, ATOM_DIFFIE_HELLMAN_GROUP1_SHA1,
&make_client_dh_exchange(make_dh_group1(&crypto_sha1_algorithm),
&make_client_dh_exchange(make_dh_group1(&nettle_sha1),
&self->host_db->super)->super);
self->kex_algorithms =
make_int_list(2, ATOM_DIFFIE_HELLMAN_GROUP14_SHA1,
......@@ -907,7 +907,7 @@ read_user_key(struct lsh_transport_config *config)
(db object spki_context)
(access string)
; For fingerprinting
(hash const object hash_algorithm)))
(hash . "const struct nettle_hash *")))
*/
static struct verifier *
......@@ -1006,7 +1006,7 @@ lsh_transport_lookup_verifier(struct lookup_verifier *s,
fingerprint =
lsh_string_colonize(
ssh_format( "%lfxS",
hash_string_l(&crypto_md5_algorithm,
hash_string_l(&nettle_md5,
key_length, key)
),
2,
......@@ -1015,7 +1015,7 @@ lsh_transport_lookup_verifier(struct lookup_verifier *s,
babble =
lsh_string_bubblebabble(
hash_string_l(&crypto_sha1_algorithm,
hash_string_l(&nettle_sha1,
key_length, key),
1
);
......@@ -1083,7 +1083,7 @@ make_lsh_transport_lookup_verifier(struct lsh_transport_config *config)
self->config = config;
self->db = NULL;
self->access = NULL;
self->hash = &crypto_sha1_algorithm;
self->hash = &nettle_sha1;
return self;
}
......
......@@ -874,7 +874,7 @@ lshd_config_handler(int key, uint32_t value, const uint8_t *data,
ALIST_SET(ctx->super.algorithms,
ATOM_DIFFIE_HELLMAN_GROUP14_SHA1,
&make_server_dh_exchange(make_dh_group14(&crypto_sha1_algorithm),
&make_server_dh_exchange(make_dh_group14(&nettle_sha1),
ctx->keys)->super);
hostkey_algorithms
......
......@@ -80,7 +80,7 @@ int main(int argc, char **argv)
key = alloca(length);
pkcs5_derive_key(make_hmac_algorithm(&crypto_sha1_algorithm),
pkcs5_derive_key(make_hmac_algorithm(&nettle_sha1),
strlen(password), password,
strlen(salt), salt,
iterations,
......
......@@ -191,7 +191,7 @@ spki_make_signer(struct alist *algorithms,
}
struct lsh_string *
spki_hash_data(const struct hash_algorithm *algorithm,
spki_hash_data(const struct nettle_hash *algorithm,
int algorithm_name,
uint32_t length, uint8_t *data)
{
......
......@@ -62,7 +62,7 @@ spki_make_signer(struct alist *algorithms,
int *algorithm_name);
struct lsh_string *
spki_hash_data(const struct hash_algorithm *algorithm,
spki_hash_data(const struct nettle_hash *algorithm,
int algorithm_name,
uint32_t length, uint8_t *data);
......
......@@ -71,7 +71,7 @@ const char *argp_program_bug_address = BUG_ADDRESS;
(vars
(e object exception_handler)
(G const object zn_group)
(H const object hash_algorithm)
(H "const struct nettle_hash *")
(file string)
(dest . int)
......@@ -89,7 +89,7 @@ make_srp_gen_options(struct exception_handler *e)
self->e = e;
self->G = make_ssh_ring_srp_1();
self->H = &crypto_sha1_algorithm;
self->H = &nettle_sha1;
self->file = NULL;
self->dest = -1
......
......@@ -49,14 +49,14 @@ make_srp_entry(const struct lsh_string *name,
/* Consumes the salt */
struct lsh_string *
srp_make_verifier(const struct zn_group *G,
const struct hash_algorithm *H,
const struct nettle_hash *H,
struct lsh_string *salt,
struct lsh_string *name,
struct lsh_string *passwd);
void
srp_hash_password(mpz_t x,
const struct hash_algorithm *H,
const struct nettle_hash *H,
struct lsh_string *salt,
struct lsh_string *name,
struct lsh_string *passwd);
......
......@@ -99,7 +99,7 @@ make_srp_entry(const struct lsh_string *name,
/* Consumes the salt */
struct lsh_string *
srp_make_verifier(const struct zn_group *G,
const struct hash_algorithm *H,
const struct nettle_hash *H,
struct lsh_string *salt,
struct lsh_string *name,
struct lsh_string *passwd)
......@@ -125,7 +125,7 @@ srp_make_verifier(const struct zn_group *G,
void
srp_hash_password(mpz_t x,
const struct hash_algorithm *H,
const struct nettle_hash *H,
struct lsh_string *salt,
struct lsh_string *name,
struct lsh_string *passwd)
......@@ -423,7 +423,7 @@ struct dh_method *
make_srp1(struct randomness *r)
{
return make_dh(make_ssh_ring_srp_1(),
&crypto_sha1_algorithm, r);
&nettle_sha1, r);
}
#endif /* WITH_SRP */
......@@ -4,34 +4,34 @@ int
test_main(void)
{
struct mac_algorithm *hmac
= make_hmac_algorithm(&crypto_md5_algorithm);
= make_hmac_algorithm(&nettle_md5);
/* Test vectors from RFC 1321 */
test_hash("MD5-1", &crypto_md5_algorithm,
test_hash("MD5-1", &nettle_md5,
S(""),
H("D41D8CD98F00B204 E9800998ECF8427E"));
test_hash("MD5-2", &crypto_md5_algorithm,
test_hash("MD5-2", &nettle_md5,
S("a"),
H("0CC175B9C0F1B6A8 31C399E269772661"));
test_hash("MD5-3", &crypto_md5_algorithm,
test_hash("MD5-3", &nettle_md5,
S("abc"),
H("900150983cd24fb0 D6963F7D28E17F72"));
test_hash("MD5-4", &crypto_md5_algorithm,
test_hash("MD5-4", &nettle_md5,
S("message digest"),
H("F96B697D7CB7938D 525A2F31AAF161D0"));
test_hash("MD5-5", &crypto_md5_algorithm,
test_hash("MD5-5", &nettle_md5,
S("abcdefghijklmnopqrstuvwxyz"),
H("C3FCD3D76192E400 7DFB496CCA67E13B"));
test_hash("MD5-6", &crypto_md5_algorithm,
test_hash("MD5-6", &nettle_md5,
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
H("D174AB98D277D9F5 A5611C2C9F419D9F"));
test_hash("MD5-7", &crypto_md5_algorithm,
test_hash("MD5-7", &nettle_md5,
S("1234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890"),
H("57EDF4A22BE3C955 AC49DA2E2107B67A"));
......
......@@ -4,9 +4,9 @@ int
test_main(void)
{
struct mac_algorithm *hmac
= make_hmac_algorithm(&crypto_sha1_algorithm);
= make_hmac_algorithm(&nettle_sha1);
test_hash("SHA1", &crypto_sha1_algorithm,
test_hash("SHA1", &nettle_sha1,
S("abc"),
H("A9993E364706816A BA3E25717850C26C 9CD0D89D"));
......
......@@ -144,7 +144,7 @@ test_cipher(const char *name, struct crypto_algorithm *algorithm,
void
test_hash(const char *name,
const struct hash_algorithm *algorithm,
const struct nettle_hash *algorithm,
const struct lsh_string *data,
const struct lsh_string *digest)
{
......
......@@ -33,7 +33,7 @@ test_cipher(const char *name, struct crypto_algorithm *algorithm,
void
test_hash(const char *name,
const struct hash_algorithm *algorithm,
const struct nettle_hash *algorithm,
const struct lsh_string *data,
const struct lsh_string *digest);
......
......@@ -770,7 +770,7 @@ transport_send_kexinit(struct transport_connection *connection)
void
transport_keyexchange_finish(struct transport_connection *connection,
const struct hash_algorithm *H,
const struct nettle_hash *H,
struct lsh_string *exchange_hash,
struct lsh_string *K)
{
......
......@@ -294,7 +294,7 @@ transport_send_kexinit(struct transport_connection *connection);
void
transport_keyexchange_finish(struct transport_connection *connection,
const struct hash_algorithm *H,
const struct nettle_hash *H,
struct lsh_string *exchange_hash,
struct lsh_string *K);
......
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