Class: COSE::SecurityMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/cose/security_message.rb

Direct Known Subclasses

Encrypt, Encrypt0, Mac, Mac0, Recipient, Sign, Sign1, Signature

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(protected_headers:, unprotected_headers:) ⇒ SecurityMessage


21
22
23
24
# File 'lib/cose/security_message.rb', line 21

def initialize(protected_headers:, unprotected_headers:)
  @protected_headers = protected_headers
  @unprotected_headers = unprotected_headers
end

Instance Attribute Details

#protected_headersObject (readonly)

Returns the value of attribute protected_headers


5
6
7
# File 'lib/cose/security_message.rb', line 5

def protected_headers
  @protected_headers
end

#unprotected_headersObject (readonly)

Returns the value of attribute unprotected_headers


5
6
7
# File 'lib/cose/security_message.rb', line 5

def unprotected_headers
  @unprotected_headers
end

Class Method Details

.deserialize(cbor) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cose/security_message.rb', line 7

def self.deserialize(cbor)
  decoded = CBOR.decode(cbor)

  if decoded.respond_to?(:value)
    decoded = decoded.value
  end

  new(
    protected_headers: CBOR.decode(decoded[0]),
    unprotected_headers: decoded[1],
    **keyword_arguments_for_initialize(decoded[2..-1])
  )
end