diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2004-05-09 01:19:29 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2004-05-09 01:19:29 +0000 |
commit | d95927546926b8244039f8503acf1162f5ca6a2d (patch) | |
tree | 64e0ae9323f5119a95bc21f41bddb91fc6301446 /usr.bin/ssh/kex.c | |
parent | dd00845b7b8b459e705440fe64d4532988369743 (diff) |
kill some more tiny files; ok deraadt@
Diffstat (limited to 'usr.bin/ssh/kex.c')
-rw-r--r-- | usr.bin/ssh/kex.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/usr.bin/ssh/kex.c b/usr.bin/ssh/kex.c index 5a952c9c22d..30dd58a78e3 100644 --- a/usr.bin/ssh/kex.c +++ b/usr.bin/ssh/kex.c @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: kex.c,v 1.56 2003/11/21 11:57:03 djm Exp $"); +RCSID("$OpenBSD: kex.c,v 1.57 2004/05/09 01:19:27 djm Exp $"); #include <openssl/crypto.h> @@ -479,6 +479,39 @@ kex_get_newkeys(int mode) return ret; } +void +derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus, + u_int8_t cookie[8], u_int8_t id[16]) +{ + const EVP_MD *evp_md = EVP_md5(); + EVP_MD_CTX md; + u_int8_t nbuf[2048], obuf[EVP_MAX_MD_SIZE]; + int len; + + EVP_DigestInit(&md, evp_md); + + len = BN_num_bytes(host_modulus); + if (len < (512 / 8) || len > sizeof(nbuf)) + fatal("%s: bad host modulus (len %d)", __func__, len); + BN_bn2bin(host_modulus, nbuf); + EVP_DigestUpdate(&md, nbuf, len); + + len = BN_num_bytes(server_modulus); + if (len < (512 / 8) || len > sizeof(nbuf)) + fatal("%s: bad server modulus (len %d)", __func__, len); + BN_bn2bin(server_modulus, nbuf); + EVP_DigestUpdate(&md, nbuf, len); + + EVP_DigestUpdate(&md, cookie, 8); + + EVP_DigestFinal(&md, id, NULL); + memcpy(id, obuf, 16); + + memset(nbuf, 0, sizeof(nbuf)); + memset(obuf, 0, sizeof(obuf)); + memset(&md, 0, sizeof(md)); +} + #if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) void dump_digest(char *msg, u_char *digest, int len) |