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]] [[example]]
name = "server" name = "server"
required-features = ["server", "sha-2"] required-features = ["server", "ring"]
[[example]] [[example]]
name = "client" name = "client"
required-features = ["client", "sha-2"] required-features = ["client", "ring"]
[dependencies] [dependencies]
actix-http = { version = "3.0.2", default-features = false } actix-http = { version = "3.0.2", default-features = false }

View file

@ -1,7 +1,6 @@
use actix_rt::task::JoinError; use actix_rt::task::JoinError;
use awc::Client; use awc::Client;
use http_signature_normalization_actix::prelude::*; use http_signature_normalization_actix::{digest::ring::Sha256, prelude::*, Canceled};
use sha2::{Digest, Sha256};
use tracing::{error, info}; use tracing::{error, info};
use tracing_error::ErrorLayer; use tracing_error::ErrorLayer;
use tracing_subscriber::{layer::SubscriberExt, EnvFilter}; use tracing_subscriber::{layer::SubscriberExt, EnvFilter};
@ -75,3 +74,9 @@ impl From<JoinError> for MyError {
MyError::Canceled 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 actix_web::{http::StatusCode, web, App, HttpRequest, HttpResponse, HttpServer, ResponseError};
use http_signature_normalization_actix::prelude::*; use http_signature_normalization_actix::{digest::ring::Sha256, prelude::*};
use sha2::{Digest, Sha256};
use std::future::{ready, Ready}; use std::future::{ready, Ready};
use tracing::info; use tracing::info;
use tracing_actix_web::TracingLogger; use tracing_actix_web::TracingLogger;

View file

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