Sha256: 5b3406a871502eb15a55eaa0ff543f2d019a045eed37d2560b8ea73b44c16c2e

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 Bytes

Contents

require "cbor"
require "cose/key/ec2"
require "cose/key/rsa"
require "cose/key/symmetric"

module COSE
  class UnknownKeyType < StandardError; end

  module Key
    def self.deserialize(data)
      map = CBOR.decode(data)

      case map[Base::LABEL_KTY]
      when COSE::Key::EC2::KTY_EC2
        COSE::Key::EC2.from_map(map)
      when COSE::Key::RSA::KTY_RSA
        COSE::Key::RSA.from_map(map)
      when COSE::Key::Symmetric::KTY_SYMMETRIC
        COSE::Key::Symmetric.from_map(map)
      else
        raise UnknownKeyType, "Unsupported or unknown key type #{map[Base::LABEL_KTY]}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cose-0.4.1 lib/cose/key.rb