Skip to content

Commit

Permalink
Compatibile with OpenSSH
Browse files Browse the repository at this point in the history
  • Loading branch information
nappa committed Dec 16, 2011
1 parent 4339264 commit 27a6556
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Expand Up @@ -19,7 +19,10 @@ class DiffieHellmanGroupExchangeSHA1 < DiffieHellmanGroup1SHA1

# Compute the number of bits needed for the given number of bytes.
def compute_need_bits
need_bits = data[:need_bytes] * 8

# for Compatibility: OpenSSH requires (need_bits * 2 + 1) length of parameter
need_bits = data[:need_bytes] * 8 * 2 + 1

if need_bits < MINIMUM_BITS
need_bits = MINIMUM_BITS
elsif need_bits > MAXIMUM_BITS
Expand Down Expand Up @@ -74,4 +77,4 @@ def build_signature_buffer(result)
end
end

end
end
4 changes: 2 additions & 2 deletions test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb
Expand Up @@ -18,7 +18,7 @@ def test_exchange_with_fewer_than_minimum_bits_uses_minimum_bits

def test_exchange_with_fewer_than_maximum_bits_uses_need_bits
dh_options :need_bytes => 500
need_bits(4000)
need_bits(8001)
assert_nothing_raised { exchange! }
end

Expand Down Expand Up @@ -89,4 +89,4 @@ def session_id
end
end

end; end
end; end

0 comments on commit 27a6556

Please sign in to comment.