summaryrefslogtreecommitdiff
path: root/kex.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-04-30 23:10:43 +0000
committerDamien Miller <djm@mindrot.org>2017-05-01 09:37:40 +1000
commit56912dea6ef63dae4eb1194e5d88973a7c6c5740 (patch)
treec0425585449d257a90a42efce5f602f7ce16779f /kex.c
parentd4084cd230f7319056559b00db8b99296dad49d5 (diff)
upstream commit
unifdef WITH_SSH1 ok markus@ Upstream-ID: 9716e62a883ef8826c57f4d33b4a81a9cc7755c7
Diffstat (limited to 'kex.c')
-rw-r--r--kex.c43
1 files changed, 1 insertions, 42 deletions
diff --git a/kex.c b/kex.c
index 98c0597a9..9a40759c1 100644
--- a/kex.c
+++ b/kex.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kex.c,v 1.131 2017/03/15 07:07:39 markus Exp $ */ 1/* $OpenBSD: kex.c,v 1.132 2017/04/30 23:10:43 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -980,47 +980,6 @@ kex_derive_keys_bn(struct ssh *ssh, u_char *hash, u_int hashlen,
980} 980}
981#endif 981#endif
982 982
983#ifdef WITH_SSH1
984int
985derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus,
986 u_int8_t cookie[8], u_int8_t id[16])
987{
988 u_int8_t hbuf[2048], sbuf[2048], obuf[SSH_DIGEST_MAX_LENGTH];
989 struct ssh_digest_ctx *hashctx = NULL;
990 size_t hlen, slen;
991 int r;
992
993 hlen = BN_num_bytes(host_modulus);
994 slen = BN_num_bytes(server_modulus);
995 if (hlen < (512 / 8) || (u_int)hlen > sizeof(hbuf) ||
996 slen < (512 / 8) || (u_int)slen > sizeof(sbuf))
997 return SSH_ERR_KEY_BITS_MISMATCH;
998 if (BN_bn2bin(host_modulus, hbuf) <= 0 ||
999 BN_bn2bin(server_modulus, sbuf) <= 0) {
1000 r = SSH_ERR_LIBCRYPTO_ERROR;
1001 goto out;
1002 }
1003 if ((hashctx = ssh_digest_start(SSH_DIGEST_MD5)) == NULL) {
1004 r = SSH_ERR_ALLOC_FAIL;
1005 goto out;
1006 }
1007 if (ssh_digest_update(hashctx, hbuf, hlen) != 0 ||
1008 ssh_digest_update(hashctx, sbuf, slen) != 0 ||
1009 ssh_digest_update(hashctx, cookie, 8) != 0 ||
1010 ssh_digest_final(hashctx, obuf, sizeof(obuf)) != 0) {
1011 r = SSH_ERR_LIBCRYPTO_ERROR;
1012 goto out;
1013 }
1014 memcpy(id, obuf, ssh_digest_bytes(SSH_DIGEST_MD5));
1015 r = 0;
1016 out:
1017 ssh_digest_free(hashctx);
1018 explicit_bzero(hbuf, sizeof(hbuf));
1019 explicit_bzero(sbuf, sizeof(sbuf));
1020 explicit_bzero(obuf, sizeof(obuf));
1021 return r;
1022}
1023#endif
1024 983
1025#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH) 984#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH)
1026void 985void