From a2bc8c03ee44d48ab7161b8c96f2bccc2c76dfaa Mon Sep 17 00:00:00 2001 From: asonix Date: Fri, 17 Jan 2020 16:56:22 -0600 Subject: [PATCH] Implement DigestVerify for Vec, &mut [] --- .../src/digest/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/http-signature-normalization-warp/src/digest/mod.rs b/http-signature-normalization-warp/src/digest/mod.rs index 0eadf6f..bc8977e 100644 --- a/http-signature-normalization-warp/src/digest/mod.rs +++ b/http-signature-normalization-warp/src/digest/mod.rs @@ -87,6 +87,24 @@ fn parse_digest_header() -> impl Filter,), Error = Re header::header::("Digest").map(|d: Digest| d.parts) } +impl DigestVerify for Vec +where + T: DigestVerify, +{ + fn verify(&mut self, parts: &[DigestPart], payload: &[u8]) -> bool { + self.iter_mut().any(|d| d.verify(parts, payload)) + } +} + +impl DigestVerify for &mut [T] +where + T: DigestVerify, +{ + fn verify(&mut self, parts: &[DigestPart], payload: &[u8]) -> bool { + self.iter_mut().any(|d| d.verify(parts, payload)) + } +} + impl FromStr for DigestPart { type Err = ParseDigestError;