Sha256: 452ebd1ba0524d817e5f859da3483b8d41c5a48e91a6b71bfcec36018867d41d
Contents?: true
Size: 934 Bytes
Versions: 3
Compression:
Stored size: 934 Bytes
Contents
# frozen_string_literal: true module JWT module JWA # Implementation of the RSA family of algorithms 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:) raise_sign_error!("The given key is a #{signing_key.class}. It has to be an OpenSSL::PKey::RSA instance") unless signing_key.is_a?(OpenSSL::PKey::RSA) 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
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
minato_ruby_api_client-0.2.2 | vendor/bundle/ruby/3.2.0/gems/jwt-2.10.1/lib/jwt/jwa/rsa.rb |
jwt-2.10.1 | lib/jwt/jwa/rsa.rb |
jwt-2.10.0 | lib/jwt/jwa/rsa.rb |