secret
Created

Test for HMAC signing with UTF-8 String

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
From f16ebf16dc9ad0353a85e39cc23d20e2d31ffcf0 Mon Sep 17 00:00:00 2001
From: Charles Oliver Nutter <headius@headius.com>
Date: Tue, 4 Dec 2012 18:52:37 -0600
Subject: [PATCH] Add test for HMAC signing a UTF-8 String. From JRUBY-7017.
 
---
test/openssl/test_hmac.rb | 9 +++++++++
1 file changed, 9 insertions(+)
 
diff --git a/test/openssl/test_hmac.rb b/test/openssl/test_hmac.rb
index ba158d2..f1e4536 100644
--- a/test/openssl/test_hmac.rb
+++ b/test/openssl/test_hmac.rb
@@ -1,3 +1,5 @@
+# coding: UTF-8
+
require_relative 'utils'
class OpenSSL::TestHMAC < Test::Unit::TestCase
@@ -29,4 +31,11 @@ class OpenSSL::TestHMAC < Test::Unit::TestCase
h = @h1.dup
assert_equal(@h1.digest, h.digest, "dup digest")
end
+
+ def test_binary_update
+ data = "Lücíllé: Bût... yøü sáîd hé wås âlrîght.\nDr. Físhmån: Yés. Hé's løst hîs léft hånd, sø hé's gøîng tø bé åll rîght"
+ hmac = OpenSSL::HMAC.new("qShkcwN92rsM9nHfdnP4ugcVU2iI7iM/trovs01ZWok", "SHA256")
+ result = hmac.update(data).hexdigest
+ assert_equal "a13984b929a07912e4e21c5720876a8e150d6f67f854437206e7f86547248396", result
+ end
end if defined?(OpenSSL)
--
1.7.10.4

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.