mirror of
https://git.asonix.dog/asonix/http-signature-normalization.git
synced 2024-11-25 10:51:01 +00:00
Update sha dependencies
This commit is contained in:
parent
1c7c7ef51e
commit
d42c0464a4
3 changed files with 23 additions and 49 deletions
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "http-signature-normalization-actix"
|
name = "http-signature-normalization-actix"
|
||||||
description = "An HTTP Signatures library that leaves the signing to you"
|
description = "An HTTP Signatures library that leaves the signing to you"
|
||||||
version = "0.5.0-beta.13"
|
version = "0.5.0-beta.14"
|
||||||
authors = ["asonix <asonix@asonix.dog>"]
|
authors = ["asonix <asonix@asonix.dog>"]
|
||||||
license-file = "LICENSE"
|
license-file = "LICENSE"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
@ -35,8 +35,8 @@ base64 = { version = "0.13", optional = true }
|
||||||
chrono = "0.4.6"
|
chrono = "0.4.6"
|
||||||
futures-util = { version = "0.3", default-features = false }
|
futures-util = { version = "0.3", default-features = false }
|
||||||
http-signature-normalization = { version = "0.5.1", path = ".." }
|
http-signature-normalization = { version = "0.5.1", path = ".." }
|
||||||
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 = ["sync"] }
|
tokio = { version = "1", default-features = false, features = ["sync"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::digest::DigestName;
|
use crate::digest::DigestName;
|
||||||
use sha2::{Sha224, Sha256, Sha384, Sha512, Sha512Trunc224, Sha512Trunc256};
|
use sha2::{Sha224, Sha256, Sha384, Sha512};
|
||||||
|
|
||||||
impl DigestName for Sha224 {
|
impl DigestName for Sha224 {
|
||||||
const NAME: &'static str = "SHA-244";
|
const NAME: &'static str = "SHA-244";
|
||||||
|
@ -17,21 +17,16 @@ impl DigestName for Sha512 {
|
||||||
const NAME: &'static str = "SHA-512";
|
const NAME: &'static str = "SHA-512";
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DigestName for Sha512Trunc224 {
|
|
||||||
const NAME: &'static str = "SHA-512-224";
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DigestName for Sha512Trunc256 {
|
|
||||||
const NAME: &'static str = "SHA-512-256";
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
mod client {
|
mod client {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::digest::DigestCreate;
|
use crate::digest::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())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,18 +53,6 @@ mod client {
|
||||||
create(self, input)
|
create(self, input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DigestCreate for Sha512Trunc224 {
|
|
||||||
fn compute(&mut self, input: &[u8]) -> String {
|
|
||||||
create(self, input)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DigestCreate for Sha512Trunc256 {
|
|
||||||
fn compute(&mut self, input: &[u8]) -> String {
|
|
||||||
create(self, input)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
|
@ -78,7 +61,11 @@ mod server {
|
||||||
use crate::digest::{DigestPart, DigestVerify};
|
use crate::digest::{DigestPart, DigestVerify};
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
fn verify(digest: &mut impl sha2::Digest, name: &str, parts: &[DigestPart]) -> bool {
|
fn verify<D: sha2::Digest + sha2::digest::FixedOutputReset>(
|
||||||
|
digest: &mut D,
|
||||||
|
name: &str,
|
||||||
|
parts: &[DigestPart],
|
||||||
|
) -> bool {
|
||||||
if let Some(part) = parts
|
if let Some(part) = parts
|
||||||
.iter()
|
.iter()
|
||||||
.find(|p| p.algorithm.to_lowercase() == name.to_lowercase())
|
.find(|p| p.algorithm.to_lowercase() == name.to_lowercase())
|
||||||
|
@ -143,24 +130,4 @@ mod server {
|
||||||
verify(self, Self::NAME, parts)
|
verify(self, Self::NAME, parts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DigestVerify for Sha512Trunc224 {
|
|
||||||
fn update(&mut self, part: &[u8]) {
|
|
||||||
sha2::Digest::update(self, part);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn verify(&mut self, parts: &[DigestPart]) -> bool {
|
|
||||||
verify(self, Self::NAME, parts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DigestVerify for Sha512Trunc256 {
|
|
||||||
fn update(&mut self, part: &[u8]) {
|
|
||||||
sha2::Digest::update(self, part);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn verify(&mut self, parts: &[DigestPart]) -> bool {
|
|
||||||
verify(self, Self::NAME, parts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,10 @@ mod client {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::digest::DigestCreate;
|
use crate::digest::DigestCreate;
|
||||||
|
|
||||||
fn create(digest: &mut impl sha3::Digest, input: &[u8]) -> String {
|
fn create<D: sha3::Digest + sha3::digest::FixedOutputReset>(
|
||||||
|
digest: &mut D,
|
||||||
|
input: &[u8],
|
||||||
|
) -> String {
|
||||||
digest.update(input);
|
digest.update(input);
|
||||||
base64::encode(&digest.finalize_reset())
|
base64::encode(&digest.finalize_reset())
|
||||||
}
|
}
|
||||||
|
@ -111,7 +114,11 @@ mod server {
|
||||||
use crate::digest::{DigestPart, DigestVerify};
|
use crate::digest::{DigestPart, DigestVerify};
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
fn verify(digest: &mut impl sha3::Digest, name: &str, parts: &[DigestPart]) -> bool {
|
fn verify<D: sha3::Digest + sha3::digest::FixedOutputReset>(
|
||||||
|
digest: &mut D,
|
||||||
|
name: &str,
|
||||||
|
parts: &[DigestPart],
|
||||||
|
) -> bool {
|
||||||
if let Some(part) = parts
|
if let Some(part) = parts
|
||||||
.iter()
|
.iter()
|
||||||
.find(|p| p.algorithm.to_lowercase() == name.to_lowercase())
|
.find(|p| p.algorithm.to_lowercase() == name.to_lowercase())
|
||||||
|
|
Loading…
Reference in a new issue