diff --git a/lib/openssl/pkey.rb b/lib/openssl/pkey.rb index 1aa22bfee..3d1e8885c 100644 --- a/lib/openssl/pkey.rb +++ b/lib/openssl/pkey.rb @@ -42,7 +42,7 @@ def public_key # The hash has keys 'p', 'q', 'g', 'pub_key', and 'priv_key'. def params %w{p q g pub_key priv_key}.map { |name| - [name, send(name) || 0.to_bn] + [name, send(name)] }.to_h end @@ -174,7 +174,7 @@ def public_key # The hash has keys 'p', 'q', 'g', 'pub_key', and 'priv_key'. def params %w{p q g pub_key priv_key}.map { |name| - [name, send(name) || 0.to_bn] + [name, send(name)] }.to_h end @@ -360,7 +360,7 @@ def public_key # The hash has keys 'n', 'e', 'd', 'p', 'q', 'dmp1', 'dmq1', and 'iqmp'. def params %w{n e d p q dmp1 dmq1 iqmp}.map { |name| - [name, send(name) || 0.to_bn] + [name, send(name)] }.to_h end diff --git a/test/openssl/test_pkey_dh.rb b/test/openssl/test_pkey_dh.rb index 88c3d674e..cec1e6301 100644 --- a/test/openssl/test_pkey_dh.rb +++ b/test/openssl/test_pkey_dh.rb @@ -138,9 +138,9 @@ def test_params assert_not_nil dh.g assert_equal dh.g, dh.params["g"] assert_nil dh.pub_key - assert_equal 0, dh.params["pub_key"] + assert_nil dh.params["pub_key"] assert_nil dh.priv_key - assert_equal 0, dh.params["priv_key"] + assert_nil dh.params["priv_key"] dhkey = OpenSSL::PKey.generate_key(dh) assert_equal dh.params["p"], dhkey.params["p"] diff --git a/test/openssl/test_pkey_dsa.rb b/test/openssl/test_pkey_dsa.rb index b47a20dfd..c120d74aa 100644 --- a/test/openssl/test_pkey_dsa.rb +++ b/test/openssl/test_pkey_dsa.rb @@ -251,7 +251,7 @@ def test_params assert_equal key.pub_key, pubkey.pub_key assert_equal key.pub_key, pubkey.params["pub_key"] assert_nil pubkey.priv_key - assert_equal 0, pubkey.params["priv_key"] + assert_nil pubkey.params["priv_key"] end def test_dup diff --git a/test/openssl/test_pkey_rsa.rb b/test/openssl/test_pkey_rsa.rb index 516d651ae..f47261ccd 100644 --- a/test/openssl/test_pkey_rsa.rb +++ b/test/openssl/test_pkey_rsa.rb @@ -535,7 +535,7 @@ def test_params pubkey = OpenSSL::PKey.read(key.public_to_der) [:d, :p, :q, :dmp1, :dmq1, :iqmp].each do |name| assert_nil pubkey.send(name) - assert_equal 0, pubkey.params[name.to_s] + assert_nil pubkey.params[name.to_s] end end