summaryrefslogtreecommitdiff
path: root/test/openssl/test_hmac.rb
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-01 03:01:07 +0000
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-01 03:01:07 +0000
commit1d4a4d11cd2b79ed2e6b3e023256932e6bf2bb45 (patch)
treef29cefcfff3689ffba9ea03f1c5ff9b4596777fd /test/openssl/test_hmac.rb
parent898220d87e9de111f7e625ecac0d52e71eca6be5 (diff)
This commit was manufactured by cvs2svn to create branch 'ruby_1_8'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl/test_hmac.rb')
-rw-r--r--test/openssl/test_hmac.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/openssl/test_hmac.rb b/test/openssl/test_hmac.rb
new file mode 100644
index 0000000000..2f8d6bba20
--- /dev/null
+++ b/test/openssl/test_hmac.rb
@@ -0,0 +1,34 @@
+begin
+ require "openssl"
+rescue LoadError
+end
+require "test/unit"
+
+if defined?(OpenSSL)
+
+class OpenSSL::TestHMAC < Test::Unit::TestCase
+ def setup
+ @digest = OpenSSL::Digest::MD5.new
+ @key = "KEY"
+ @data = "DATA"
+ @h1 = OpenSSL::HMAC.new(@key, @digest)
+ @h2 = OpenSSL::HMAC.new(@key, @digest)
+ end
+
+ def teardown
+ end
+
+ def test_hmac
+ @h1.update(@data)
+ assert_equal(OpenSSL::HMAC.digest(@digest, @key, @data), @h1.digest, "digest")
+ assert_equal(OpenSSL::HMAC.hexdigest(@digest, @key, @data), @h1.hexdigest, "hexdigest")
+ end
+
+ def test_dup
+ @h1.update(@data)
+ h = @h1.dup
+ assert_equal(@h1.digest, h.digest, "dup digest")
+ end
+end
+
+end