diff --git a/lib/fog/hmac.rb b/lib/fog/hmac.rb
index <HASH>..<HASH> 100644
--- a/lib/fog/hmac.rb
+++ b/lib/fog/hmac.rb
@@ -2,17 +2,33 @@ module Fog
   class HMAC
 
     def initialize(type, key)
-      @digest = case type
+      @key = key
+      case type
       when 'sha1'
-        OpenSSL::Digest::Digest.new('sha1')
+        setup_sha1
       when 'sha256'
-        OpenSSL::Digest::Digest.new('sha256')
+        setup_sha256
       end
-      @key = key
     end
 
     def sign(data)
-      OpenSSL::HMAC.digest(@digest, @key, data)
+      @signer.call(data)
+    end
+
+    private
+
+    def setup_sha1
+      @digest = OpenSSL::Digest::Digest.new('sha1')
+      @signer = lambda do |data|
+        OpenSSL::HMAC.digest(@digest, @key, data)
+      end
+    end
+
+    def setup_sha256
+      @digest = OpenSSL::Digest::Digest.new('sha256')
+      @signer = lambda do |data|
+        OpenSSL::HMAC.digest(@digest, @key, data)
+      end
     end
 
   end
make hmac stuff a bit more flexible