Class: OpenSSL::SignatureAlgorithm::Base
- Inherits:
-
Object
- Object
- OpenSSL::SignatureAlgorithm::Base
- Defined in:
- lib/openssl/signature_algorithm/base.rb
Instance Attribute Summary collapse
-
#signing_key ⇒ Object
readonly
Returns the value of attribute signing_key.
-
#verify_key ⇒ Object
Returns the value of attribute verify_key.
Instance Method Summary collapse
- #compatible_verify_key?(verify_key) ⇒ Boolean
- #sign(data) ⇒ Object
- #verify(signature, verification_data) ⇒ Object
Instance Attribute Details
#signing_key ⇒ Object (readonly)
Returns the value of attribute signing_key.
13 14 15 |
# File 'lib/openssl/signature_algorithm/base.rb', line 13 def signing_key @signing_key end |
#verify_key ⇒ Object
Returns the value of attribute verify_key.
13 14 15 |
# File 'lib/openssl/signature_algorithm/base.rb', line 13 def verify_key @verify_key end |
Instance Method Details
#compatible_verify_key?(verify_key) ⇒ Boolean
23 24 25 |
# File 'lib/openssl/signature_algorithm/base.rb', line 23 def compatible_verify_key?(verify_key) verify_key.respond_to?(:verify) end |
#sign(data) ⇒ Object
27 28 29 |
# File 'lib/openssl/signature_algorithm/base.rb', line 27 def sign(data) signing_key.sign(hash_function, data) end |
#verify(signature, verification_data) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/openssl/signature_algorithm/base.rb', line 31 def verify(signature, verification_data) formatted_signature = if respond_to?(:formatted_signature, true) formatted_signature(signature) else signature end verify_key.verify(hash_function, formatted_signature, verification_data) || raise(OpenSSL::SignatureAlgorithm::SignatureVerificationError, "Signature verification failed") end |