Class: HMAC::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/atig/oauth-patch.rb

Instance Method Summary collapse

Instance Method Details

#set_key(key) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/atig/oauth-patch.rb', line 25

def set_key(key)
  key = @algorithm.digest(key) if key.size > @block_size
  key_xor_ipad = Array.new(@block_size, 0x36)
  key_xor_opad = Array.new(@block_size, 0x5c)
  key.bytes.each_with_index do |value, index|
    key_xor_ipad[index] ^= value
    key_xor_opad[index] ^= value
  end
  @key_xor_ipad = key_xor_ipad.pack('c*')
  @key_xor_opad = key_xor_opad.pack('c*')
  @md = @algorithm.new
  @initialized = true
end