Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 2 features: ring & aws-lc-rs #179

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tokio = { version = "1.19", features = [
"io-util",
], optional = true }
tokio-util = { version = "0.7.3", features = ["codec", "io"], optional = true }
tokio-rustls = { version = "0.26", optional = true }
tokio-rustls = { version = "0.26", optional = true, default-features = false, features = ["logging", "tls12"]}
futures = { version = "0.3", optional = true }
async-trait = { version = "0.1", optional = true }
rand = { version = "0.8", optional = true }
Expand All @@ -33,6 +33,7 @@ hex = { version = "0.4", optional = true }
## scram libraries
base64 = { version = "0.22", optional = true }
ring = { version = "0.17", optional = true }
aws-lc-rs = { version = "1.7", optional = true }
stringprep = { version = "0.1.2", optional = true }
x509-certificate = { version = "0.23", optional = true }
## types
Expand All @@ -43,7 +44,11 @@ postgres-types = { version = "0.2", features = [
chrono = { version = "0.4", features = ["std"], optional = true }

[features]
default = ["server-api"]
default = ["server-api-ring"]
server-api-ring = ["server-api", "ring"]
server-api-aws-lc-rs = ["server-api", "aws-lc-rs"]
ring = ["dep:ring", "tokio-rustls/ring"]
aws-lc-rs = ["dep:aws-lc-rs", "tokio-rustls/aws-lc-rs"]
server-api = [
"dep:tokio",
"dep:tokio-util",
Expand All @@ -54,7 +59,6 @@ server-api = [
"dep:md5",
"dep:hex",
"dep:base64",
"dep:ring",
"dep:stringprep",
"dep:x509-certificate",
"dep:postgres-types",
Expand Down
8 changes: 5 additions & 3 deletions src/api/auth/scram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ use base64::engine::general_purpose::STANDARD;
use base64::Engine;
use bytes::Bytes;
use futures::{Sink, SinkExt};
use ring::digest;
use ring::hmac;
use ring::pbkdf2;
use tokio::sync::Mutex;
use x509_certificate::certificate::CapturedX509Certificate;
use x509_certificate::SignatureAlgorithm;

#[cfg(not(feature = "ring"))]
use aws_lc_rs::{digest, hmac, pbkdf2};
#[cfg(feature = "ring")]
use ring::{digest, hmac, pbkdf2};

use crate::api::auth::{AuthSource, LoginInfo, Password};
use crate::api::{ClientInfo, MakeHandler, PgWireConnectionState};
use crate::error::{PgWireError, PgWireResult};
Expand Down
Loading