Module: JWT::Algos

Extended by:
Algos
Included in:
Algos
Defined in:
lib/jwt/algos.rb,
lib/jwt/algos/ps.rb,
lib/jwt/algos/rsa.rb,
lib/jwt/algos/hmac.rb,
lib/jwt/algos/none.rb,
lib/jwt/algos/ecdsa.rb,
lib/jwt/algos/eddsa.rb,
lib/jwt/algos/hmac_rbnacl.rb,
lib/jwt/algos/unsupported.rb,
lib/jwt/algos/algo_wrapper.rb,
lib/jwt/algos/hmac_rbnacl_fixed.rb

Defined Under Namespace

Modules: Ecdsa, Eddsa, Hmac, HmacRbNaCl, HmacRbNaClFixed, None, Ps, Rsa, Unsupported Classes: AlgoWrapper

Constant Summary collapse

ALGOS =
[Algos::Ecdsa,
         Algos::Rsa,
         Algos::Eddsa,
         Algos::Ps,
         Algos::None,
         Algos::Unsupported].tap do |l|
  if ::JWT.rbnacl_6_or_greater?
    require_relative 'algos/hmac_rbnacl'
    l.unshift(Algos::HmacRbNaCl)
  elsif ::JWT.rbnacl?
    require_relative 'algos/hmac_rbnacl_fixed'
    l.unshift(Algos::HmacRbNaClFixed)
  else
    l.unshift(Algos::Hmac)
  end
end.freeze

Instance Method Summary collapse

Instance Method Details

#create(algorithm) ⇒ Object



44
45
46
# File 'lib/jwt/algos.rb', line 44

def create(algorithm)
  Algos::AlgoWrapper.new(*find(algorithm))
end

#find(algorithm) ⇒ Object



40
41
42
# File 'lib/jwt/algos.rb', line 40

def find(algorithm)
  indexed[algorithm && algorithm.downcase]
end

#implementation?(algorithm) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/jwt/algos.rb', line 48

def implementation?(algorithm)
  (algorithm.respond_to?(:valid_alg?) && algorithm.respond_to?(:verify)) ||
    (algorithm.respond_to?(:alg) && algorithm.respond_to?(:sign))
end