diff --git a/src/decoding.rs b/src/decoding.rs index 145a24d8..ab51299c 100644 --- a/src/decoding.rs +++ b/src/decoding.rs @@ -156,12 +156,10 @@ fn verify_signature<'a>( return Err(new_error(ErrorKind::MissingAlgorithm)); } - if validation.validate_signature { - for alg in &validation.algorithms { - if key.family != alg.family() { - return Err(new_error(ErrorKind::InvalidAlgorithm)); - } - } + if validation.validate_signature + && !validation.algorithms.iter().any(|alg| key.family == alg.family()) + { + return Err(new_error(ErrorKind::InvalidAlgorithm)); } let (signature, message) = expect_two!(token.rsplitn(2, '.'));