Module: Net::SSH::Transport::HMAC

Defined in:
lib/net/ssh/transport/hmac.rb,
lib/net/ssh/transport/hmac/md5.rb,
lib/net/ssh/transport/hmac/sha1.rb,
lib/net/ssh/transport/hmac/none.rb,
lib/net/ssh/transport/hmac/md5_96.rb,
lib/net/ssh/transport/hmac/sha1_96.rb,
lib/net/ssh/transport/hmac/sha2_256.rb,
lib/net/ssh/transport/hmac/abstract.rb,
lib/net/ssh/transport/hmac/sha2_512.rb,
lib/net/ssh/transport/hmac/ripemd160.rb,
lib/net/ssh/transport/hmac/sha2_512_96.rb,
lib/net/ssh/transport/hmac/sha2_256_96.rb

Overview

Implements a simple factory interface for fetching hmac implementations, or for finding the key lengths for hmac implementations.s

Defined Under Namespace

Classes: Abstract, MD5, MD5_96, None, RIPEMD160, SHA1, SHA1_96, SHA2_256, SHA2_256_96, SHA2_512, SHA2_512_96

Constant Summary collapse

MAP =

The mapping of SSH hmac algorithms to their implementations

{
  'hmac-md5'       => MD5,
  'hmac-md5-96'    => MD5_96,
  'hmac-sha1'      => SHA1,
  'hmac-sha1-96'   => SHA1_96,
  'hmac-ripemd160' => RIPEMD160,
  '[email protected]' => RIPEMD160,
  'none'           => None
}

Class Method Summary collapse

Class Method Details

.get(name, key = "", parameters = {}) ⇒ Object

Retrieves a new hmac instance of the given SSH type (name). If key is given, the new instance will be initialized with that key.


35
36
37
38
# File 'lib/net/ssh/transport/hmac.rb', line 35

def self.get(name, key="", parameters = {})
  impl = MAP[name] or raise ArgumentError, "hmac not found: #{name.inspect}"
  impl.new(Net::SSH::Transport::KeyExpander.expand_key(impl.key_length, key, parameters))
end

.key_length(name) ⇒ Object

Retrieves the key length for the hmac of the given SSH type (name).


41
42
43
44
# File 'lib/net/ssh/transport/hmac.rb', line 41

def self.key_length(name)
  impl = MAP[name] or raise ArgumentError, "hmac not found: #{name.inspect}"
  impl.key_length
end