diff options
author | Darren Tucker <dtucker@zip.com.au> | 2004-05-13 16:30:44 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2004-05-13 16:30:44 +1000 |
commit | e14e005f41cf541017ab4e285f0b2ec23a21b7ff (patch) | |
tree | dc39d17aec412258454cf026c2c3e27cf1b45411 /kex.c | |
parent | 770fc01078ffd4952ceb91f617063b390730499c (diff) |
- djm@cvs.openbsd.org 2004/05/09 01:19:28
[OVERVIEW auth-rsa.c auth1.c kex.c monitor.c session.c sshconnect1.c
sshd.c] removed: mpaux.c mpaux.h
kill some more tiny files; ok deraadt@
Diffstat (limited to 'kex.c')
-rw-r--r-- | kex.c | 35 |
1 files changed, 34 insertions, 1 deletions
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: kex.c,v 1.56 2003/11/21 11:57:03 djm Exp $"); | 26 | RCSID("$OpenBSD: kex.c,v 1.57 2004/05/09 01:19:27 djm Exp $"); |
27 | 27 | ||
28 | #include <openssl/crypto.h> | 28 | #include <openssl/crypto.h> |
29 | 29 | ||
@@ -479,6 +479,39 @@ kex_get_newkeys(int mode) | |||
479 | return ret; | 479 | return ret; |
480 | } | 480 | } |
481 | 481 | ||
482 | void | ||
483 | derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus, | ||
484 | u_int8_t cookie[8], u_int8_t id[16]) | ||
485 | { | ||
486 | const EVP_MD *evp_md = EVP_md5(); | ||
487 | EVP_MD_CTX md; | ||
488 | u_int8_t nbuf[2048], obuf[EVP_MAX_MD_SIZE]; | ||
489 | int len; | ||
490 | |||
491 | EVP_DigestInit(&md, evp_md); | ||
492 | |||
493 | len = BN_num_bytes(host_modulus); | ||
494 | if (len < (512 / 8) || len > sizeof(nbuf)) | ||
495 | fatal("%s: bad host modulus (len %d)", __func__, len); | ||
496 | BN_bn2bin(host_modulus, nbuf); | ||
497 | EVP_DigestUpdate(&md, nbuf, len); | ||
498 | |||
499 | len = BN_num_bytes(server_modulus); | ||
500 | if (len < (512 / 8) || len > sizeof(nbuf)) | ||
501 | fatal("%s: bad server modulus (len %d)", __func__, len); | ||
502 | BN_bn2bin(server_modulus, nbuf); | ||
503 | EVP_DigestUpdate(&md, nbuf, len); | ||
504 | |||
505 | EVP_DigestUpdate(&md, cookie, 8); | ||
506 | |||
507 | EVP_DigestFinal(&md, id, NULL); | ||
508 | memcpy(id, obuf, 16); | ||
509 | |||
510 | memset(nbuf, 0, sizeof(nbuf)); | ||
511 | memset(obuf, 0, sizeof(obuf)); | ||
512 | memset(&md, 0, sizeof(md)); | ||
513 | } | ||
514 | |||
482 | #if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) | 515 | #if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) |
483 | void | 516 | void |
484 | dump_digest(char *msg, u_char *digest, int len) | 517 | dump_digest(char *msg, u_char *digest, int len) |