Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkey: change PKey::{RSA,DSA,DH}#params to use nil for missing parameters #774

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Jul 3, 2024

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 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.


Also:

pkey: implement PKey::{RSA,DSA,DH}#params in Ruby

Move the definitions to lib/openssl/pkey.rb.

They don't have to be implemented in the native extension and can be simplified by using existing methods.

Add a test case to verify the current behavior.
Move the definitions to lib/openssl/pkey.rb.

They don't have to be implemented in the native extension and can be
simplified by using existing methods.
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 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant