Skip to content

Commit

Permalink
Use the same crypto backend as rustls on our side too
Browse files Browse the repository at this point in the history
  • Loading branch information
paolobarbolini authored and Jarema committed May 4, 2024
1 parent 3ead110 commit 276d61d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -140,7 +140,7 @@ jobs:
- name: Install cargo hack
run: cargo install cargo-hack
- name: Check lint
run: cargo hack check --feature-powerset --no-dev-deps -p async-nats
run: cargo hack check --feature-powerset --at-least-one-of aws-lc-rs,ring --no-dev-deps -p async-nats


check_licenses:
Expand Down
7 changes: 4 additions & 3 deletions async-nats/Cargo.toml
Expand Up @@ -14,6 +14,7 @@ keywords = ["nats", "client", "messaging", "api"]
categories = ["network-programming", "api-bindings"]

[dependencies]
aws-lc-rs = { version = "1.6", optional = true }
memchr = "2.4"
bytes = { version = "1.4.0", features = ["serde"] }
futures = { version = "0.3.28", default-features = false, features = ["std"] }
Expand All @@ -35,7 +36,7 @@ tracing = "0.1"
thiserror = "1.0"
base64 = "0.22"
tryhard = "0.5"
ring = "0.17"
ring = { version = "0.17", optional = true }
rand = "0.8"
webpki = { package = "rustls-webpki", version = "0.102" }
portable-atomic = "1"
Expand All @@ -60,8 +61,8 @@ num = "0.4.1"
default = ["server_2_10", "ring"]
# Enables Service API for the client.
service = []
aws-lc-rs = ["tokio-rustls/aws-lc-rs"]
ring = ["tokio-rustls/ring"]
aws-lc-rs = ["dep:aws-lc-rs", "tokio-rustls/aws-lc-rs"]
ring = ["dep:ring", "tokio-rustls/ring"]
fips = ["aws-lc-rs", "tokio-rustls/fips"]
# All experimental features are part of this feature flag.
experimental = ["service"]
Expand Down
10 changes: 9 additions & 1 deletion async-nats/src/crypto.rs
@@ -1,4 +1,12 @@
use ring::digest::{Context, SHA256};
#[cfg(feature = "aws-lc-rs")]
use aws_lc_rs as crypto_backend;
#[cfg(not(feature = "aws-lc-rs"))]
use ring as crypto_backend;

#[cfg(not(any(feature = "aws-lc-rs", feature = "ring")))]
compile_error!("Please enable the `aws-lc-rs` or `ring` feature");

use crypto_backend::digest::{Context, SHA256};

pub(crate) struct Sha256(Context);

Expand Down

0 comments on commit 276d61d

Please sign in to comment.