Sha256: 150b661f4c3b1c1bf6986bf7d520994a79d95ce2f748ea1e3fe589cde9ac63d9
Contents?: true
Size: 1.22 KB
Versions: 4
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module JWT module JWA module Eddsa SUPPORTED = %w[ED25519 EdDSA].freeze SUPPORTED_DOWNCASED = SUPPORTED.map(&:downcase).freeze class << self def sign(algorithm, msg, key) unless key.is_a?(RbNaCl::Signatures::Ed25519::SigningKey) raise EncodeError, "Key given is a #{key.class} but has to be an RbNaCl::Signatures::Ed25519::SigningKey" end validate_algorithm!(algorithm) key.sign(msg) end def verify(algorithm, public_key, signing_input, signature) unless public_key.is_a?(RbNaCl::Signatures::Ed25519::VerifyKey) raise DecodeError, "key given is a #{public_key.class} but has to be a RbNaCl::Signatures::Ed25519::VerifyKey" end validate_algorithm!(algorithm) public_key.verify(signature, signing_input) rescue RbNaCl::CryptoError false end private def validate_algorithm!(algorithm) return if SUPPORTED_DOWNCASED.include?(algorithm.downcase) raise IncorrectAlgorithm, "Algorithm #{algorithm} not supported. Supported algoritms are #{SUPPORTED.join(', ')}" end end end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
blacklight-spotlight-3.6.0.beta8 | vendor/bundle/ruby/3.2.0/gems/jwt-2.8.2/lib/jwt/jwa/eddsa.rb |
jwt-2.8.2 | lib/jwt/jwa/eddsa.rb |
jwt-2.8.1 | lib/jwt/jwa/eddsa.rb |
jwt-2.8.0 | lib/jwt/jwa/eddsa.rb |