Update sha dependencies

This commit is contained in:
Aode (lion) 2021-12-13 12:34:17 -06:00
parent 4bd4f0f797
commit 1c7c7ef51e
3 changed files with 14 additions and 24 deletions

View file

@ -1,7 +1,7 @@
[package] [package]
name = "http-signature-normalization-reqwest" name = "http-signature-normalization-reqwest"
description = "An HTTP Signatures library that leaves the signing to you" description = "An HTTP Signatures library that leaves the signing to you"
version = "0.3.1" version = "0.4.0"
authors = ["asonix <asonix@asonix.dog>"] authors = ["asonix <asonix@asonix.dog>"]
license-file = "LICENSE" license-file = "LICENSE"
readme = "README.md" readme = "README.md"
@ -29,8 +29,8 @@ http = "0.2.0"
http-signature-normalization = { version = "0.5.1", path = ".." } http-signature-normalization = { version = "0.5.1", path = ".." }
reqwest = { version = "0.11", default-features = false, features = ["json"] } reqwest = { version = "0.11", default-features = false, features = ["json"] }
reqwest-middleware = { version = "0.1.2", optional = true } reqwest-middleware = { version = "0.1.2", optional = true }
sha2 = { version = "0.9", optional = true } sha2 = { version = "0.10", optional = true }
sha3 = { version = "0.9", optional = true } sha3 = { version = "0.10", optional = true }
thiserror = "1.0" thiserror = "1.0"
tokio = { version = "1", default-features = false, features = ["rt"], optional = true } tokio = { version = "1", default-features = false, features = ["rt"], optional = true }

View file

@ -1,9 +1,12 @@
use sha2::{Sha224, Sha256, Sha384, Sha512, Sha512Trunc224, Sha512Trunc256}; use sha2::{Sha224, Sha256, Sha384, Sha512};
use super::DigestCreate; use super::DigestCreate;
fn create(digest: &mut impl sha2::Digest, input: &[u8]) -> String { fn create<D: sha2::Digest + sha2::digest::FixedOutputReset>(
digest.update(input); digest: &mut D,
input: &[u8],
) -> String {
sha2::Digest::update(digest, input);
base64::encode(&digest.finalize_reset()) base64::encode(&digest.finalize_reset())
} }
@ -38,19 +41,3 @@ impl DigestCreate for Sha512 {
create(self, input) create(self, input)
} }
} }
impl DigestCreate for Sha512Trunc224 {
const NAME: &'static str = "SHA-512-224";
fn compute(&mut self, input: &[u8]) -> String {
create(self, input)
}
}
impl DigestCreate for Sha512Trunc256 {
const NAME: &'static str = "SHA-512-256";
fn compute(&mut self, input: &[u8]) -> String {
create(self, input)
}
}

View file

@ -5,8 +5,11 @@ use sha3::{
use super::DigestCreate; use super::DigestCreate;
fn create(digest: &mut impl sha3::Digest, input: &[u8]) -> String { fn create<D: sha3::Digest + sha3::digest::FixedOutputReset>(
digest.update(input); digest: &mut D,
input: &[u8],
) -> String {
sha3::Digest::update(digest, input);
base64::encode(&digest.finalize_reset()) base64::encode(&digest.finalize_reset())
} }