Skip to content

Commit

Permalink
Avoid iterating the RSA_OPT_PARAMS twice
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinj committed Oct 30, 2022
1 parent 3b11042 commit 5be1d79
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/jwt/jwk/rsa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ def create_rsa_key_using_accessors(rsa_parameters) # rubocop:disable Metrics/Abc
end

def validate_rsa_parameters!(rsa_parameters)
return unless rsa_parameters[:d]
return unless rsa_parameters.key?(:d)

return if RSA_OPT_PARAMS.all? { |k| rsa_parameters.keys.include?(k) }
return if RSA_OPT_PARAMS.none? { |k| rsa_parameters.keys.include?(k) }
parameters = RSA_OPT_PARAMS - rsa_parameters.keys
return if parameters.empty? || parameters.size == RSA_OPT_PARAMS.size

raise JWT::JWKError, 'When one of p, q, dp, dq or qi is given all the other optimization parameters also needs to be defined' # https://www.rfc-editor.org/rfc/rfc7518.html#section-6.3.2
end
Expand Down

0 comments on commit 5be1d79

Please sign in to comment.