mirror of
https://git.asonix.dog/asonix/http-signature-normalization.git
synced 2024-11-21 17:00:59 +00:00
Use ring for reqwest example
This commit is contained in:
parent
ec73fe55c9
commit
c1d36000dd
3 changed files with 29 additions and 34 deletions
|
@ -21,7 +21,7 @@ sha-3 = ["digest", "dep:sha3"]
|
|||
|
||||
[[example]]
|
||||
name = "client"
|
||||
required-features = ["default-spawner", "sha-2"]
|
||||
required-features = ["default-spawner", "ring"]
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.71"
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use http_signature_normalization_reqwest::prelude::*;
|
||||
use http_signature_normalization_reqwest::{digest::ring::Sha256, prelude::*};
|
||||
use reqwest::{
|
||||
header::{ACCEPT, USER_AGENT},
|
||||
Client,
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
async fn request(config: Config) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
let digest = Sha256::new();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
//! Types for creating digests with the `ring` cryptography library
|
||||
|
||||
use super::DigestCreate;
|
||||
|
||||
/// A Sha256 digest backed by ring
|
||||
#[derive(Clone)]
|
||||
pub struct Sha256 {
|
||||
|
@ -78,11 +80,6 @@ impl Default for Sha512 {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
mod client {
|
||||
use super::*;
|
||||
use crate::digest::DigestCreate;
|
||||
|
||||
fn create(mut context: ring::digest::Context, input: &[u8]) -> String {
|
||||
context.update(input);
|
||||
let digest = context.finish();
|
||||
|
@ -112,4 +109,3 @@ mod client {
|
|||
create(self.ctx.clone(), input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue