Commit ddb14d8e authored by Balázs Scheidler's avatar Balázs Scheidler Committed by Niels Möller
Browse files

* keyexchange.c (kex_make_key): Expand keys, when the required key

length is longer than tha hash output. (Baszi).

Rev: ChangeLog:1.17
Rev: src/keyexchange.c:1.36
parent 84740590
Mon Dec 28 14:14:57 1998 <nisse@puck>
* keyexchange.c (kex_make_key): Expand keys, when the required key
length is longer than tha hash output. (Baszi).
Sun Dec 27 06:37:40 1998 <nisse@puck>
* compress.c (packet_compressor): Removed the mode variable.
......
......@@ -342,12 +342,47 @@ static struct lsh_string *kex_make_key(struct hash_instance *secret,
HASH_UPDATE(hash, session_id->length, session_id->data);
HASH_DIGEST(hash, digest);
if (key_length > hash->hash_size)
fatal("Not implemented\n");
memcpy(key->data, digest, key_length);
#if 0
/* This is the simplest special case */
if (key_length <= hash->hash_size)
memcpy(key->data, digest, key_length);
#endif
{
/* FIXME: This code could probably be simplified a little, but
* it should do for now. */
int key_ofs, max;
max = MIN(key_length, hash->hash_size);
memcpy(key->data, digest, max);
if (max != key_length)
{
struct hash_instance *prev_hash = HASH_COPY(secret);
key_ofs = max;
while (key_length - key_ofs > 0)
{
KILL(hash);
hash = prev_hash;
HASH_UPDATE(hash, hash->hash_size, digest);
KILL(prev_hash);
prev_hash = HASH_COPY(hash);
HASH_DIGEST(hash, digest);
max = MIN(key_length - key_ofs, hash->hash_size);
memcpy(key->data + key_ofs, digest, max);
key_ofs += max;
}
KILL(prev_hash);
}
}
KILL(hash);
debug("Expanded key: ", type);
debug_hex(key->length, key->data);
return key;
}
......
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