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/none.rb,
lib/net/ssh/transport/hmac/sha1.rb,
lib/net/ssh/transport/hmac/md5_96.rb,
lib/net/ssh/transport/hmac/sha1_96.rb,
lib/net/ssh/transport/hmac/abstract.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, SHA1, SHA1_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,
  'none'         => None
}

Class Method Summary collapse

Class Method Details

.get(name, key = "") ⇒ 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.



21
22
23
24
# File 'lib/net/ssh/transport/hmac.rb', line 21

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

.key_length(name) ⇒ Object

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



27
28
29
30
# File 'lib/net/ssh/transport/hmac.rb', line 27

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