Class: Net::SSH::Transport::HMAC::Abstract

### Home Classes Methods

### In Files

- lib/net/ssh/transport/hmac/abstract.rb

### Parent

Object

### Methods

- ::digest_class
- ::key_length
- ::mac_length
- ::new
- #digest
- #digest_class
- #key=
- #key_length
- #mac_length

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Net
- Net::SSH
- Net::SSH::Authentication
- Net::SSH::Authentication::Agent
- Net::SSH::Authentication::Agent::Comment
- Net::SSH::Authentication::AgentError
- Net::SSH::Authentication::AgentNotAvailable
- Net::SSH::Authentication::Constants
- Net::SSH::Authentication::DisallowedMethod
- Net::SSH::Authentication::KeyManager
- Net::SSH::Authentication::KeyManagerError
- Net::SSH::Authentication::Methods
- Net::SSH::Authentication::Methods::Abstract
- Net::SSH::Authentication::Methods::Hostbased
- Net::SSH::Authentication::Methods::KeyboardInteractive
- Net::SSH::Authentication::Methods::None
- Net::SSH::Authentication::Methods::Password
- Net::SSH::Authentication::Methods::Publickey
- Net::SSH::Authentication::Session
- Net::SSH::AuthenticationFailed
- Net::SSH::Buffer
- Net::SSH::ChannelOpenFailed
- Net::SSH::ChannelRequestFailed
- Net::SSH::Compat
- Net::SSH::Config
- Net::SSH::Connection
- Net::SSH::Connection::Channel
- Net::SSH::Connection::Constants
- Net::SSH::Connection::Keepalive
- Net::SSH::Connection::Session
- Net::SSH::Connection::Session::NilChannel
- Net::SSH::Connection::Term
- Net::SSH::ConnectionTimeout
- Net::SSH::Disconnect
- Net::SSH::Exception
- Net::SSH::HostKeyError
- Net::SSH::HostKeyMismatch
- Net::SSH::HostKeyUnknown
- Net::SSH::KeyFactory
- Net::SSH::KnownHosts
- Net::SSH::Loggable
- Net::SSH::Packet
- Net::SSH::PromptMethods
- Net::SSH::PromptMethods::Clear
- Net::SSH::PromptMethods::Highline
- Net::SSH::PromptMethods::Termios
- Net::SSH::Proxy
- Net::SSH::Proxy::Command
- Net::SSH::Proxy::ConnectError
- Net::SSH::Proxy::Error
- Net::SSH::Proxy::HTTP
- Net::SSH::Proxy::SOCKS4
- Net::SSH::Proxy::SOCKS5
- Net::SSH::Proxy::UnauthorizedError
- Net::SSH::Test
- Net::SSH::Test::Channel
- Net::SSH::Test::Extensions
- Net::SSH::Test::Extensions::BufferedIo
- Net::SSH::Test::Extensions::Channel
- Net::SSH::Test::Extensions::IO
- Net::SSH::Test::Extensions::IO::ClassMethods
- Net::SSH::Test::Extensions::PacketStream
- Net::SSH::Test::Kex
- Net::SSH::Test::LocalPacket
- Net::SSH::Test::Packet
- Net::SSH::Test::RemotePacket
- Net::SSH::Test::Script
- Net::SSH::Test::Socket
- Net::SSH::Timeout
- Net::SSH::Transport
- Net::SSH::Transport::Algorithms
- Net::SSH::Transport::CTR
- Net::SSH::Transport::CipherFactory
- Net::SSH::Transport::Constants
- Net::SSH::Transport::HMAC
- Net::SSH::Transport::HMAC::Abstract
- Net::SSH::Transport::HMAC::MD5
- Net::SSH::Transport::HMAC::MD5_96
- Net::SSH::Transport::HMAC::None
- Net::SSH::Transport::HMAC::RIPEMD160
- Net::SSH::Transport::HMAC::SHA1
- Net::SSH::Transport::HMAC::SHA1_96
- Net::SSH::Transport::HMAC::SHA2_256
- Net::SSH::Transport::HMAC::SHA2_256_96
- Net::SSH::Transport::HMAC::SHA2_512
- Net::SSH::Transport::HMAC::SHA2_512_96
- Net::SSH::Transport::IdentityCipher
- Net::SSH::Transport::Kex
- Net::SSH::Transport::Kex::DiffieHellmanGroup14SHA1
- Net::SSH::Transport::Kex::DiffieHellmanGroup1SHA1
- Net::SSH::Transport::Kex::DiffieHellmanGroupExchangeSHA1
- Net::SSH::Transport::Kex::DiffieHellmanGroupExchangeSHA256
- Net::SSH::Transport::Kex::EcdhSHA2NistP256
- Net::SSH::Transport::Kex::EcdhSHA2NistP384
- Net::SSH::Transport::Kex::EcdhSHA2NistP521
- Net::SSH::Transport::KeyExpander
- Net::SSH::Transport::PacketStream
- Net::SSH::Transport::ServerVersion
- Net::SSH::Transport::Session
- Net::SSH::Transport::State
- Net::SSH::Verifiers
- Net::SSH::Verifiers::Lenient
- Net::SSH::Verifiers::Null
- Net::SSH::Verifiers::Secure
- Net::SSH::Verifiers::Strict
- Net::SSH::Version
- OpenSSL
- OpenSSL::BN
- OpenSSL::PKey
- OpenSSL::PKey::DH
- OpenSSL::PKey::DSA
- OpenSSL::PKey::EC
- OpenSSL::PKey::OpenSSL
- OpenSSL::PKey::OpenSSL::PKey
- OpenSSL::PKey::OpenSSL::PKey::OpenSSL
- OpenSSL::PKey::OpenSSL::PKey::OpenSSL::PKey
- OpenSSL::PKey::OpenSSL::PKey::OpenSSL::PKey::ECError
- OpenSSL::PKey::PKey
- OpenSSL::PKey::RSA
- String

