class COSE::SecurityMessage
Constants
- ZERO_LENGTH_BIN_STRING
Attributes
protected_headers[R]
unprotected_headers[R]
Public Class Methods
deserialize(cbor)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
new(protected_headers:, unprotected_headers:)
click to toggle source
# File lib/cose/security_message.rb, line 44 def initialize(protected_headers:, unprotected_headers:) @protected_headers = protected_headers @unprotected_headers = unprotected_headers end
Public Instance Methods
algorithm()
click to toggle source
# File lib/cose/security_message.rb, line 49 def algorithm @algorithm ||= COSE::Algorithm.find(headers.alg) || raise(COSE::Error, "Unsupported algorithm '#{headers.alg}'") end
headers()
click to toggle source
# File lib/cose/security_message.rb, line 53 def headers @headers ||= Headers.new(protected_headers, unprotected_headers) end
Private Instance Methods
serialized_map(map)
click to toggle source
# File lib/cose/security_message.rb, line 59 def serialized_map(map) if map && !map.empty? map.to_cbor else zero_length_bin_string end end
zero_length_bin_string()
click to toggle source
# File lib/cose/security_message.rb, line 67 def zero_length_bin_string ZERO_LENGTH_BIN_STRING end