Class: COSE::Key::Base
- Inherits:
-
Object
- Object
- COSE::Key::Base
- Defined in:
- lib/cose/key/base.rb
Constant Summary collapse
- LABEL_BASE_IV =
5
- LABEL_KEY_OPS =
4
- LABEL_ALG =
3
- LABEL_KID =
2
- LABEL_KTY =
1
Instance Attribute Summary collapse
-
#alg ⇒ Object
Returns the value of attribute alg.
-
#base_iv ⇒ Object
Returns the value of attribute base_iv.
-
#key_ops ⇒ Object
Returns the value of attribute key_ops.
-
#kid ⇒ Object
Returns the value of attribute kid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(kid: nil, alg: nil, key_ops: nil, base_iv: nil) ⇒ Base
constructor
A new instance of Base.
- #map ⇒ Object
- #serialize ⇒ Object
Constructor Details
#initialize(kid: nil, alg: nil, key_ops: nil, base_iv: nil) ⇒ Base
Returns a new instance of Base.
32 33 34 35 36 37 |
# File 'lib/cose/key/base.rb', line 32 def initialize(kid: nil, alg: nil, key_ops: nil, base_iv: nil) @kid = kid @alg = alg @key_ops = key_ops @base_iv = base_iv end |
Instance Attribute Details
#alg ⇒ Object
Returns the value of attribute alg.
30 31 32 |
# File 'lib/cose/key/base.rb', line 30 def alg @alg end |
#base_iv ⇒ Object
Returns the value of attribute base_iv.
30 31 32 |
# File 'lib/cose/key/base.rb', line 30 def base_iv @base_iv end |
#key_ops ⇒ Object
Returns the value of attribute key_ops.
30 31 32 |
# File 'lib/cose/key/base.rb', line 30 def key_ops @key_ops end |
#kid ⇒ Object
Returns the value of attribute kid.
30 31 32 |
# File 'lib/cose/key/base.rb', line 30 def kid @kid end |
Class Method Details
.deserialize(cbor) ⇒ Object
14 15 16 |
# File 'lib/cose/key/base.rb', line 14 def self.deserialize(cbor) from_map(CBOR.decode(cbor)) end |
.from_map(map) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cose/key/base.rb', line 18 def self.from_map(map) enforce_type(map) new( base_iv: map[LABEL_BASE_IV], key_ops: map[LABEL_KEY_OPS], alg: map[LABEL_ALG], kid: map[LABEL_KID], **keyword_arguments_for_initialize(map) ) end |
Instance Method Details
#map ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/cose/key/base.rb', line 43 def map { LABEL_BASE_IV => base_iv, LABEL_KEY_OPS => key_ops, LABEL_ALG => alg, LABEL_KID => kid, }.compact end |
#serialize ⇒ Object
39 40 41 |
# File 'lib/cose/key/base.rb', line 39 def serialize CBOR.encode(map) end |