summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-13 02:37:35 +0000
committeremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-13 02:37:35 +0000
commit4247bfd60a15438e6adbabff682e96a235e2d241 (patch)
tree5eb88e41eee17b55e0db66b44b78df3131a72abc /test
parenta27b63d3fc1c491eda62a8a48527df53301f45ce (diff)
* ext/openssl/ossl_digest.c: allow Digests to be created by sn, ln or
oid. * test/openssl/test_digest.rb: add tests for this. [Ruby 1.9 - Feature #4412] [ruby-core:35319] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/openssl/test_digest.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/openssl/test_digest.rb b/test/openssl/test_digest.rb
index e9b4ad136d..ce0d85fe55 100644
--- a/test/openssl/test_digest.rb
+++ b/test/openssl/test_digest.rb
@@ -56,6 +56,11 @@ class OpenSSL::TestDigest < Test::Unit::TestCase
assert_equal(dig1, dig2, "reset")
end
+ def test_digest_by_oid_and_name
+ check_digest(OpenSSL::ASN1::ObjectId.new("MD5"))
+ check_digest(OpenSSL::ASN1::ObjectId.new("SHA1"))
+ end
+
if OpenSSL::OPENSSL_VERSION_NUMBER > 0x00908000
def encode16(str)
str.unpack("H*").first
@@ -77,6 +82,24 @@ class OpenSSL::TestDigest < Test::Unit::TestCase
assert_equal(sha384_a, encode16(OpenSSL::Digest::SHA384.digest("a")))
assert_equal(sha512_a, encode16(OpenSSL::Digest::SHA512.digest("a")))
end
+
+ def test_digest_by_oid_and_name_sha2
+ check_digest(OpenSSL::ASN1::ObjectId.new("SHA224"))
+ check_digest(OpenSSL::ASN1::ObjectId.new("SHA256"))
+ check_digest(OpenSSL::ASN1::ObjectId.new("SHA384"))
+ check_digest(OpenSSL::ASN1::ObjectId.new("SHA512"))
+ end
+ end
+
+ private
+
+ def check_digest(oid)
+ d = OpenSSL::Digest.new(oid.sn)
+ assert_not_nil(d)
+ d = OpenSSL::Digest.new(oid.ln)
+ assert_not_nil(d)
+ d = OpenSSL::Digest.new(oid.oid)
+ assert_not_nil(d)
end
end