Sha256: 62c4a2e9d9c2fd897b9deb288f95039174533de53be2c1cfdd2d55d29e84adab
Contents?: true
Size: 903 Bytes
Versions: 4
Compression:
Stored size: 903 Bytes
Contents
# frozen_string_literal: true module JWT module JWA class Rsa include JWT::JWA::SigningAlgorithm def initialize(alg) @alg = alg @digest = OpenSSL::Digest.new(alg.sub('RS', 'SHA')) end def sign(data:, signing_key:) unless signing_key.is_a?(OpenSSL::PKey::RSA) raise_sign_error!("The given key is a #{signing_key.class}. It has to be an OpenSSL::PKey::RSA instance") end signing_key.sign(digest, data) end def verify(data:, signature:, verification_key:) verification_key.verify(digest, signature, data) rescue OpenSSL::PKey::PKeyError raise JWT::VerificationError, 'Signature verification raised' end register_algorithm(new('RS256')) register_algorithm(new('RS384')) register_algorithm(new('RS512')) private attr_reader :digest end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
jwt-2.9.3 | lib/jwt/jwa/rsa.rb |
jwt-2.9.2 | lib/jwt/jwa/rsa.rb |
jwt-2.9.1 | lib/jwt/jwa/rsa.rb |
jwt-2.9.0 | lib/jwt/jwa/rsa.rb |