Skip to content

Commit dded5d4

Browse files
0x676e67bwesterbghedoevanrittenhousekornelski
authored
Sync Detailed error codes and Clean up boring_sys::init() (#47)
* 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. --------- 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]>
1 parent 2e17f2b commit dded5d4

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

boring-sys/src/lib.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,7 @@ pub const fn ERR_GET_REASON(l: c_uint) -> c_int {
4848
}
4949

5050
pub fn init() {
51-
use std::ptr;
52-
use std::sync::Once;
53-
54-
// explicitly initialize to work around https://github.com/openssl/openssl/issues/3505
55-
static INIT: Once = Once::new();
56-
57-
let init_options = OPENSSL_INIT_LOAD_SSL_STRINGS;
58-
59-
INIT.call_once(|| {
60-
assert_eq!(
61-
unsafe { OPENSSL_init_ssl(init_options.try_into().unwrap(), ptr::null_mut()) },
62-
1
63-
)
64-
});
51+
unsafe {
52+
CRYPTO_library_init();
53+
}
6554
}

boring/src/error.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ impl Error {
182182
}
183183
}
184184

185+
/// Returns the raw OpenSSL error constant for the library reporting the
186+
/// error.
187+
pub fn library_code(&self) -> libc::c_int {
188+
ffi::ERR_GET_LIB(self.code)
189+
}
190+
185191
/// Returns the name of the function reporting the error.
186192
pub fn function(&self) -> Option<&'static str> {
187193
unsafe {
@@ -206,6 +212,11 @@ impl Error {
206212
}
207213
}
208214

215+
/// Returns the raw OpenSSL error constant for the reason for the error.
216+
pub fn reason_code(&self) -> libc::c_int {
217+
ffi::ERR_GET_REASON(self.code)
218+
}
219+
209220
/// Returns the name of the source file which encountered the error.
210221
pub fn file(&self) -> &'static str {
211222
unsafe {
@@ -235,12 +246,14 @@ impl fmt::Debug for Error {
235246
if let Some(library) = self.library() {
236247
builder.field("library", &library);
237248
}
249+
builder.field("library_code", &self.library_code());
238250
if let Some(function) = self.function() {
239251
builder.field("function", &function);
240252
}
241253
if let Some(reason) = self.reason() {
242254
builder.field("reason", &reason);
243255
}
256+
builder.field("reason_code", &self.reason_code());
244257
builder.field("file", &self.file());
245258
builder.field("line", &self.line());
246259
if let Some(data) = self.data() {

0 commit comments

Comments
 (0)