Update examples to use ring

This commit is contained in:
asonix 2023-08-04 18:01:41 -05:00
parent ea964decc8
commit 8750783667
4 changed files with 13 additions and 6 deletions

View file

@ -21,11 +21,11 @@ ring = ["digest", "dep:ring"]
[[example]]
name = "server"
required-features = ["server", "sha-2"]
required-features = ["server", "ring"]
[[example]]
name = "client"
required-features = ["client", "sha-2"]
required-features = ["client", "ring"]
[dependencies]
actix-http = { version = "3.0.2", default-features = false }

View file

@ -1,7 +1,6 @@
use actix_rt::task::JoinError;
use awc::Client;
use http_signature_normalization_actix::prelude::*;
use sha2::{Digest, Sha256};
use http_signature_normalization_actix::{digest::ring::Sha256, prelude::*, Canceled};
use tracing::{error, info};
use tracing_error::ErrorLayer;
use tracing_subscriber::{layer::SubscriberExt, EnvFilter};
@ -75,3 +74,9 @@ impl From<JoinError> for MyError {
MyError::Canceled
}
}
impl From<Canceled> for MyError {
fn from(_: Canceled) -> Self {
MyError::Canceled
}
}

View file

@ -1,6 +1,5 @@
use actix_web::{http::StatusCode, web, App, HttpRequest, HttpResponse, HttpServer, ResponseError};
use http_signature_normalization_actix::prelude::*;
use sha2::{Digest, Sha256};
use http_signature_normalization_actix::{digest::ring::Sha256, prelude::*};
use std::future::{ready, Ready};
use tracing::info;
use tracing_actix_web::TracingLogger;

View file

@ -3,16 +3,19 @@
use crate::digest::DigestName;
/// A Sha256 digest backed by ring
#[derive(Clone)]
pub struct Sha256 {
ctx: ring::digest::Context,
}
/// A Sha384 digest backed by ring
#[derive(Clone)]
pub struct Sha384 {
ctx: ring::digest::Context,
}
/// A Sha512 digest backed by ring
#[derive(Clone)]
pub struct Sha512 {
ctx: ring::digest::Context,
}