Module: HrrRbSsh::Transport::MacAlgorithm::Functionable
Instance Attribute Summary
Attributes included from Loggable
#log_key, #logger
Instance Method Summary
collapse
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn
Instance Method Details
#compute(sequence_number, unencrypted_packet) ⇒ Object
25
26
27
28
29
|
# File 'lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb', line 25
def compute sequence_number, unencrypted_packet
data = DataType::Uint32.encode(sequence_number) + unencrypted_packet
digest = OpenSSL::HMAC.digest self.class::DIGEST, @key, data
digest[0, digest_length]
end
|
#digest_length ⇒ Object
17
18
19
|
# File 'lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb', line 17
def digest_length
self.class::DIGEST_LENGTH
end
|
#initialize(key, logger: nil) ⇒ Object
12
13
14
15
|
# File 'lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb', line 12
def initialize key, logger: nil
self.logger = logger
@key = key
end
|
#key_length ⇒ Object
21
22
23
|
# File 'lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb', line 21
def key_length
self.class::KEY_LENGTH
end
|