No matching classes.

# Net::SSH::Transport::HMAC::Abstract

The base class of all OpenSSL-based HMAC algorithm wrappers.

### Attributes

key[R]

The key in use for this instance.

### Public Class Methods

digest_class(*v) click to toggle source

    # File lib/net/ssh/transport/hmac/abstract.rb, line 34
    def digest_class(*v)
      @digest_class = nil if !defined?(@digest_class)
      if v.empty?
        @digest_class = superclass.digest_class if @digest_class.nil? && superclass.respond_to?(:digest_class)
        return @digest_class
      elsif v.length == 1
        @digest_class = v.first
      else
        raise ArgumentError, "wrong number of arguments (#{v.length} for 1)"
      end
    end

key_length(*v) click to toggle source

    # File lib/net/ssh/transport/hmac/abstract.rb, line 10
    def key_length(*v)
      @key_length = nil if !defined?(@key_length)
      if v.empty?
        @key_length = superclass.key_length if @key_length.nil? && superclass.respond_to?(:key_length)
        return @key_length
      elsif v.length == 1
        @key_length = v.first
      else
        raise ArgumentError, "wrong number of arguments (#{v.length} for 1)"
      end
    end

mac_length(*v) click to toggle source

    # File lib/net/ssh/transport/hmac/abstract.rb, line 22
    def mac_length(*v)
      @mac_length = nil if !defined?(@mac_length)
      if v.empty?
        @mac_length = superclass.mac_length if @mac_length.nil? && superclass.respond_to?(:mac_length)
        return @mac_length
      elsif v.length == 1
        @mac_length = v.first
      else
        raise ArgumentError, "wrong number of arguments (#{v.length} for 1)"
      end
    end

new(key=nil) click to toggle source

    # File lib/net/ssh/transport/hmac/abstract.rb, line 62
    def initialize(key=nil)
      self.key = key
    end

### Public Instance Methods

digest(data) click to toggle source

Compute the HMAC digest for the given data string.

    # File lib/net/ssh/transport/hmac/abstract.rb, line 73
    def digest(data)
      OpenSSL::HMAC.digest(digest_class.new, key, data)[0,mac_length]
    end

digest_class() click to toggle source

    # File lib/net/ssh/transport/hmac/abstract.rb, line 55
    def digest_class
      self.class.digest_class
    end

key=(value) click to toggle source

Sets the key to the given value, truncating it so that it is the correct length.

    # File lib/net/ssh/transport/hmac/abstract.rb, line 68
    def key=(value)
      @key = value ? value.to_s[0,key_length] : nil
    end

key_length() click to toggle source

    # File lib/net/ssh/transport/hmac/abstract.rb, line 47
    def key_length
      self.class.key_length
    end

mac_length() click to toggle source

    # File lib/net/ssh/transport/hmac/abstract.rb, line 51
    def mac_length
      self.class.mac_length
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.