Skip to content

Commit

Permalink
A little cleanup for the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinj committed Dec 28, 2022
1 parent 6d3fe30 commit 0cddb6a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/openssl/test_pkey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ def test_from_parameters_with_invalid_alg

def test_s_from_parameters_rsa_with_n_e_and_d_given_as_integers
new_key = OpenSSL::PKey.from_parameters("RSA", n: 3161751493,
e: 65537,
d: 2064855961)
e: 65537,
d: 2064855961)

assert_instance_of OpenSSL::PKey::RSA, new_key
assert_equal true, new_key.private?
Expand All @@ -197,8 +197,8 @@ def test_s_from_parameters_rsa_with_n_e_and_d_given_as_integers

def test_s_from_parameters_rsa_with_n_e_and_d_given
new_key = OpenSSL::PKey.from_parameters("RSA", "n" => OpenSSL::BN.new(3161751493),
"e" => OpenSSL::BN.new(65537),
"d" => OpenSSL::BN.new(2064855961))
"e" => OpenSSL::BN.new(65537),
"d" => OpenSSL::BN.new(2064855961))

assert_instance_of OpenSSL::PKey::RSA, new_key
assert_equal true, new_key.private?
Expand All @@ -209,7 +209,7 @@ def test_s_from_parameters_rsa_with_n_e_and_d_given

def test_s_from_parameters_rsa_with_n_and_e_given
new_key = OpenSSL::PKey.from_parameters("RSA", n: OpenSSL::BN.new(3161751493),
e: OpenSSL::BN.new(65537))
e: OpenSSL::BN.new(65537))

assert_instance_of OpenSSL::PKey::RSA, new_key
assert_equal false, new_key.private?
Expand Down Expand Up @@ -273,8 +273,8 @@ def test_s_from_parameters_rsa_with_invalid_parameter

def test_s_from_parameters_ec_pub_given_as_string
source = OpenSSL::PKey::EC.generate("prime256v1")
new_key = OpenSSL::PKey.from_parameters("EC", { group: source.group.curve_name,
pub: source.public_key.to_bn.to_s(2) })
new_key = OpenSSL::PKey.from_parameters("EC", group: source.group.curve_name,
pub: source.public_key.to_bn.to_s(2))
assert_instance_of OpenSSL::PKey::EC, new_key
assert_equal source.group.curve_name, new_key.group.curve_name
assert_equal source.public_key, new_key.public_key
Expand All @@ -283,8 +283,8 @@ def test_s_from_parameters_ec_pub_given_as_string

def test_s_from_parameters_ec_priv_given_as_bn
source = OpenSSL::PKey::EC.generate("prime256v1")
new_key = OpenSSL::PKey.from_parameters("EC", { group: source.group.curve_name,
priv: source.private_key.to_bn })
new_key = OpenSSL::PKey.from_parameters("EC", group: source.group.curve_name,
priv: source.private_key.to_bn)
assert_instance_of OpenSSL::PKey::EC, new_key
assert_equal source.group.curve_name, new_key.group.curve_name
assert_equal source.private_key, new_key.private_key
Expand All @@ -293,8 +293,8 @@ def test_s_from_parameters_ec_priv_given_as_bn

def test_s_from_parameters_ec_priv_given_as_integer
source = OpenSSL::PKey::EC.generate("prime256v1")
new_key = OpenSSL::PKey.from_parameters("EC", { group: source.group.curve_name,
priv: source.private_key.to_i })
new_key = OpenSSL::PKey.from_parameters("EC", group: source.group.curve_name,
priv: source.private_key.to_i)
assert_instance_of OpenSSL::PKey::EC, new_key
assert_equal source.group.curve_name, new_key.group.curve_name
assert_equal source.private_key, new_key.private_key
Expand All @@ -304,9 +304,9 @@ def test_s_from_parameters_ec_priv_given_as_integer
def test_s_from_parameters_ec_priv_and_pub_given_for_different_curves
["prime256v1", "secp256k1", "secp384r1", "secp521r1"].each do |curve|
source = OpenSSL::PKey::EC.generate(curve)
new_key = OpenSSL::PKey.from_parameters("EC", { group: source.group.curve_name,
pub: source.public_key.to_bn.to_s(2),
priv: source.private_key.to_i })
new_key = OpenSSL::PKey.from_parameters("EC", group: source.group.curve_name,
pub: source.public_key.to_bn.to_s(2),
priv: source.private_key.to_i)
assert_instance_of OpenSSL::PKey::EC, new_key
assert_equal source.group.curve_name, new_key.group.curve_name
assert_equal source.private_key, new_key.private_key
Expand Down

0 comments on commit 0cddb6a

Please sign in to comment.