Skip to content

Commit 72dabe1

Browse files
cjpattonghedo
authored andcommitted
Remove the "kx-*" features
The "kx-*" features control default key exchange preferences. Its implementation requires disabling APIs for manually setting curve preferences via `set_curves()` or `set_curves_list()`. In practice, most teams need to be able to override default preferences at runtime anyway, which means these features were never really used. This commit gets rid of them, thereby reducing some complexity in the API.
1 parent 646ae33 commit 72dabe1

File tree

4 files changed

+0
-103
lines changed

4 files changed

+0
-103
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,6 @@ jobs:
363363
name: Run `underscore-wildcards` tests
364364
- run: cargo test --features pq-experimental,rpk
365365
name: Run `pq-experimental,rpk` tests
366-
- run: cargo test --features kx-safe-default,pq-experimental
367-
name: Run `kx-safe-default` tests
368366
- run: cargo test --features pq-experimental,underscore-wildcards
369367
name: Run `pq-experimental,underscore-wildcards` tests
370368
- run: cargo test --features rpk,underscore-wildcards

boring/Cargo.toml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,6 @@ pq-experimental = ["boring-sys/pq-experimental"]
4444
# those for `pq-experimental` feature apply.
4545
underscore-wildcards = ["boring-sys/underscore-wildcards"]
4646

47-
# Controlling key exchange preferences at compile time
48-
49-
# Choose key exchange preferences at compile time. This prevents the user from
50-
# choosing their own preferences.
51-
kx-safe-default = []
52-
53-
# Support PQ key exchange. The client will prefer classical key exchange, but
54-
# will upgrade to PQ key exchange if requested by the server. This is the
55-
# safest option if you don't know if the peer supports PQ key exchange. This
56-
# feature implies "kx-safe-default".
57-
kx-client-pq-supported = ["kx-safe-default"]
58-
59-
# Prefer PQ key exchange. The client will prefer PQ exchange, but fallback to
60-
# classical key exchange if requested by the server. This is the best option if
61-
# you know the peer supports PQ key exchange. This feature implies
62-
# "kx-safe-default" and "kx-client-pq-supported".
63-
kx-client-pq-preferred = ["kx-safe-default", "kx-client-pq-supported"]
64-
65-
# Disable key exchange involving non-NIST key exchange on the client side.
66-
# Implies "kx-safe-default".
67-
kx-client-nist-required = ["kx-safe-default"]
68-
6947
[dependencies]
7048
bitflags = { workspace = true }
7149
foreign-types = { workspace = true }

boring/src/ssl/mod.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -747,16 +747,12 @@ impl SslCurve {
747747
}
748748
}
749749

