Blob Blame History Raw
From 7046d670d3803d484b7af490e529dc4619145cc2 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Thu, 11 Feb 2016 13:52:20 +0100
Subject: [PATCH] diffie_hellman_sha256: convert bytes to bits

As otherwise we get far too small numbers.

CVE-2016-0787

Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 src/kex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/kex.c b/src/kex.c
index 5649248..f12797c 100644
--- a/src/kex.c
+++ b/src/kex.c
@@ -103,7 +103,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
         memset(&exchange_state->req_state, 0, sizeof(packet_require_state_t));
 
         /* Generate x and e */
-        _libssh2_bn_rand(exchange_state->x, group_order, 0, -1);
+        _libssh2_bn_rand(exchange_state->x, group_order * 8 - 1, 0, -1);
         _libssh2_bn_mod_exp(exchange_state->e, g, exchange_state->x, p,
                             exchange_state->ctx);
 
-- 
2.5.0