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 Oct 29, 2022
1 parent 83d3032 commit aa6383d
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 @@ -180,8 +180,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 @@ -192,8 +192,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 @@ -204,7 +204,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 @@ -268,8 +268,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 @@ -278,8 +278,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 @@ -288,8 +288,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 @@ -299,9 +299,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 aa6383d

Please sign in to comment.