Class: COSE::SecurityMessage
- Inherits:
-
Object
- Object
- COSE::SecurityMessage
- Defined in:
- lib/cose/security_message.rb,
lib/cose/security_message/headers.rb
Defined Under Namespace
Classes: Headers
Constant Summary collapse
- ZERO_LENGTH_BIN_STRING =
"".b
Instance Attribute Summary collapse
-
#protected_headers ⇒ Object
readonly
Returns the value of attribute protected_headers.
-
#unprotected_headers ⇒ Object
readonly
Returns the value of attribute unprotected_headers.
Class Method Summary collapse
Instance Method Summary collapse
- #algorithm ⇒ Object
- #headers ⇒ Object
-
#initialize(protected_headers:, unprotected_headers:) ⇒ SecurityMessage
constructor
A new instance of SecurityMessage.
Constructor Details
#initialize(protected_headers:, unprotected_headers:) ⇒ SecurityMessage
Returns a new instance of SecurityMessage.
44 45 46 47 |
# File 'lib/cose/security_message.rb', line 44 def initialize(protected_headers:, unprotected_headers:) @protected_headers = protected_headers @unprotected_headers = unprotected_headers end |
Instance Attribute Details
#protected_headers ⇒ Object (readonly)
Returns the value of attribute protected_headers.
12 13 14 |
# File 'lib/cose/security_message.rb', line 12 def protected_headers @protected_headers end |
#unprotected_headers ⇒ Object (readonly)
Returns the value of attribute unprotected_headers.
12 13 14 |
# File 'lib/cose/security_message.rb', line 12 def unprotected_headers @unprotected_headers end |
Class Method Details
.deserialize(cbor) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cose/security_message.rb', line 14 def self.deserialize(cbor) decoded = CBOR.decode(cbor) if decoded.is_a?(CBOR::Tagged) if respond_to?(:tag) && tag != decoded.tag raise(COSE::Error, "Invalid CBOR tag") end decoded = decoded.value end from_array(decoded) end |
.deserialize_headers(data) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/cose/security_message.rb', line 36 def self.deserialize_headers(data) if data == ZERO_LENGTH_BIN_STRING {} else CBOR.decode(data) end end |
.from_array(array) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/cose/security_message.rb', line 28 def self.from_array(array) new( protected_headers: deserialize_headers(array[0]), unprotected_headers: array[1], **keyword_arguments_for_initialize(array[2..-1]) ) end |