750-
// We need to allow dead_code here because `SslRef::set_curves` is conditionally compiled
751-
// against the absence of the `kx-safe-default` feature and thus this function is never used.
752-
//
753750
// **NOTE**: This function only exists because the version of boringssl we currently use does
754751
// not expose SSL_CTX_set1_group_ids. Because `SslRef::curve()` returns the public SSL_GROUP id
755752
// as opposed to the internal NID, but `SslContextBuilder::set_curves()` requires the internal
756753
// NID, we need this mapping in place to avoid breaking changes to the public API. Once the
757754
// underlying boringssl version is upgraded, this should be removed in favor of the new
758755
// SSL_CTX_set1_group_ids API.
759-
#[allow(dead_code)]
760756
pub fn nid(&self) -> Option<SslCurveNid> {
761757
match self.0 {
762758
ffi::SSL_GROUP_SECP224R1 => Some(ffi::NID_secp224r1),
@@ -2017,11 +2013,6 @@ impl SslContextBuilder {
20172013
}
20182014

20192015
/// Sets the context's supported curves.
2020-
//
2021-
// If the "kx-*" flags are used to set key exchange preference, then don't allow the user to
2022-
// set them here. This ensures we don't override the user's preference without telling them:
2023-
// when the flags are used, the preferences are set just before connecting or accepting.
2024-
#[cfg(not(feature = "kx-safe-default"))]
20252016
#[corresponds(SSL_CTX_set1_curves_list)]
20262017
pub fn set_curves_list(&mut self, curves: &str) -> Result<(), ErrorStack> {
20272018
let curves = CString::new(curves).map_err(ErrorStack::internal_error)?;
@@ -2035,12 +2026,7 @@ impl SslContextBuilder {
20352026
}
20362027

20372028
/// Sets the context's supported curves.
2038-
//
2039-
// If the "kx-*" flags are used to set key exchange preference, then don't allow the user to
2040-
// set them here. This ensures we don't override the user's preference without telling them:
2041-
// when the flags are used, the preferences are set just before connecting or accepting.
20422029
#[corresponds(SSL_CTX_set1_curves)]
2043-
#[cfg(not(feature = "kx-safe-default"))]
20442030
pub fn set_curves(&mut self, curves: &[SslCurve]) -> Result<(), ErrorStack> {
20452031
let curves: Vec<i32> = curves
20462032
.iter()
@@ -2915,40 +2901,6 @@ impl SslRef {
29152901
}
29162902
}
29172903

2918-
#[cfg(feature = "kx-safe-default")]
2919-
fn client_set_default_curves_list(&mut self) {
2920-
let curves = if cfg!(feature = "kx-client-pq-preferred") {
2921-
if cfg!(feature = "kx-client-nist-required") {
2922-
"P256Kyber768Draft00:P-256:P-384:P-521"
2923-
} else {
2924-
"X25519MLKEM768:X25519Kyber768Draft00:X25519:P256Kyber768Draft00:P-256:P-384:P-521"
2925-
}
2926-
} else if cfg!(feature = "kx-client-pq-supported") {
2927-
if cfg!(feature = "kx-client-nist-required") {
2928-
"P-256:P-384:P-521:P256Kyber768Draft00"
2929-
} else {
2930-
"X25519:P-256:P-384:P-521:X25519MLKEM768:X25519Kyber768Draft00:P256Kyber768Draft00"
2931-
}
2932-
} else {
2933-
if cfg!(feature = "kx-client-nist-required") {
2934-
"P-256:P-384:P-521"
2935-
} else {
2936-
"X25519:P-256:P-384:P-521"
2937-
}
2938-
};
2939-
2940-
self.set_curves_list(curves)
2941-
.expect("invalid default client curves list");
2942-
}
2943-
2944-
#[cfg(feature = "kx-safe-default")]
2945-
fn server_set_default_curves_list(&mut self) {
2946-
self.set_curves_list(
2947-
"X25519MLKEM768:X25519Kyber768Draft00:P256Kyber768Draft00:X25519:P-256:P-384",
2948-
)
2949-
.expect("invalid default server curves list");
2950-
}
2951-
29522904
/// Returns the [`SslCurve`] used for this `SslRef`.
29532905
#[corresponds(SSL_get_curve_id)]
29542906
#[must_use]
@@ -4341,9 +4293,6 @@ where
43414293
pub fn setup_connect(mut self) -> MidHandshakeSslStream<S> {
43424294
self.set_connect_state();
43434295

4344-
#[cfg(feature = "kx-safe-default")]
4345-
self.inner.ssl.client_set_default_curves_list();
4346-
43474296
MidHandshakeSslStream {
43484297
stream: self.inner,
43494298
error: Error {
@@ -4373,9 +4322,6 @@ where
43734322
pub fn setup_accept(mut self) -> MidHandshakeSslStream<S> {
43744323
self.set_accept_state();
43754324

4376-
#[cfg(feature = "kx-safe-default")]
4377-
self.inner.ssl.server_set_default_curves_list();
4378-
43794325
MidHandshakeSslStream {
43804326
stream: self.inner,
43814327
error: Error {

boring/src/ssl/test/mod.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -952,30 +952,6 @@ fn sni_callback_swapped_ctx() {
952952
assert!(CALLED_BACK.load(Ordering::SeqCst));
953953
}
954954

955-
#[cfg(feature = "kx-safe-default")]
956-
#[test]
957-
fn client_set_default_curves_list() {
958-
let ssl_ctx = crate::ssl::SslContextBuilder::new(SslMethod::tls())
959-
.unwrap()
960-
.build();
961-
let mut ssl = Ssl::new(&ssl_ctx).unwrap();
962-
963-
// Panics if Kyber768 missing in boringSSL.
964-
ssl.client_set_default_curves_list();
965-
}
966-
967-
#[cfg(feature = "kx-safe-default")]
968-
#[test]
969-
fn server_set_default_curves_list() {
970-
let ssl_ctx = crate::ssl::SslContextBuilder::new(SslMethod::tls())
971-
.unwrap()
972-
.build();
973-
let mut ssl = Ssl::new(&ssl_ctx).unwrap();
974-
975-
// Panics if Kyber768 missing in boringSSL.
976-
ssl.server_set_default_curves_list();
977-
}
978-
979955
#[test]
980956
fn get_curve() {
981957
let server = Server::builder().build();
@@ -994,7 +970,6 @@ fn get_curve_name() {
994970
assert_eq!(SslCurve::X25519.name(), Some("X25519"));
995971
}
996972

997-
#[cfg(not(feature = "kx-safe-default"))]
998973
#[test]
999974
fn set_curves() {
1000975
let mut ctx = SslContext::builder(SslMethod::tls()).unwrap();

0 commit comments

Comments
 (0)