Sha256: a9ff362bc835fff244c48e1a17f730507a17287f83975bfcfb1005092dce68ca

Contents?: true

Size: 757 Bytes

Versions: 1

Compression:

Stored size: 757 Bytes

Contents

# frozen_string_literal: true

require "cose/algorithm/signature_algorithm"
require "cose/error"
require "cose/key/ec2"
require "openssl"
require "openssl/signature_algorithm/ecdsa"

module COSE
  module Algorithm
    class ECDSA < SignatureAlgorithm
      attr_reader :hash_function

      def initialize(*args, hash_function:)
        super(*args)

        @hash_function = hash_function
      end

      private

      def signature_algorithm_class
        OpenSSL::SignatureAlgorithm::ECDSA
      end

      def to_pkey(key)
        case key
        when COSE::Key::EC2
          key.to_pkey
        when OpenSSL::PKey::EC
          key
        else
          raise(COSE::Error, "Incompatible key for algorithm")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cose-0.11.0 lib/cose/algorithm/ecdsa.rb