Skip to content

Commit

Permalink
feat(s2n-quic-crypto): replace ring with aws-lc on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
camshaft committed Nov 17, 2023
1 parent 3c368f1 commit 4874179
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 35 deletions.
7 changes: 1 addition & 6 deletions quic/s2n-quic-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@ default = []
testing = []

[dependencies]
aws-lc-rs = { version = "1.5", default-features = false, features = ["aws-lc-sys"] }
cfg-if = "1"
lazy_static = "1"
s2n-codec = { version = "=0.31.0", path = "../../common/s2n-codec", default-features = false }
s2n-quic-core = { version = "=0.31.0", path = "../s2n-quic-core", default-features = false }
zeroize = { version = "1", default-features = false, features = ["derive"] }

[target.'cfg(target_os = "linux")'.dependencies]
aws-lc-rs = { version = "1.3", default-features = false, features = ["aws-lc-sys"] }

[target.'cfg(not(target_os = "linux"))'.dependencies]
ring = { version = "0.16", default-features = false }

[dev-dependencies]
aes = "0.8"
aes-gcm = "0.10"
Expand Down
28 changes: 0 additions & 28 deletions quic/s2n-quic-crypto/src/aesgcm/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,8 @@ impl aead::Aead for LessSafeKey {
type Nonce = [u8; NONCE_LEN];
type Tag = [u8; TAG_LEN];

#[inline]
#[cfg(not(target_os = "linux"))]
fn encrypt(
&self,
nonce: &[u8; NONCE_LEN],
aad: &[u8],
payload: &mut scatter::Buffer,
) -> aead::Result {
use s2n_codec::Encoder;

let nonce = Nonce::assume_unique_for_key(*nonce);
let aad = Aad::from(aad);

let buffer = payload.flatten();

let tag = {
let (input, _) = buffer.split_mut();

self.seal_in_place_separate_tag(nonce, aad, input)
.map_err(|_| aead::Error::INTERNAL_ERROR)?
};

buffer.write_slice(tag.as_ref());

Ok(())
}

// use the scatter API if we're using AWS-LC
#[inline]
#[cfg(target_os = "linux")]
fn encrypt(
&self,
nonce: &[u8; NONCE_LEN],
Expand Down
1 change: 0 additions & 1 deletion quic/s2n-quic-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ mod ctr;
mod ghash;
mod iv;

#[cfg(target_os = "linux")]
use aws_lc_rs as ring;

#[doc(hidden)]
Expand Down

0 comments on commit 4874179

Please sign in to comment.