Skip to content

Commit 7ee98f6

Browse files
0x676e67bwesterbghedoevanrittenhousekornelski
authored
sync upstream (#54)
* RTG-3333 Support X25519MLKEM768 by default, but don't sent it as client X25519MLKEM768 is the standardised successor of the preliminary X25519Kyber768Draft00. Latest browsers have switched to X25519MLKEM768. Cloudflare supports both on the edge. We've had support for X25519MLKEM768 in this crate for a while, but didn't enable by default. We're now enabling serverside support by default. We also let clients advertise support when set to kx-client-pq-supported. We don't enable support by default yet for clients set to kx-client-pq-preferred, as that would cause an extra round-trip due to HelloRetryRequest if the server doesn't support X25519MLKEM768 yet. BoringSSL against which we build must support X25519MLKEM768, otherwise this will fail. * replace once_cell with LazyLock We can drop the once_cell dependency since the same functionality is implemented in std now. Requires bumping MSRV to 1.80. * fix manual_c_str_literals clippy warning * chore: Fix docs on SslRef::replace_ex_data * Detailed error codes * Clean up boring_sys::init() We don't need the workaround that was initially introduced for a bug in openssl, and OPENSSL_init_ssl always calls into CRYPTO_library_init on boringssl, so just call it explicitly. * Expose EVP_HPKE_KEY * Expose client/server-side ECH Resolves cloudflare/boring#282 * Clean up ECH tests * Expose SSL_set_enable_ech_grease * Use corresponds macro * build: Fix the build for 32-bit Linux platform (#312) build: Fix the build for 32-bit Linux platform * Set CMAKE_BUILD_PARALLEL_LEVEL to available_parallelism cmake-rs' jobserver doesn't work reliably, if at all. One workaround is to set CMAKE_BUILD_PARALLEL_LEVEL to available_parallelism(). On my machine it shaves ~35 seconds off of boring-sys builds. * Expose SSL_CTX_set1_ech_keys from SslContextRef We currently expose this method on `SslContextBuilder`, which is fine for bootstrapping an `SSL_CTX`, but subsequent attempts to set ECH keys (like during key rotation) can only happen via `SslContextRef`. Also update the method on the builder to take an immutable reference to self because the API is thread safe. * Bump cmake-rs to improve Mac OS build parallelism There's a bug on OSX that prevents the CMake jobserver from working properly, and so CMake defaults to a single-threaded build. It's not clear when this is actually going to get fixed, so recent versions of cmake-rs just disable the jobserver and have CMake fall back to the number of available cores: rust-lang/cmake-rs#229 This means we don't need e6833b0 * Release 4.14.0 (#317) * Actually expose SslEchKeys * Address clippy lints * Revert "Refactor!: Introduce a Cargo feature for optional Hyper 0 support" This reverts commit 49d5a61. * Revert "Refactor!: Remove strict `TokioIo` response requirement from `hyper_boring::v1::HttpsConnector`" This reverts commit e518c24. * Introduce a builder pattern for SslEchKeys + make set_ech_keys take a reference (#320) Previously, set_ech_keys would consume the SslEchKeys struct to enforce the requirement that the struct is immutable after initializing it on a SSL_CTX. The problem with this is that it requires applications to needlessly reallocate the SslEchKeys struct if they want to initialize keys on multiple SSL_CTXs, which is a pretty common pattern. To work around this, we introduce a builder (SslEchKeysBuilder) that requires mutable access to add keys to the underlying struct. set_ech_keys takes in a reference to SslEchKeys, which can only be made via consuming the builder. * Revert cmake bump (for now) as it is overly restrictive (#321) Some users of boring have issues with newer versions of cmake. Because we have an alternative solution, we can hold off on the bump for now. --------- Co-authored-by: Bas Westerbaan <[email protected]> Co-authored-by: Alessandro Ghedini <[email protected]> Co-authored-by: Evan Rittenhouse <[email protected]> Co-authored-by: Kornel <[email protected]> Co-authored-by: Rushil Mehra <[email protected]> Co-authored-by: Rushil Mehra <[email protected]>
1 parent 372501f commit 7ee98f6

File tree

8 files changed

+82
-22
lines changed

8 files changed

+82
-22
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,5 @@ jobs:
366366
name: Run `rpk,underscore-wildcards` tests
367367
- run: cargo test --features pq-experimental,rpk,underscore-wildcards
368368
name: Run `pq-experimental,rpk,underscore-wildcards` tests
369-
- run: cargo test -p hyper-boring --features hyper1-runtime
369+
- run: cargo test -p hyper-boring --features hyper1
370370
name: Run hyper 1.0 tests for hyper-boring
371-
- run: cargo test -p hyper-boring --features hyper0-runtime
372-
name: Run hyper 0. tests for hyper-boring

RELEASE_NOTES

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
2+
4.14.0
3+
- 2024-01-27 Set CMAKE_BUILD_PARALLEL_LEVEL to available_parallelism
4+
- 2025-02-14 build: Fix the build for 32-bit Linux platform (#312)
5+
- 2024-11-30 Use corresponds macro
6+
- 2025-02-12 Expose SSL_set_enable_ech_grease
7+
- 2025-02-12 Clean up ECH tests
8+
- 2025-02-10 Expose client/server-side ECH
9+
- 2025-02-10 Expose EVP_HPKE_KEY
10+
- 2025-02-10 Clean up boring_sys::init()
11+
- 2024-11-27 Detailed error codes
12+
- 2025-02-04 chore: Fix docs on SslRef::replace_ex_data
13+
- 2025-01-22 fix manual_c_str_literals clippy warning
14+
- 2025-01-22 replace once_cell with LazyLock
15+
- 2025-01-13 RTG-3333 Support X25519MLKEM768 by default, but don't sent it as client
16+
- 2024-07-31 Allow dead_code instead of disabling clippy entirely for bindgen
17+
- 2024-11-12 Remove INVALID_CALL from mid-handshake error message
18+
- 2024-08-16 Fix bug with accessing memzero'd X509StoreContext in tests
19+
- 2024-08-16 Support linking with a runtime cpp library
20+
- 2024-12-06 Refactor!: Introduce a Cargo feature for optional Hyper 0 support
21+
- 2024-12-06 Refactor!: Remove strict `TokioIo` response requirement from `hyper_boring::v1::HttpsConnector`
22+
123
4.13.0
224
- 2024-11-26 Sync X509StoreBuilder with openssl
325
- 2024-11-26 Sync X509VerifyFlags with openssl
@@ -6,15 +28,15 @@
628
- 2024-11-28 Clippy
729
- 2024-03-11 Fix Windows build
830

9-
4.12.0
31+
4.12.0
1032
- 2024-11-20 Add bindings for SSL_CB_ACCEPT_EXIT and SSL_CB_CONNECT_EXIT
1133
- 2024-10-22 (ci): brew link x86 toolchain for macos13 runner
1234
- 2024-10-22 Skip bindgen 0.70's layout tests before Rust 1.77
1335
- 2024-10-18 Add `set_cert_verify_callback` (`SSL_CTX_set_cert_verify`)
1436

1537
4.11.0
1638
- 2024-10-17 boring-sys: include HPKE header file for bindgen
17-
- 2024-10-17 Add "fips-compat" feature
39+
- 2024-10-17 Add "fips-compat" feature (#286)
1840
- 2024-09-25 Create semgrep.yml
1941

2042
4.10.3
@@ -47,6 +69,7 @@
4769
- 2024-08-04 Properly handle `Option<i32>` in `SslRef::set_curves`
4870

4971
4.9.0
72+
- 2024-08-02 Actually Release 4.9.0
5073
- 2024-08-02 Guard against empty strings given to select_next_proto (#252)
5174
- 2024-08-01 Document `SslCurve::nid()`
5275
- 2024-08-01 Add SslCurve::to_nid() and remove SslCurveId

boring-sys/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ include = [
1919
"/LICENSE-MIT",
2020
"/cmake/*.cmake",
2121
# boringssl (non-FIPS)
22+
"/deps/boringssl/src/util/32-bit-toolchain.cmake",
2223
"/deps/boringssl/**/*.[chS]",
2324
"/deps/boringssl/**/*.asm",
2425
"/deps/boringssl/sources.json",
@@ -31,6 +32,7 @@ include = [
3132
"/deps/boringssl/**/sources.cmake",
3233
"/deps/boringssl/LICENSE",
3334
# boringssl (FIPS)
35+
"/deps/boringssl-fips/src/util/32-bit-toolchain.cmake",
3436
"/deps/boringssl-fips/**/*.[chS]",
3537
"/deps/boringssl-fips/**/*.asm",
3638
"/deps/boringssl-fips/**/*.pl",

boring-sys/build/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl Env {
165165
opt_level: target_var("OPT_LEVEL"),
166166
android_ndk_home: target_var("ANDROID_NDK_HOME").map(Into::into),
167167
cmake_toolchain_file: target_var("CMAKE_TOOLCHAIN_FILE").map(Into::into),
168-
cpp_runtime_lib: target_var("BORING_BSSL_RUST_CPPLIB").map(Into::into),
168+
cpp_runtime_lib: target_var("BORING_BSSL_RUST_CPPLIB"),
169169
}
170170
}
171171
}

boring-sys/build/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,10 @@ fn built_boring_source_path(config: &Config) -> &PathBuf {
572572

573573
let mut cfg = get_boringssl_cmake_config(config);
574574

575+
if let Ok(threads) = std::thread::available_parallelism() {
576+
cfg.env("CMAKE_BUILD_PARALLEL_LEVEL", threads.to_string());
577+
}
578+
575579
if config.features.fips {
576580
let (clang, clangxx) = verify_fips_clang_version();
577581
cfg.define("CMAKE_C_COMPILER", clang)

boring/src/ssl/ech.rs

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
use crate::ffi;
2-
use foreign_types::{ForeignType, ForeignTypeRef};
2+
use foreign_types::ForeignType;
33
use libc::c_int;
44

55
use crate::error::ErrorStack;
66
use crate::hpke::HpkeKey;
77
use crate::{cvt_0i, cvt_p};
88

9-
foreign_type_and_impl_send_sync! {
10-
type CType = ffi::SSL_ECH_KEYS;
11-
fn drop = ffi::SSL_ECH_KEYS_free;
12-
13-
pub struct SslEchKeys;
9+
pub struct SslEchKeysBuilder {
10+
keys: SslEchKeys,
1411
}
1512

16-
impl SslEchKeys {
17-
pub fn new() -> Result<SslEchKeys, ErrorStack> {
13+
impl SslEchKeysBuilder {
14+
pub fn new() -> Result<SslEchKeysBuilder, ErrorStack> {
1815
unsafe {
1916
ffi::init();
20-
cvt_p(ffi::SSL_ECH_KEYS_new()).map(|p| SslEchKeys::from_ptr(p))
17+
let keys = cvt_p(ffi::SSL_ECH_KEYS_new())?;
18+
19+
Ok(SslEchKeysBuilder::from_ptr(keys))
20+
}
21+
}
22+
23+
pub unsafe fn from_ptr(keys: *mut ffi::SSL_ECH_KEYS) -> Self {
24+
Self {
25+
keys: SslEchKeys::from_ptr(keys),
2126
}
2227
}
23-
}
2428

25-
impl SslEchKeysRef {
2629
pub fn add_key(
2730
&mut self,
2831
is_retry_config: bool,
@@ -31,7 +34,7 @@ impl SslEchKeysRef {
3134
) -> Result<(), ErrorStack> {
3235
unsafe {
3336
cvt_0i(ffi::SSL_ECH_KEYS_add(
34-
self.as_ptr(),
37+
self.keys.as_ptr(),
3538
is_retry_config as c_int,
3639
ech_config.as_ptr(),
3740
ech_config.len(),
@@ -40,4 +43,21 @@ impl SslEchKeysRef {
4043
.map(|_| ())
4144
}
4245
}
46+
47+
pub fn build(self) -> SslEchKeys {
48+
self.keys
49+
}
50+
}
51+
52+
foreign_type_and_impl_send_sync! {
53+
type CType = ffi::SSL_ECH_KEYS;
54+
fn drop = ffi::SSL_ECH_KEYS_free;
55+
56+
pub struct SslEchKeys;
57+
}
58+
59+
impl SslEchKeys {
60+
pub fn builder() -> Result<SslEchKeysBuilder, ErrorStack> {
61+
SslEchKeysBuilder::new()
62+
}
4363
}

boring/src/ssl/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ pub use self::cert_compression::CertCompressionAlgorithm;
108108
pub use self::connector::{
109109
ConnectConfiguration, SslAcceptor, SslAcceptorBuilder, SslConnector, SslConnectorBuilder,
110110
};
111+
#[cfg(not(feature = "fips"))]
112+
pub use self::ech::SslEchKeysRef;
111113
pub use self::error::{Error, ErrorCode, HandshakeError};
112114

113115
mod async_callbacks;
@@ -2018,7 +2020,7 @@ impl SslContextBuilder {
20182020
/// threads.
20192021
#[cfg(not(feature = "fips"))]
20202022
#[corresponds(SSL_CTX_set1_ech_keys)]
2021-
pub fn set_ech_keys(&mut self, keys: SslEchKeys) -> Result<(), ErrorStack> {
2023+
pub fn set_ech_keys(&self, keys: &SslEchKeys) -> Result<(), ErrorStack> {
20222024
unsafe { cvt(ffi::SSL_CTX_set1_ech_keys(self.as_ptr(), keys.as_ptr())).map(|_| ()) }
20232025
}
20242026

@@ -2253,6 +2255,16 @@ impl SslContextRef {
22532255
let mode = unsafe { ffi::SSL_CTX_get_verify_mode(self.as_ptr()) };
22542256
SslVerifyMode::from_bits(mode).expect("SSL_CTX_get_verify_mode returned invalid mode")
22552257
}
2258+
2259+
/// Registers a list of ECH keys on the context. This list should contain new and old
2260+
/// ECHConfigs to allow stale DNS caches to update. Unlike most `SSL_CTX` APIs, this function
2261+
/// is safe to call even after the `SSL_CTX` has been associated with connections on various
2262+
/// threads.
2263+
#[cfg(not(feature = "fips"))]
2264+
#[corresponds(SSL_CTX_set1_ech_keys)]
2265+
pub fn set_ech_keys(&self, keys: &SslEchKeys) -> Result<(), ErrorStack> {
2266+
unsafe { cvt(ffi::SSL_CTX_set1_ech_keys(self.as_ptr(), keys.as_ptr())).map(|_| ()) }
2267+
}
22562268
}
22572269

22582270
/// Error returned by the callback to get a session when operation

boring/src/ssl/test/ech.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ static ECH_KEY_2: &[u8] = include_bytes!("../../../test/echkey-2");
1818
fn bootstrap_ech(config: &[u8], key: &[u8], list: &[u8]) -> (Server, ClientSslBuilder) {
1919
let server = {
2020
let key = HpkeKey::dhkem_p256_sha256(key).unwrap();
21-
let mut ech_keys = SslEchKeys::new().unwrap();
22-
ech_keys.add_key(true, config, key).unwrap();
21+
let mut ech_keys_builder = SslEchKeys::builder().unwrap();
22+
ech_keys_builder.add_key(true, config, key).unwrap();
23+
let ech_keys = ech_keys_builder.build();
2324

2425
let mut builder = Server::builder();
25-
builder.ctx().set_ech_keys(ech_keys).unwrap();
26+
builder.ctx().set_ech_keys(&ech_keys).unwrap();
2627

2728
builder.build()
2829
};

0 commit comments

Comments
 (0)