From 61279f1fb6c38649f5bfc2f4c0cf8c68ebb1e74a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 7 Jun 2013 01:03:03 +0200 Subject: [PATCH] [feature/elliptic-curve] Add comment for generator 2 and sha1 hash function. --- phpseclib/Net/SSH2.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 2807f839..9fb29c7c 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -1180,11 +1180,11 @@ class Net_SSH2 { break; } - $kexHash = new Crypt_Hash('sha1'); - $keyLength = min($keyLength, $kexHash->getLength()); - + // For both diffie-hellman-group1-sha1 and diffie-hellman-group14-sha1 + // the generator field element is 2 (decimal) and the hash function is sha1. $g = new Math_BigInteger(2); $prime = new Math_BigInteger($prime, 16); + $kexHash = new Crypt_Hash('sha1'); //$q = $p->bitwise_rightShift(1); /* To increase the speed of the key exchange, both client and server may @@ -1195,6 +1195,7 @@ class Net_SSH2 { -- http://tools.ietf.org/html/rfc4419#section-6.2 */ $one = new Math_BigInteger(1); + $keyLength = min($keyLength, $kexHash->getLength()); $max = $one->bitwise_leftShift(16 * $keyLength)->subtract($one); // 2 * 8 * $keyLength $x = $one->random($one, $max);