Skip to content

Commit

Permalink
Fix unit tests for OpenSSL 3
Browse files Browse the repository at this point in the history
  • Loading branch information
fwininger committed Apr 29, 2022
1 parent 78948d1 commit aca76f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions test/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ def P(*args)
Net::SSH::Packet.new(Net::SSH::Buffer.from(*args))
end

# DH key generate with OpenSSL::PKey::DH.new(512).to_pem
def dh_512bits_bn
OpenSSL::PKey::DH.new(
<<~DH_KEY
-----BEGIN DH PARAMETERS-----
MEYCQQDkZMgCTieW40x/bmCpf6m1XHERNnyOodot21UsJkCidr+T6aAcy/Oz4mWo
aYudmZZLQz7jhz0Ut2VQUw0Nz033AgEC
-----END DH PARAMETERS-----
DH_KEY
).p
end

class NetSSHTest < Minitest::Test
def assert_nothing_raised(&block)
yield
Expand Down
2 changes: 1 addition & 1 deletion test/transport/kex/test_diffie_hellman_group1_sha1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def packet_data
end

def server_dh_pubkey
@server_dh_pubkey ||= bn(1234567890)
@server_dh_pubkey ||= OpenSSL::BN.new(dh_512bits_bn, 10)
end

def shared_secret
Expand Down
2 changes: 1 addition & 1 deletion test/transport/test_algorithms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def install_mock_algorithm_lookups(options = {})
end

def shared_secret
@shared_secret ||= OpenSSL::BN.new("1234567890", 10)
@shared_secret ||= dh_512bits_bn
end

def session_id
Expand Down

0 comments on commit aca76f4

Please sign in to comment.