Sha256: fd76ab6694a68901da23c61f43284660c44a8da8cab80289c08754b434b253d0

Contents?: true

Size: 571 Bytes

Versions: 7

Compression:

Stored size: 571 Bytes

Contents

module JWT
  module Algos
    module Rsa
      module_function

      SUPPORTED = %w[RS256 RS384 RS512].freeze

      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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
jwt-2.3.0 lib/jwt/algos/rsa.rb
jwt-2.2.3 lib/jwt/algos/rsa.rb
jwt-2.2.2 lib/jwt/algos/rsa.rb
jwt-2.2.1 lib/jwt/algos/rsa.rb
jwt-2.2.0 lib/jwt/algos/rsa.rb
jwt-2.2.0.pre.beta.0 lib/jwt/algos/rsa.rb
jwt-2.1.0 lib/jwt/algos/rsa.rb