Object
The base class of all OpenSSL-based HMAC algorithm wrappers.
# File lib/net/ssh/transport/hmac/abstract.rb, line 34 34: def digest_class(*v) 35: @digest_class = nil if !defined?(@digest_class) 36: if v.empty? 37: @digest_class = superclass.digest_class if @digest_class.nil? && superclass.respond_to?(:digest_class) 38: return @digest_class 39: elsif v.length == 1 40: @digest_class = v.first 41: else 42: raise ArgumentError, "wrong number of arguments (#{v.length} for 1)" 43: end 44: end
# File lib/net/ssh/transport/hmac/abstract.rb, line 10 10: def key_length(*v) 11: @key_length = nil if !defined?(@key_length) 12: if v.empty? 13: @key_length = superclass.key_length if @key_length.nil? && superclass.respond_to?(:key_length) 14: return @key_length 15: elsif v.length == 1 16: @key_length = v.first 17: else 18: raise ArgumentError, "wrong number of arguments (#{v.length} for 1)" 19: end 20: end
# File lib/net/ssh/transport/hmac/abstract.rb, line 22 22: def mac_length(*v) 23: @mac_length = nil if !defined?(@mac_length) 24: if v.empty? 25: @mac_length = superclass.mac_length if @mac_length.nil? && superclass.respond_to?(:mac_length) 26: return @mac_length 27: elsif v.length == 1 28: @mac_length = v.first 29: else 30: raise ArgumentError, "wrong number of arguments (#{v.length} for 1)" 31: end 32: end
Compute the HMAC digest for the given data string.
# File lib/net/ssh/transport/hmac/abstract.rb, line 73 73: def digest(data) 74: OpenSSL::HMAC.digest(digest_class.new, key, data)[0,mac_length] 75: end
# File lib/net/ssh/transport/hmac/abstract.rb, line 55 55: def digest_class 56: self.class.digest_class 57: end
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 68: def key=(value) 69: @key = value ? value.to_s[0,key_length] : nil 70: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.