summaryrefslogtreecommitdiff
path: root/ext/openssl
diff options
context:
space:
mode:
authorKazuki Yamaguchi <[email protected]>2024-06-14 14:45:56 +0900
committerKazuki Yamaguchi <[email protected]>2025-01-23 01:45:52 +0900
commit87316d58faa2d57e9f1c1df2f76584a129a60bcc (patch)
tree8dfdaf48092519691d7d70e7c04dca1f2cad3c1c /ext/openssl
parentec4592280fe1efcf65982c2a5c0d39b311d56575 (diff)
[ruby/openssl] pkey: change PKey::{RSA,DSA,DH}#params to use nil for missing parameters
The returned Hash from these methods contain 0 in place of a missing parameter in the key, for example: pkey = OpenSSL::PKey.read(OpenSSL::PKey::RSA.new(2048).public_to_pem) pp pkey.params #=> # {"n"=>#<OpenSSL::BN https://github.com/ruby/openssl/commit/286934673421[...snip]>, # "e"=>#<OpenSSL::BN 65537>, # "d"=>#<OpenSSL::BN 0>, # "p"=>#<OpenSSL::BN 0>, # "q"=>#<OpenSSL::BN 0>, # "dmp1"=>#<OpenSSL::BN 0>, # "dmq1"=>#<OpenSSL::BN 0>, # "iqmp"=>#<OpenSSL::BN 0>} Let's use nil instead, which is more appropriate for indicating a missing value. https://github.com/ruby/openssl/commit/f247ec3dec
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/lib/openssl/pkey.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/openssl/lib/openssl/pkey.rb b/ext/openssl/lib/openssl/pkey.rb
index 1aa22bfee6..3d1e8885ca 100644
--- a/ext/openssl/lib/openssl/pkey.rb
+++ b/ext/openssl/lib/openssl/pkey.rb
@@ -42,7 +42,7 @@ module OpenSSL::PKey
# 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 @@ module OpenSSL::PKey
# 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 @@ module OpenSSL::PKey
# 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