Class: Linzer::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/linzer/key.rb,
lib/linzer/key/helper.rb

Direct Known Subclasses

ECDSA::Key, Ed25519::Key, HMAC::Key, RSA::Key

Defined Under Namespace

Modules: Helper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(material, params = {}) ⇒ Key

Returns a new instance of Key.



5
6
7
8
9
10
# File 'lib/linzer/key.rb', line 5

def initialize(material, params = {})
  @material = material
  @params   = Hash(params).clone.freeze
  validate
  freeze
end

Instance Attribute Details

#materialObject (readonly)

Returns the value of attribute material.



12
13
14
# File 'lib/linzer/key.rb', line 12

def material
  @material
end

Instance Method Details

#key_idObject



14
15
16
# File 'lib/linzer/key.rb', line 14

def key_id
  @params[:id]
end

#sign(*args) ⇒ Object



18
19
20
21
# File 'lib/linzer/key.rb', line 18

def sign(*args)
  abstract_error = "Cannot sign data, \"#{self.class}\" is an abstract class."
  raise Error.new abstract_error
end

#verify(*args) ⇒ Object



23
24
25
26
# File 'lib/linzer/key.rb', line 23

def verify(*args)
  abstract_error = "Cannot verify signature, \"#{self.class}\" is an abstract class."
  raise Error.new abstract_error
end