diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2020-07-16 23:56:48 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-16 23:56:48 +0900 |
commit | 2fc6f94ef7e3f6b3ca487b6842c3ce625b806d19 (patch) | |
tree | dda923fc43ba0287630ba923f1cb2662b67bb302 /test | |
parent | a36220bf3d53d1f11e374c634d5bc4c6e3d821e0 (diff) | |
parent | 0bf51da6e24bbdb6f5724a87fe047ac2b521415d (diff) | |
download | ruby-openssl-2fc6f94ef7e3f6b3ca487b6842c3ce625b806d19.tar.gz |
Merge pull request #383 from cwjenkins/add_rsa_keys_eql
Add wrapper method for EVP_PKEY_cmp to compare same type keys
Diffstat (limited to 'test')
-rw-r--r-- | test/openssl/test_pkey.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/openssl/test_pkey.rb b/test/openssl/test_pkey.rb index 5307fe5b..0a516f98 100644 --- a/test/openssl/test_pkey.rb +++ b/test/openssl/test_pkey.rb @@ -151,4 +151,22 @@ class OpenSSL::TestPKey < OpenSSL::PKeyTestCase assert_equal bob_pem, bob.public_to_pem assert_equal [shared_secret].pack("H*"), alice.derive(bob) end + + def test_compare? + key1 = Fixtures.pkey("rsa1024") + key2 = Fixtures.pkey("rsa1024") + key3 = Fixtures.pkey("rsa2048") + key4 = Fixtures.pkey("dh-1") + + assert_equal(true, key1.compare?(key2)) + assert_equal(true, key1.public_key.compare?(key2)) + assert_equal(true, key2.compare?(key1)) + assert_equal(true, key2.public_key.compare?(key1)) + + assert_equal(false, key1.compare?(key3)) + + assert_raise(TypeError) do + key1.compare?(key4) + end + end end |