diff --git a/lib/jwt/jwk/rsa.rb b/lib/jwt/jwk/rsa.rb index 30e21a38..c909b635 100644 --- a/lib/jwt/jwk/rsa.rb +++ b/lib/jwt/jwk/rsa.rb @@ -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