Skip to main content

verify_any_content_digest_header

Function verify_any_content_digest_header 

Source
pub fn verify_any_content_digest_header(
    header: &str,
    body: &[u8],
    accepted: &[DigestAlgorithm],
) -> Result<DigestAlgorithm, Error>
Expand description

Verifies that the Content-Digest: header carries at least one matching entry across the supplied accepted algorithms.

Iterates accepted in caller-supplied priority order; the first algorithm whose dictionary entry matches the body’s hash is taken as proof. Algorithms in the header that are not in accepted are ignored. If no entry verifies (because none of the accepted algorithms are present, or every matching entry mismatches), the last error encountered is propagated.

§Errors

Returns Error::UnsupportedDigestAlgorithm when none of the accepted algorithms appear in the header, Error::InvalidHeader on parse failure, and Error::DigestMismatch when an accepted algorithm appears but its byte sequence does not match the body.