Sha256: 391b15b8f90bc2b5d785e274d527ad962ca8af393c129c88abdc4ac7c1f022a9

Contents?: true

Size: 609 Bytes

Versions: 8

Compression:

Stored size: 609 Bytes

Contents

require "cbor"

module COSE
  class SecurityMessage
    attr_reader :protected_headers, :unprotected_headers

    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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cose-0.8.0 lib/cose/security_message.rb
cose-0.7.0 lib/cose/security_message.rb
cose-0.6.1 lib/cose/security_message.rb
cose-0.6.0 lib/cose/security_message.rb
cose-0.5.0 lib/cose/security_message.rb
cose-0.4.1 lib/cose/security_message.rb
cose-0.4.0 lib/cose/security_message.rb
cose-0.3.0 lib/cose/security_message.rb