aboutsummaryrefslogtreecommitdiffstats
path: root/test/tc_hmac.rb
blob: 57eb2c04e2b132bc51e1086f12d0a06e3ec57a12 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env ruby
=begin
= $RCSfile$ -- TestCases for OpenSSL::HMAC

= Info
  'OpenSSL for Ruby 2' project
  Copyright (C) 2002  Michal Rokos <m.rokos@sh.cvut.cz>
  All rights reserved.

= Licence
  This program is licenced under the same licence as Ruby.
  (See the file 'LICENCE'.)

= Version
  $Id$
=end

require 'test/unit'
require 'openssl'

include OpenSSL

##
# OpenSSL::debug = true
#

class TC_HMAC < Test::Unit::TestCase
  def setup
    ##
    # None
    # 
  end
  def test_hmac
    digest = Digest::MD5.new
    key = "KEY"
    data = "DATA"

    h = HMAC::new(key, digest)
    h.update(data)
    
    assert_equal(HMAC::digest(digest, key, data), h.digest, "digest")
    assert_equal(HMAC::hexdigest(digest, key, data), h.hexdigest, "hexdigest")
  end
  def test_dup
    ##
    # TODO: Make some test case for
    # 
  end
  def teardown
    ##
    # None
    # 
  end
end