Sha256: 3159c1b2044ea770cea11e369c259c4cfae2c15c1bb5e1ef0acc119e8399b1f8

Contents?: true

Size: 751 Bytes

Versions: 2

Compression:

Stored size: 751 Bytes

Contents

# frozen_string_literal: true

require "cose/key/base"

module COSE
  module Key
    class RSA < Base
      LABEL_N = -1
      LABEL_E = -2

      KTY_RSA = 3

      attr_reader :modulus_n, :public_exponent_e

      def initialize(modulus_n:, public_exponent_e:)
        if !modulus_n
          raise ArgumentError, "Required modulus_n is missing"
        elsif !public_exponent_e
          raise ArgumentError, "Required public_exponent_e is missing"
        else
          @modulus_n = modulus_n
          @public_exponent_e = public_exponent_e
        end
      end

      def self.from_map(map)
        enforce_type(map, KTY_RSA, "Not an RSA key")

        new(modulus_n: map[LABEL_N], public_exponent_e: map[LABEL_E])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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