Sha256: dd1e7d50cbd3e8992d4ba1c654f77c8a0145b5e79572efca25ba5a49a146b486
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require "cbor" module COSE module Key class Base LABEL_BASE_IV = 5 LABEL_KEY_OPS = 4 LABEL_ALG = 3 LABEL_KID = 2 LABEL_KTY = 1 def self.deserialize(cbor) from_map(CBOR.decode(cbor)) end def self.from_map(map) enforce_type(map) new( base_iv: map[LABEL_BASE_IV], key_ops: map[LABEL_KEY_OPS], alg: map[LABEL_ALG], kid: map[LABEL_KID], **keyword_arguments_for_initialize(map) ) end attr_accessor :kid, :alg, :key_ops, :base_iv def initialize(kid: nil, alg: nil, key_ops: nil, base_iv: nil) @kid = kid @alg = alg @key_ops = key_ops @base_iv = base_iv end def serialize CBOR.encode(map) end def map map = { LABEL_BASE_IV => base_iv, LABEL_KEY_OPS => key_ops, LABEL_ALG => alg, LABEL_KID => kid, } map.reject { |_k, v| v.nil? } end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
cose-1.0.0 | lib/cose/key/base.rb |
cose-0.11.0 | lib/cose/key/base.rb |
cose-0.10.0 | lib/cose/key/base.rb |
cose-0.9.0 | lib/cose/key/base.rb |
cose-0.8.0 | lib/cose/key/base.rb |