Class: COSE::Key::Symmetric
Constant Summary collapse
- LABEL_K =
-1
- KTY_SYMMETRIC =
4
Constants inherited from Base
Base::LABEL_ALG, Base::LABEL_BASE_IV, Base::LABEL_KEY_OPS, Base::LABEL_KID, Base::LABEL_KTY
Instance Attribute Summary collapse
-
#k ⇒ Object
readonly
Returns the value of attribute k.
Attributes inherited from Base
#alg, #base_iv, #key_ops, #kid
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(k:, **keyword_arguments) ⇒ Symmetric
constructor
rubocop:disable Naming/MethodParameterName.
- #map ⇒ Object
Methods inherited from Base
deserialize, from_map, #serialize
Constructor Details
#initialize(k:, **keyword_arguments) ⇒ Symmetric
rubocop:disable Naming/MethodParameterName
20 21 22 23 24 25 26 27 28 |
# File 'lib/cose/key/symmetric.rb', line 20 def initialize(k:, **keyword_arguments) # rubocop:disable Naming/MethodParameterName super(**keyword_arguments) if !k raise ArgumentError, "Required key value k is missing" else @k = k end end |
Instance Attribute Details
#k ⇒ Object (readonly)
Returns the value of attribute k.
12 13 14 |
# File 'lib/cose/key/symmetric.rb', line 12 def k @k end |
Class Method Details
.enforce_type(map) ⇒ Object
14 15 16 17 18 |
# File 'lib/cose/key/symmetric.rb', line 14 def self.enforce_type(map) if map[LABEL_KTY] != KTY_SYMMETRIC raise "Not a Symmetric key" end end |
.keyword_arguments_for_initialize(map) ⇒ Object
34 35 36 |
# File 'lib/cose/key/symmetric.rb', line 34 def self.keyword_arguments_for_initialize(map) { k: map[LABEL_K] } end |
Instance Method Details
#map ⇒ Object
30 31 32 |
# File 'lib/cose/key/symmetric.rb', line 30 def map super.merge(LABEL_KTY => KTY_SYMMETRIC, LABEL_K => k) end |