Sha256: fe47806362734c37835cc981129f87f1e2d7cf68233851a52e8f2498d500d2e7

Contents?: true

Size: 874 Bytes

Versions: 7

Compression:

Stored size: 874 Bytes

Contents

require_relative 'utils'

class OpenSSL::TestHMAC < Test::Unit::TestCase
  def setup
    @digest = OpenSSL::Digest::MD5
    @key = "KEY"
    @data = "DATA"
    @h1 = OpenSSL::HMAC.new(@key, @digest.new)
    @h2 = OpenSSL::HMAC.new(@key, "MD5")
  end

  def teardown
  end

  def test_hmac
    @h1.update(@data)
    @h2.update(@data)
    assert_equal(@h1.digest, @h2.digest)

    assert_equal(OpenSSL::HMAC.digest(@digest.new, @key, @data), @h1.digest, "digest")
    assert_equal(OpenSSL::HMAC.hexdigest(@digest.new, @key, @data), @h1.hexdigest, "hexdigest")

    assert_equal(OpenSSL::HMAC.digest("MD5", @key, @data), @h2.digest, "digest")
    assert_equal(OpenSSL::HMAC.hexdigest("MD5", @key, @data), @h2.hexdigest, "hexdigest")
  end

  def test_dup
    @h1.update(@data)
    h = @h1.dup
    assert_equal(@h1.digest, h.digest, "dup digest")
  end
end if defined?(OpenSSL)

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
jruby-openssl-0.8.0.pre3 test/1.9/test_hmac.rb
jruby-openssl-0.8.0.pre2 test/1.9/test_hmac.rb
jruby-openssl-0.8.0.pre1 test/1.9/test_hmac.rb
jruby-openssl-maven-0.7.6.1 test/1.9/test_hmac.rb
jruby-openssl-0.7.7 test/1.9/test_hmac.rb
jruby-openssl-0.7.6.1 test/1.9/test_hmac.rb
jruby-openssl-0.7.5 test/1.9/test_hmac.rb