Module: JWT::Algos::Rsa

Defined in:
lib/jwt/algos/rsa.rb

Constant Summary collapse

SUPPORTED =
%w[RS256 RS384 RS512].freeze

Class Method Summary collapse

Class Method Details

.sign(to_sign) ⇒ Object

Raises:



8
9
10
11
12
# File 'lib/jwt/algos/rsa.rb', line 8

def sign(to_sign)
  algorithm, msg, key = to_sign.values
  raise EncodeError, "The given key is a #{key.class}. It has to be an OpenSSL::PKey::RSA instance." if key.class == String
  key.sign(OpenSSL::Digest.new(algorithm.sub('RS', 'sha')), msg)
end

.verify(to_verify) ⇒ Object



14
15
16
# File 'lib/jwt/algos/rsa.rb', line 14

def verify(to_verify)
  SecurityUtils.verify_rsa(to_verify.algorithm, to_verify.public_key, to_verify.signing_input, to_verify.signature)
end