mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
[ruby/openssl] Add compare? method to OpenSSL::PKey that wraps EVP_PKEY_cmp.
Explicitly check for type given some conflicting statements within openssl's
documentation around EVP_PKEY_cmp and EVP_PKEY_ASN1_METHOD(3).
Add documentation with an example for compare?
0bf51da6e2
This commit is contained in:
parent
da6341b709
commit
c71afc9db7
Notes:
git
2021-03-16 20:38:48 +09:00
2 changed files with 57 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue