034fe96
From 8a453a7b0f1e667b7369eb73b00843a8decdecc9 Mon Sep 17 00:00:00 2001
034fe96
From: Daniel Stenberg <daniel@haxx.se>
034fe96
Date: Thu, 11 Feb 2016 13:52:20 +0100
034fe96
Subject: [PATCH] diffie_hellman_sha256: convert bytes to bits
034fe96
034fe96
As otherwise we get far too small numbers.
034fe96
034fe96
CVE-2016-0787
034fe96
---
034fe96
 src/kex.c | 2 +-
034fe96
 1 file changed, 1 insertion(+), 1 deletion(-)
034fe96
034fe96
diff --git a/src/kex.c b/src/kex.c
034fe96
index 6349457..e89b36c 100644
034fe96
--- a/src/kex.c
034fe96
+++ b/src/kex.c
034fe96
@@ -751,11 +751,11 @@ static int diffie_hellman_sha256(LIBSSH2_SESSION *session,
034fe96
 
034fe96
         /* Zero the whole thing out */
034fe96
         memset(&exchange_state->req_state, 0, sizeof(packet_require_state_t));
034fe96
 
034fe96
         /* Generate x and e */
034fe96
-        _libssh2_bn_rand(exchange_state->x, group_order, 0, -1);
034fe96
+        _libssh2_bn_rand(exchange_state->x, group_order * 8 - 1, 0, -1);
034fe96
         _libssh2_bn_mod_exp(exchange_state->e, g, exchange_state->x, p,
034fe96
                             exchange_state->ctx);
034fe96
 
034fe96
         /* Send KEX init */
034fe96
         /* packet_type(1) + String Length(4) + leading 0(1) */
034fe96
-- 
034fe96
2.7.0
034fe96