Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make really obvious that we shouldn't use this repo, but leaving noti…

…ce and not just deleting to be nice to future computer archaeologists
  • Loading branch information...
commit dee131d27b40d1c88a10711eb05bc4fa7c844a0f 1 parent 932baae
@markburns markburns authored
View
15 History.txt
@@ -1,15 +0,0 @@
-== 0.4.0 / 2010-01-19
-
-* Ruby 1.9 compatibility [Tim Kersey]
-* Minitest integration [Tim Kersey]
-* Updated to Hoe 2.5.0 [Geoffrey Grosenbach]
-
-== 0.3.2 / 2008-08-20
-
-* Removed spurious constants that cause warnings on load [Blaine Cook]
-* Move hoe to build dependency if build deps are supported [Blaine Cook]
-
-== 0.3.1 / 2007-08-13
-
-* Converted to gem by Geoffrey Grosenbach
-* Tests converted to Test::Unit
View
11 Manifest.txt
@@ -1,11 +0,0 @@
-History.txt
-Manifest.txt
-README.txt
-Rakefile
-lib/hmac-md5.rb
-lib/hmac-rmd160.rb
-lib/hmac-sha1.rb
-lib/hmac-sha2.rb
-lib/hmac.rb
-lib/ruby_hmac.rb
-test/test_hmac.rb
View
42 README.md
@@ -1,41 +1,9 @@
-= ruby-hmac
-
-* http://ruby-hmac.rubyforge.org
-
-== IMPORTANT: USE OpenSSL INSTEAD!
-
+IMPORTANT: USE OpenSSL INSTEAD!
+================================
The HMAC functionality included with OpenSSL is available from Ruby and is much faster. It's recommended that you use OpenSSL instead of this library.
-
See the blog post on [OpenSSL vs. Ruby HMAC Benchmarks](http://blog.nathanielbibler.com/post/63031273/openssl-hmac-vs-ruby-hmac-benchmarks).
-== DESCRIPTION:
-
-This module provides common interface to HMAC functionality. HMAC is a kind of "Message Authentication Code" (MAC) algorithm whose standard is documented in RFC2104. Namely, a MAC provides a way to check the integrity of information transmitted over or stored in an unreliable medium, based on a secret key.
-
-Originally written by Daiki Ueno. Converted to a RubyGem by Geoffrey Grosenbach
-
-== LICENSE:
-
-(The MIT License)
-
-Copyright (c) 2007 Daiki Ueno
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-'Software'), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ruby-hmac
+=========
+* http://ruby-hmac.rubyforge.org
View
23 Rakefile
@@ -1,23 +0,0 @@
-require 'rubygems'
-require 'hoe'
-$:.unshift(File.dirname(__FILE__) + "/lib")
-require 'hmac'
-
-Hoe.spec 'ruby-hmac' do
- developer "Daiki Ueno", ""
- developer "Geoffrey Grosenbach", "boss@topfunky.com"
-end
-
-Hoe.plugin :minitest
-Hoe.plugin :git
-Hoe.plugin :gemcutter
-
-desc "Simple require on packaged files to make sure they are all there"
-task :verify => :package do
- # An error message will be displayed if files are missing
- if system %(ruby -e "require 'pkg/ruby-hmac-#{HMAC::VERSION}/lib/hmac'")
- puts "\nThe library files are present"
- end
-end
-
-task :release => :verify
View
11 lib/hmac-md5.rb
@@ -1,11 +0,0 @@
-require 'hmac'
-require 'digest/md5'
-
-module HMAC
- class MD5 < Base
- def initialize(key = nil)
- super(Digest::MD5, 64, 16, key)
- end
- public_class_method :new, :digest, :hexdigest
- end
-end
View
11 lib/hmac-rmd160.rb
@@ -1,11 +0,0 @@
-require 'hmac'
-require 'digest/rmd160'
-
-module HMAC
- class RMD160 < Base
- def initialize(key = nil)
- super(Digest::RMD160, 64, 20, key)
- end
- public_class_method :new, :digest, :hexdigest
- end
-end
View
11 lib/hmac-sha1.rb
@@ -1,11 +0,0 @@
-require 'hmac'
-require 'digest/sha1'
-
-module HMAC
- class SHA1 < Base
- def initialize(key = nil)
- super(Digest::SHA1, 64, 20, key)
- end
- public_class_method :new, :digest, :hexdigest
- end
-end
View
25 lib/hmac-sha2.rb
@@ -1,25 +0,0 @@
-require 'hmac'
-require 'digest/sha2'
-
-module HMAC
- class SHA256 < Base
- def initialize(key = nil)
- super(Digest::SHA256, 64, 32, key)
- end
- public_class_method :new, :digest, :hexdigest
- end
-
- class SHA384 < Base
- def initialize(key = nil)
- super(Digest::SHA384, 128, 48, key)
- end
- public_class_method :new, :digest, :hexdigest
- end
-
- class SHA512 < Base
- def initialize(key = nil)
- super(Digest::SHA512, 128, 64, key)
- end
- public_class_method :new, :digest, :hexdigest
- end
-end
View
118 lib/hmac.rb
@@ -1,118 +0,0 @@
-# Copyright (C) 2001 Daiki Ueno <ueno@unixuser.org>
-# This library is distributed under the terms of the Ruby license.
-
-# This module provides common interface to HMAC engines.
-# HMAC standard is documented in RFC 2104:
-#
-# H. Krawczyk et al., "HMAC: Keyed-Hashing for Message Authentication",
-# RFC 2104, February 1997
-#
-# These APIs are inspired by JCE 1.2's javax.crypto.Mac interface.
-#
-# <URL:http://java.sun.com/security/JCE1.2/spec/apidoc/javax/crypto/Mac.html>
-#
-# Source repository is at
-#
-# http://github.com/topfunky/ruby-hmac/tree/master
-
-module HMAC
-
- VERSION = '0.4.0'
-
- class Base
- def initialize(algorithm, block_size, output_length, key)
- @algorithm = algorithm
- @block_size = block_size
- @output_length = output_length
- @initialized = false
- @key_xor_ipad = ''
- @key_xor_opad = ''
- set_key(key) unless key.nil?
- end
-
- private
- def check_status
- unless @initialized
- raise RuntimeError,
- "The underlying hash algorithm has not yet been initialized."
- end
- end
-
- public
- def set_key(key)
- # If key is longer than the block size, apply hash function
- # to key and use the result as a real key.
- key = @algorithm.digest(key) if key.size > @block_size
- akey = key.unpack("C*")
- key_xor_ipad = ("\x36" * @block_size).unpack("C*")
- key_xor_opad = ("\x5C" * @block_size).unpack("C*")
- for i in 0 .. akey.size - 1
- key_xor_ipad[i] ^= akey[i]
- key_xor_opad[i] ^= akey[i]
- end
- @key_xor_ipad = key_xor_ipad.pack("C*")
- @key_xor_opad = key_xor_opad.pack("C*")
- @md = @algorithm.new
- @initialized = true
- end
-
- def reset_key
- @key_xor_ipad.gsub!(/./, '?')
- @key_xor_opad.gsub!(/./, '?')
- @key_xor_ipad[0..-1] = ''
- @key_xor_opad[0..-1] = ''
- @initialized = false
- end
-
- def update(text)
- check_status
- # perform inner H
- md = @algorithm.new
- md.update(@key_xor_ipad)
- md.update(text)
- str = md.digest
- # perform outer H
- md = @algorithm.new
- md.update(@key_xor_opad)
- md.update(str)
- @md = md
- end
- alias << update
-
- def digest
- check_status
- @md.digest
- end
-
- def hexdigest
- check_status
- @md.hexdigest
- end
- alias to_s hexdigest
-
- # These two class methods below are safer than using above
- # instance methods combinatorially because an instance will have
- # held a key even if it's no longer in use.
- def Base.digest(key, text)
- hmac = self.new(key)
- begin
- hmac.update(text)
- hmac.digest
- ensure
- hmac.reset_key
- end
- end
-
- def Base.hexdigest(key, text)
- hmac = self.new(key)
- begin
- hmac.update(text)
- hmac.hexdigest
- ensure
- hmac.reset_key
- end
- end
-
- private_class_method :new, :digest, :hexdigest
- end
-end
View
2  lib/ruby_hmac.rb
@@ -1,2 +0,0 @@
-# Convenience file to match gem name
-require 'hmac'
View
33 ruby-hmac.gemspec
@@ -1,33 +0,0 @@
-Gem::Specification.new do |s|
- s.name = %q{ruby-hmac}
- s.version = "0.3.2"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Daiki Ueno", "Geoffrey Grosenbach"]
- s.date = %q{2008-08-21}
- s.description = %q{A MAC provides a way to check the integrity of information transmitted over or stored in an unreliable medium, based on a secret key.}
- s.email = %q{boss@topfunky.com}
- s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
- s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "lib/hmac-md5.rb", "lib/hmac-rmd160.rb", "lib/hmac-sha1.rb", "lib/hmac-sha2.rb", "lib/hmac.rb", "test/test_hmac.rb"]
- s.has_rdoc = true
- s.homepage = %q{http://ruby-hmac.rubyforge.org}
- s.rdoc_options = ["--main", "README.txt"]
- s.require_paths = ["lib"]
- s.rubyforge_project = %q{ruby-hmac}
- s.rubygems_version = %q{1.2.0}
- s.summary = %q{An implementation of the HMAC authentication code in Ruby.}
- s.test_files = ["test/test_hmac.rb"]
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 2
-
- if current_version >= 3 then
- s.add_development_dependency(%q<hoe>, [">= 1.7.0"])
- else
- s.add_dependency(%q<hoe>, [">= 1.7.0"])
- end
- else
- s.add_dependency(%q<hoe>, [">= 1.7.0"])
- end
-end
View
89 test/test_hmac.rb
@@ -1,89 +0,0 @@
-#!/usr/bin/env ruby
-
-$: << File.dirname(__FILE__) + "/../lib"
-require "hmac-md5"
-require "hmac-sha1"
-begin
- require "minitest/unit"
-rescue LoadError
- require "rubygems"
- require "minitest/unit"
-end
-
-MiniTest::Unit.autorun
-
-class TestHmac < MiniTest::Unit::TestCase
-
- def test_s_digest
- key = "\x0b" * 16
- text = "Hi There"
-
- hmac = HMAC::MD5.new(key)
- hmac.update(text)
-
- assert_equal(hmac.digest, HMAC::MD5.digest(key, text))
- end
-
- def test_s_hexdigest
- key = "\x0b" * 16
- text = "Hi There"
-
- hmac = HMAC::MD5.new(key)
- hmac.update(text)
-
- assert_equal(hmac.hexdigest, HMAC::MD5.hexdigest(key, text))
- end
-
- def test_hmac_md5_1
- assert_equal(HMAC::MD5.hexdigest("\x0b" * 16, "Hi There"),
- "9294727a3638bb1c13f48ef8158bfc9d")
- end
-
- def test_hmac_md5_2
- assert_equal(HMAC::MD5.hexdigest("Jefe", "what do ya want for nothing?"),
- "750c783e6ab0b503eaa86e310a5db738")
- end
-
- def test_hmac_md5_3
- assert_equal(HMAC::MD5.hexdigest("\xaa" * 16, "\xdd" * 50),
- "56be34521d144c88dbb8c733f0e8b3f6")
- end
-
- def test_hmac_md5_4
- assert_equal(HMAC::MD5.hexdigest(["0102030405060708090a0b0c0d0e0f10111213141516171819"].pack("H*"), "\xcd" * 50),
- "697eaf0aca3a3aea3a75164746ffaa79")
- end
-
- def test_hmac_md5_5
- assert_equal(HMAC::MD5.hexdigest("\x0c" * 16, "Test With Truncation"),
- "56461ef2342edc00f9bab995690efd4c")
- end
-
- # def test_hmac_md5_6
- # assert_equal(HMAC::MD5.hexdigest("\x0c" * 16, "Test With Truncation"),
- # "56461ef2342edc00f9bab995")
- # end
-
- def test_hmac_md5_7
- assert_equal(HMAC::MD5.hexdigest("\xaa" * 80, "Test Using Larger Than Block-Size Key - Hash Key First"),
- "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd")
- end
-
- def test_hmac_md5_8
- assert_equal(HMAC::MD5.hexdigest("\xaa" * 80, "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"),
- "6f630fad67cda0ee1fb1f562db3aa53e")
- end
-
- def test_reset_key
- hmac = HMAC::MD5.new("key")
- hmac.reset_key
- assert_raises(RuntimeError) { hmac.update("foo") }
- end
-
- def test_set_key
- hmac = HMAC::MD5.new
- assert_raises(RuntimeError) { hmac.update("foo") }
- hmac.reset_key
- assert_raises(RuntimeError) { hmac.update("foo") }
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.