Class: Linzer::HMAC::Key
- Inherits:
-
Key
- Object
- Key
- Linzer::HMAC::Key
show all
- Defined in:
- lib/linzer/hmac.rb
Instance Attribute Summary
Attributes inherited from Key
#material
Instance Method Summary
collapse
Methods inherited from Key
#initialize, #key_id
Constructor Details
This class inherits a constructor from Linzer::Key
Instance Method Details
#inspect ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/linzer/hmac.rb', line 29
def inspect
vars =
instance_variables
.reject { |v| v == :@material } .map do |n|
"#{n}=#{instance_variable_get(n).inspect}"
end
oid = Digest::SHA2.hexdigest(object_id.to_s)[48..63]
"#<%s:0x%s %s>" % [self.class, oid, vars.join(", ")]
end
|
#private? ⇒ Boolean
21
22
23
|
# File 'lib/linzer/hmac.rb', line 21
def private?
!material.nil?
end
|
#public? ⇒ Boolean
25
26
27
|
# File 'lib/linzer/hmac.rb', line 25
def public?
false
end
|
#sign(data) ⇒ Object
13
14
15
|
# File 'lib/linzer/hmac.rb', line 13
def sign(data)
OpenSSL::HMAC.digest(@params[:digest], material, data)
end
|
#validate ⇒ Object
8
9
10
11
|
# File 'lib/linzer/hmac.rb', line 8
def validate
super
validate_digest
end
|
#verify(signature, data) ⇒ Object
17
18
19
|
# File 'lib/linzer/hmac.rb', line 17
def verify(signature, data)
signature == sign(data)
end
|