Class: COSE::SecurityMessage
- Inherits:
-
Object
- Object
- COSE::SecurityMessage
show all
- 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
Class Method Summary
collapse
Instance Method Summary
collapse
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:)
=
=
end
|
Instance Attribute Details
Returns the value of attribute protected_headers.
12
13
14
|
# File 'lib/cose/security_message.rb', line 12
def
end
|
Returns the value of attribute unprotected_headers.
12
13
14
|
# File 'lib/cose/security_message.rb', line 12
def
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
|
36
37
38
39
40
41
42
|
# File 'lib/cose/security_message.rb', line 36
def self.(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: (array[0]),
unprotected_headers: array[1],
**keyword_arguments_for_initialize(array[2..-1])
)
end
|
Instance Method Details
#algorithm ⇒ Object
49
50
51
|
# File 'lib/cose/security_message.rb', line 49
def algorithm
@algorithm ||= COSE::Algorithm.find(.alg) || raise(COSE::Error, "Unsupported algorithm '#{headers.alg}'")
end
|
53
54
55
|
# File 'lib/cose/security_message.rb', line 53
def
||= .new(, )
end
|