Class: COSE::Algorithm::SignatureAlgorithm

Inherits:
Base
  • Object
show all
Defined in:
lib/cose/algorithm/signature_algorithm.rb

Direct Known Subclasses

ECDSA, EdDSA, RSAPSS

Instance Attribute Summary

Attributes inherited from Base

#id, #name

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from COSE::Algorithm::Base

Instance Method Details

#compatible_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/cose/algorithm/signature_algorithm.rb', line 14

def compatible_key?(key)
  valid_key?(key) && to_pkey(key)
rescue COSE::Error
  false
end

#verify(key, signature, verification_data) ⇒ Object



9
10
11
12
# File 'lib/cose/algorithm/signature_algorithm.rb', line 9

def verify(key, signature, verification_data)
  compatible_key?(key) || raise(COSE::Error, "Incompatible key for signature verification")
  valid_signature?(key, signature, verification_data) || raise(COSE::Error, "Signature verification failed")
end