#digest #header #spec #proposed #openssl #http #default

http_digest_headers

Parial implementation of the proposed httpbis-digest-headers spec

1 unstable release

0.1.0 Dec 5, 2021

#8 in #proposed

MIT license

14KB
243 lines

HTTP Digest Headers

A partial implementation of http-digest-headers that is easily extensible for additional digest algoritms and crypto libs. For deets, read_the_docs


lib.rs:

Features

Crypto Support

Both OpenSSL and Ring are currently supported (with openssl as the default). But the crate is designed such that extending for additional crypto libs should be trivial. Just send me a PR!

  • use_openssl: This is the default
  • use_ring: Turn off default features and add use_ring
[dependencies]
http_digest_headers = { version="0.1.0", default-features = false, features ="use_ring" }

Examples

Generate a digest header value

use http_digest_headers::{DigestHeader, DigestMethod, Error};

fn make_digest_header() -> Result<String, Error> {
   // Generate some simple test data.  This can be anything.
   let data = b"this is some data";

   // Create a builder, and digest with both SHA-256 and SHA-512.
   let builder = DigestHeader::new()
   .with_method(DigestMethod::SHA256, data)?
   .with_method(DigestMethod::SHA512, data)?;

   // Generate the resulting strings for the digest header value.
   let header_value = format!("{}", builder);

   // The result:String can now be used in a digest header.  For instance,
   // for reqwest, you might use client.header("digest", result).
   Ok(header_value)
}

Dependencies

~0.6–4MB
~102K SLoC