Sha256: 2911325798814029be73885b58f19f470439e742c460b70377885e12ab58ae42

Contents?: true

Size: 740 Bytes

Versions: 2

Compression:

Stored size: 740 Bytes

Contents

module COSE
  module Key
    # https://tools.ietf.org/html/rfc8152#section-13.1
    Curve = Struct.new(:id, :name, :pkey_name) do
      @curves = {}

      def self.register(id, name, pkey_name)
        @curves[id] = new(id, name, pkey_name)
      end

      def self.find(id)
        @curves[id]
      end

      def self.by_name(name)
        @curves.values.detect { |curve| curve.name == name }
      end

      def self.by_pkey_name(pkey_name)
        @curves.values.detect { |curve| curve.pkey_name == pkey_name }
      end

      def value
        id
      end
    end
  end
end

COSE::Key::Curve.register(1, "P-256", "prime256v1")
COSE::Key::Curve.register(2, "P-384", "secp384r1")
COSE::Key::Curve.register(3, "P-521", "secp521r1")

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cose-0.8.0 lib/cose/key/curve.rb
cose-0.7.0 lib/cose/key/curve.rb