Class: OpenSSL::SignatureAlgorithm::RSAPSS

Inherits:
RSA
  • Object
show all
Defined in:
lib/openssl/signature_algorithm/rsapss.rb

Constant Summary

Constants inherited from RSA

OpenSSL::SignatureAlgorithm::RSA::ACCEPTED_HASH_FUNCTIONS, OpenSSL::SignatureAlgorithm::RSA::DEFAULT_KEY_SIZE

Instance Attribute Summary

Attributes inherited from RSA

#hash_function

Attributes inherited from Base

#signing_key, #verify_key

Instance Method Summary collapse

Methods inherited from RSA

#generate_signing_key, #initialize

Methods inherited from Base

#compatible_verify_key?

Constructor Details

This class inherits a constructor from OpenSSL::SignatureAlgorithm::RSA

Instance Method Details

#mgf1_hash_functionObject



23
24
25
# File 'lib/openssl/signature_algorithm/rsapss.rb', line 23

def mgf1_hash_function
  hash_function
end

#sign(data) ⇒ Object



9
10
11
# File 'lib/openssl/signature_algorithm/rsapss.rb', line 9

def sign(data)
  signing_key.sign_pss(hash_function, data, salt_length: :max, mgf1_hash: mgf1_hash_function)
end

#verify(signature, verification_data) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/openssl/signature_algorithm/rsapss.rb', line 13

def verify(signature, verification_data)
  verify_key.verify_pss(
    hash_function,
    signature,
    verification_data,
    salt_length: :auto,
    mgf1_hash: mgf1_hash_function
  ) || raise(OpenSSL::SignatureAlgorithm::SignatureVerificationError, "Signature verification failed")
end