module JWT::Signature

Signature logic for JWT

Constants

ToSign
ToVerify

Public Instance Methods

sign(algorithm, msg, key) click to toggle source
# File lib/jwt/signature.rb, line 21
def sign(algorithm, msg, key)
  algo, code = Algos.find(algorithm)
  algo.sign ToSign.new(code, msg, key)
end
verify(algorithm, key, signing_input, signature) click to toggle source
# File lib/jwt/signature.rb, line 26
def verify(algorithm, key, signing_input, signature)
  algo, code = Algos.find(algorithm)
  algo.verify(ToVerify.new(code, key, signing_input, signature))
rescue OpenSSL::PKey::PKeyError
  raise JWT::VerificationError, 'Signature verification raised'
ensure
  OpenSSL.errors.clear
end