mirror of
https://git.asonix.dog/asonix/http-signature-normalization.git
synced 2024-11-24 18:31:01 +00:00
Update sha2 and sha3
This commit is contained in:
parent
85932442fe
commit
b0080ae668
3 changed files with 10 additions and 10 deletions
|
@ -33,8 +33,8 @@ chrono = "0.4.6"
|
|||
futures = "0.3"
|
||||
http-signature-normalization = { version = "0.5.0", path = ".." }
|
||||
log = "0.4"
|
||||
sha2 = { version = "0.8", optional = true }
|
||||
sha3 = { version = "0.8", optional = true }
|
||||
sha2 = { version = "0.9", optional = true }
|
||||
sha3 = { version = "0.9", optional = true }
|
||||
thiserror = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -4,8 +4,8 @@ use sha2::{Sha224, Sha256, Sha384, Sha512, Sha512Trunc224, Sha512Trunc256};
|
|||
use super::{DigestCreate, DigestPart, DigestVerify};
|
||||
|
||||
fn create(digest: &mut impl sha2::Digest, input: &[u8]) -> String {
|
||||
digest.input(input);
|
||||
base64::encode(&digest.result_reset())
|
||||
digest.update(input);
|
||||
base64::encode(&digest.finalize_reset())
|
||||
}
|
||||
|
||||
fn verify(digest: &mut impl sha2::Digest, name: &str, parts: &[DigestPart], bytes: &[u8]) -> bool {
|
||||
|
@ -14,8 +14,8 @@ fn verify(digest: &mut impl sha2::Digest, name: &str, parts: &[DigestPart], byte
|
|||
.find(|p| p.algorithm.to_lowercase() == name.to_lowercase())
|
||||
{
|
||||
debug!("Verifying digest type, {}", name);
|
||||
digest.input(bytes);
|
||||
let encoded = base64::encode(&digest.result_reset());
|
||||
digest.update(bytes);
|
||||
let encoded = base64::encode(&digest.finalize_reset());
|
||||
|
||||
return part.digest == encoded;
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ use sha3::{
|
|||
use super::{DigestCreate, DigestPart, DigestVerify};
|
||||
|
||||
fn create(digest: &mut impl sha2::Digest, input: &[u8]) -> String {
|
||||
digest.input(input);
|
||||
base64::encode(&digest.result_reset())
|
||||
digest.update(input);
|
||||
base64::encode(&digest.finalize_reset())
|
||||
}
|
||||
|
||||
fn verify(digest: &mut impl sha2::Digest, name: &str, parts: &[DigestPart], bytes: &[u8]) -> bool {
|
||||
|
@ -17,8 +17,8 @@ fn verify(digest: &mut impl sha2::Digest, name: &str, parts: &[DigestPart], byte
|
|||
.find(|p| p.algorithm.to_lowercase() == name.to_lowercase())
|
||||
{
|
||||
debug!("Verifying digest type, {}", name);
|
||||
digest.input(bytes);
|
||||
let encoded = base64::encode(&digest.result_reset());
|
||||
digest.update(bytes);
|
||||
let encoded = base64::encode(&digest.finalize_reset());
|
||||
|
||||
return part.digest == encoded;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue