Skip to content

Commit a5233a1

Browse files
test(s2n-quic-tls): remove openssl dev dependency (#3161)
1 parent ff97381 commit a5233a1

3 files changed

Lines changed: 14 additions & 25 deletions

File tree

examples/post-quantum/Cargo.toml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ s2n-quic = { version = "1", path = "../../quic/s2n-quic" }
1010
# enable the post-quantum feature in s2n-tls
1111
s2n-tls = { version = "*", features = ["pq"] }
1212
tokio = { version = "1", features = ["full"] }
13-
# Build the vendored version to make it easy to test.
14-
#
15-
# For a production build, it's probably better to link to the system dependency instead
16-
# so you automatically get security patches.
17-
#
18-
# NOTE: The version of the `openssl-sys` crate is not the same as OpenSSL itself.
19-
# Versions 1.0.1 - 3.0.0 are automatically discovered.
20-
openssl-sys = { version = "0.9", features = ["vendored"] }
2113

2214
[workspace]
2315
members = ["."]

quic/s2n-quic-tls/Cargo.toml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,10 @@ s2n-tls = { version = "0.3.31", features = ["quic"] }
2929
[dev-dependencies]
3030
checkers = "0.7"
3131
pin-project = { version = "1" }
32-
openssl = { version = "0.10" }
33-
# Build the vendored version to make it easy to test in dev
34-
#
35-
# NOTE: The version of the `openssl-sys` crate is not the same as OpenSSL itself.
36-
# Versions 1.0.1 - 3.0.0 are automatically discovered.
37-
openssl-sys = { version = "0.9", features = ["vendored"] }
32+
aws-lc-rs = "1.12"
3833
s2n-quic-core = { path = "../s2n-quic-core", features = ["testing"] }
3934
s2n-quic-rustls = { path = "../s2n-quic-rustls" }
4035

41-
# we don't use openssl-sys directly; it's just here to pin and vendor in dev
42-
[package.metadata.cargo-udeps.ignore]
43-
development = [ "openssl-sys" ]
44-
4536
[lints.rust.unexpected_cfgs]
4637
level = "warn"
4738
check-cfg = [

quic/s2n-quic-tls/src/tests.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
use crate::{certificate, client, server};
5+
use aws_lc_rs::{
6+
digest::{self, Digest},
7+
signature::{EcdsaKeyPair, ECDSA_P256_SHA256_ASN1_SIGNING},
8+
};
59
use core::{
610
sync::atomic::{AtomicBool, AtomicU8, Ordering},
711
task::Poll,
812
};
9-
use openssl::{ec::EcKey, ecdsa::EcdsaSig};
1013
use pin_project::pin_project;
1114
use s2n_quic_core::{
1215
crypto::tls::{
1316
self,
1417
testing::{
15-
certificates::{CERT_PEM, KEY_PEM, UNTRUSTED_CERT_PEM, UNTRUSTED_KEY_PEM},
18+
certificates::{CERT_PEM, KEY_DER, KEY_PEM, UNTRUSTED_CERT_PEM, UNTRUSTED_KEY_PEM},
1619
server_params,
1720
},
1821
ConnectionInfo, Endpoint,
@@ -146,12 +149,15 @@ impl ConnectionFuture for MyPrivateKeyFuture {
146149
let mut in_buf = vec![0; in_buf_size];
147150
op.input(&mut in_buf)?;
148151

149-
let key = EcKey::private_key_from_pem(KEY_PEM.as_bytes())
150-
.expect("Failed to create EcKey from pem");
151-
let sig = EcdsaSig::sign(&in_buf, &key).expect("Failed to sign input");
152-
let out = sig.to_der().expect("Failed to convert signature to der");
152+
let key = EcdsaKeyPair::from_pkcs8(&ECDSA_P256_SHA256_ASN1_SIGNING, KEY_DER)
153+
.expect("Failed to create EcdsaKeyPair from pkcs8");
154+
// s2n-tls hands us the already-computed digest, so import it and sign it
155+
// directly rather than re-hashing the input.
156+
let digest =
157+
Digest::import_less_safe(&in_buf, &digest::SHA256).expect("Failed to import digest");
158+
let sig = key.sign_digest(&digest).expect("Failed to sign input");
153159

154-
op.set_output(conn, &out)?;
160+
op.set_output(conn, sig.as_ref())?;
155161
Poll::Ready(Ok(()))
156162
}
157163
}

0 commit comments

Comments
 (0)