Skip to content

Commit 05270fa

Browse files
rushilmehrakornelski
authored andcommitted
Expose SSL_set_enable_ech_grease
1 parent 24003a0 commit 05270fa

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

boring/src/ssl/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3708,6 +3708,17 @@ impl SslRef {
37083708
pub fn ech_accepted(&self) -> bool {
37093709
unsafe { ffi::SSL_ech_accepted(self.as_ptr()) != 0 }
37103710
}
3711+
3712+
// Whether or not to enable ECH grease on `SSL`.
3713+
#[cfg(not(feature = "fips"))]
3714+
#[corresponds(SSL_set_enable_ech_grease)]
3715+
pub fn set_enable_ech_grease(&self, enable: bool) {
3716+
let enable = if enable { 1 } else { 0 };
3717+
3718+
unsafe {
3719+
ffi::SSL_set_enable_ech_grease(self.as_ptr(), enable);
3720+
}
3721+
}
37113722
}
37123723

37133724
/// An SSL stream midway through the handshake process.

boring/src/ssl/test/ech.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,15 @@ fn ech_rejection() {
5858
assert!(failed_ssl_stream.ssl().get_ech_retry_configs().is_some());
5959
assert!(!failed_ssl_stream.ssl().ech_accepted())
6060
}
61+
62+
#[test]
63+
fn ech_grease() {
64+
let server = Server::builder().build();
65+
66+
let mut client = server.client_with_root_ca().build().builder();
67+
// Verified with a pcap locally that the ECH extension gets sent due to GREASE
68+
client.ssl().set_enable_ech_grease(true);
69+
70+
let ssl_stream = client.connect();
71+
assert!(!ssl_stream.ssl().ech_accepted())
72+
}

0 commit comments

Comments
 (0)