summaryrefslogtreecommitdiff
path: root/kexgexc.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2005-11-05 15:19:35 +1100
committerDamien Miller <djm@mindrot.org>2005-11-05 15:19:35 +1100
commit19bb3a57f88adc789d61964fcb8f50165026b322 (patch)
treeba18e185c014c1da12ce4422a7e7bad9e71725f5 /kexgexc.c
parent24ecf612614d83622d9777349b4ecd21ee22bb2a (diff)
- djm@cvs.openbsd.org 2005/11/04 05:15:59
[kex.c kex.h kexdh.c kexdhc.c kexdhs.c kexgex.c kexgexc.c kexgexs.c] remove hardcoded hash lengths in key exchange code, allowing implementation of KEX methods with different hashes (e.g. SHA-256); ok markus@ dtucker@ stevesk@
Diffstat (limited to 'kexgexc.c')
-rw-r--r--kexgexc.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/kexgexc.c b/kexgexc.c
index 0193183b..a6ff8757 100644
--- a/kexgexc.c
+++ b/kexgexc.c
@@ -24,7 +24,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: kexgexc.c,v 1.2 2003/12/08 11:00:47 markus Exp $");
+RCSID("$OpenBSD: kexgexc.c,v 1.3 2005/11/04 05:15:59 djm Exp $");
#include "xmalloc.h"
#include "key.h"
@@ -42,7 +42,7 @@ kexgex_client(Kex *kex)
BIGNUM *p = NULL, *g = NULL;
Key *server_host_key;
u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL;
- u_int klen, kout, slen, sbloblen;
+ u_int klen, kout, slen, sbloblen, hashlen;
int min, max, nbits;
DH *dh;
@@ -155,7 +155,8 @@ kexgex_client(Kex *kex)
min = max = -1;
/* calc and verify H */
- hash = kexgex_hash(
+ kexgex_hash(
+ kex->evp_md,
kex->client_version_string,
kex->server_version_string,
buffer_ptr(&kex->my), buffer_len(&kex->my),
@@ -165,25 +166,27 @@ kexgex_client(Kex *kex)
dh->p, dh->g,
dh->pub_key,
dh_server_pub,
- shared_secret
+ shared_secret,
+ &hash, &hashlen
);
+
/* have keys, free DH */
DH_free(dh);
xfree(server_host_key_blob);
BN_clear_free(dh_server_pub);
- if (key_verify(server_host_key, signature, slen, hash, 20) != 1)
+ if (key_verify(server_host_key, signature, slen, hash, hashlen) != 1)
fatal("key_verify failed for server_host_key");
key_free(server_host_key);
xfree(signature);
/* save session id */
if (kex->session_id == NULL) {
- kex->session_id_len = 20;
+ kex->session_id_len = hashlen;
kex->session_id = xmalloc(kex->session_id_len);
memcpy(kex->session_id, hash, kex->session_id_len);
}
- kex_derive_keys(kex, hash, shared_secret);
+ kex_derive_keys(kex, hash, hashlen, shared_secret);
BN_clear_free(shared_secret);
kex_finish(kex);