[openssh-commits] [openssh] 01/05: upstream commit

git+noreply at mindrot.org git+noreply at mindrot.org
Fri Jan 30 12:19:36 AEDT 2015


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 25f5f78d8bf5c22d9cea8b49de24ebeee648a355
Author: djm at openbsd.org <djm at openbsd.org>
Date:   Fri Jan 30 00:22:25 2015 +0000

    upstream commit
    
    fix ssh protocol 1, spotted by miod@
---
 kex.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/kex.c b/kex.c
index 7eb3185..2618e22 100644
--- a/kex.c
+++ b/kex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kex.c,v 1.104 2015/01/26 06:10:03 djm Exp $ */
+/* $OpenBSD: kex.c,v 1.105 2015/01/30 00:22:25 djm Exp $ */
 /*
  * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
  *
@@ -785,17 +785,27 @@ int
 derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus,
     u_int8_t cookie[8], u_int8_t id[16])
 {
-	u_int8_t nbuf[2048], obuf[SSH_DIGEST_MAX_LENGTH];
+	u_int8_t hbuf[2048], sbuf[2048], obuf[SSH_DIGEST_MAX_LENGTH];
 	struct ssh_digest_ctx *hashctx = NULL;
-	size_t len;
+	size_t hlen, slen;
 	int r;
 
-	len = BN_num_bytes(host_modulus);
-	if (len < (512 / 8) || (u_int)len > sizeof(nbuf))
+	hlen = BN_num_bytes(host_modulus);
+	slen = BN_num_bytes(server_modulus);
+	if (hlen < (512 / 8) || (u_int)hlen > sizeof(hbuf) ||
+	    slen < (512 / 8) || (u_int)slen > sizeof(sbuf))
 		return SSH_ERR_KEY_BITS_MISMATCH;
-	if (BN_bn2bin(host_modulus, nbuf) <= 0 ||
-	    (hashctx = ssh_digest_start(SSH_DIGEST_MD5)) == NULL ||
-	    ssh_digest_update(hashctx, nbuf, len) != 0 ||
+	if (BN_bn2bin(host_modulus, hbuf) <= 0 ||
+	    BN_bn2bin(server_modulus, sbuf) <= 0) {
+		r = SSH_ERR_LIBCRYPTO_ERROR;
+		goto out;
+	}
+	if ((hashctx = ssh_digest_start(SSH_DIGEST_MD5)) == NULL) {
+		r = SSH_ERR_ALLOC_FAIL;
+		goto out;
+	}
+	if (ssh_digest_update(hashctx, hbuf, hlen) != 0 ||
+	    ssh_digest_update(hashctx, sbuf, slen) != 0 ||
 	    ssh_digest_update(hashctx, cookie, 8) != 0 ||
 	    ssh_digest_final(hashctx, obuf, sizeof(obuf)) != 0) {
 		r = SSH_ERR_LIBCRYPTO_ERROR;
@@ -805,7 +815,8 @@ derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus,
 	r = 0;
  out:
 	ssh_digest_free(hashctx);
-	explicit_bzero(nbuf, sizeof(nbuf));
+	explicit_bzero(hbuf, sizeof(hbuf));
+	explicit_bzero(sbuf, sizeof(sbuf));
 	explicit_bzero(obuf, sizeof(obuf));
 	return r;
 }

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list