Commit Graph

103 Commits

Author SHA1 Message Date
vuittont60 4d1b7fc816 Fix typos 2023-12-14 02:28:11 +01:00
Anthony Ramine 9cf03ae4c1 Move async callbacks infra to boring itself
This helps drive async callbacks from outside tokio-boring, such as in quiche.

Not a breaking change because every public item in tokio-boring is preserved as is.
2023-11-27 11:53:35 +01:00
Anthony Ramine c38ed71511 Use replace_ex_data more
Setting callbacks multiple times on a SslContextBuilder causes the previous callback
installed to leak, using replace_ex_data internally prevents that.

We also start using it in tokio-boring in with_ex_data_future, my understanding
is that the futures currently in use are never installed twice by that function
but that could change in the future with the addition of more async callbacks.
2023-11-23 11:07:17 +01:00
Anthony Ramine a32783374f Properly drop overwritten ex data
We introduce new methods replace_ex_data for both SslContextBuilder
and Ssl in case anyone is relying on the leaking behaviour of their
set_ex_data methods, but we do document that they leak now.
2023-11-16 19:47:16 +01:00
Anthony Ramine 8a26577b5d Allow returning GetSessionPendingError from get session callbacks 2023-10-25 10:25:55 +01:00
Anthony Ramine 1e2a4812d2 Test set_get_session_callback 2023-10-25 10:25:55 +01:00
Anthony Ramine 965fde7bae Test new session callback on server side 2023-10-25 10:25:55 +01:00
Anthony Ramine c48ed2ef62 Move session tests to their own module 2023-10-25 10:25:55 +01:00
Anthony Ramine 7ddb106c20 Introduce a new set of env variables for FIPS-like builds
Builds using feature fips or fips-link-precompiled now
read variables prefixed by BORING_BSSL_FIPS_ instead of
BORING_BSSL_. This helps complex builds where build dependencies
also use boring, where we may not want to use fips there.

Without those separate variables, the boring build for the
build dependencies end up relying on e.g. BORING_BSSL_PATH,
causing errors if this path is a boring checkout intended for
fips builds, while the fips feature isn't enabled for
the build dependency.
2023-10-23 12:28:12 +02:00
Anthony Ramine bc095478fc Use prefix BORING_BSSL_ for all boringssl env variables
This means BORING_SSL_PRECOMPILED_BCM_O is now
BORING_BSSL_PRECOMPILED_BCM_O.

Prefix BORING_BSSL_ has been chosen because that's the
one that is used the most among all the variables
the build script uses.
2023-10-23 12:28:12 +02:00
Anthony Ramine 84a80c1916 Change X509VerifyResult to Result<(), X509VerifyError>
This commit separates X509VerifyResult::OK from the rest
of the codes that actually represent errors, using
a Result type as usual.
2023-10-11 14:42:59 +02:00
Anthony Ramine ad4239d59c Introduce bindings for all X509_V_ERR_* constants 2023-10-11 14:42:59 +02:00
sabjank ea5b399487 Add SHA224, SHA512, SHA512-256 tests 2023-10-11 09:53:30 +02:00
sabjank 2f73d3148a Expose SHA512-256 2023-10-11 09:53:30 +02:00
Anthony Ramine 6c681a409c Remove boring::fips::enable (fixes #150)
In boringssl, FIPS_mode_set is more or less useless, and
it doesn't even set an error stack at all on failure,
so there is no point using it instead of FIPS_mode.
2023-10-10 15:34:56 +01:00
Anthony Ramine 5f88374d7b Introduce SslSignatureAlgorithm::RSA_PKCS1_MD5_SHA1 2023-10-10 09:22:36 +01:00
Anthony Ramine 273509ccb0 Introduce Ssl::set_certificate 2023-10-10 09:22:36 +01:00
Anthony Ramine 907eaf079c Introduce async callbacks
We introduce tokio_boring::SslContextBuilderExt, with 2 methods:

* set_async_select_certificate_callback
* set_async_private_key_method
2023-10-10 09:22:36 +01:00
Anthony Ramine 0ffbdb030f Implement SslContextBuilder::set_private_key_method 2023-10-10 09:22:36 +01:00
Anthony Ramine 61bfbb5bd6 Change signature for set_select_certificate_callback
To handle lifetimes better and allow returning a &mut SslRef from
the client hello struct passed to the closure from
SslContextBuilder::set_select_certificate_callback, we make
the ClientHello struct itself own a reference to the FFI
client hello struct.
2023-10-10 09:22:36 +01:00
Alessandro Ghedini 97e2a8bc30 Add a few WouldBlock cases 2023-10-10 09:22:36 +01:00
Anthony Ramine 3d7ff0a5c0 Introduce setup_accept and setup_connect
These two new kinds of methods immediately return a MidHandshakeSslStream
instead of actually initiating a handshake. This greatly simplifies
loops around MidHandshakeSslStream::WouldBlock.
2023-10-10 09:22:36 +01:00
Anthony Ramine 3b88f4ee5b Panic on error when setting default curves list
These lists are hardcoded and the calls have no business failing in the first place.
2023-10-10 09:22:36 +01:00
Alessandro Ghedini 7b0de9341c Introduce ssl::Error::would_block 2023-10-10 09:22:36 +01:00
Anthony Ramine 602bb6d63d Fix clippy lints 2023-10-09 11:49:07 +01:00
Yuchen Wu a3cdf8769a Add new(), connect(), accept() and handshake() to SslStream
These APIs allow more SslStream to be used more flexibly
2023-09-21 17:40:06 +02:00
Christopher Patton 6057ab79f9 Enable P-521 with "kx-safe-default"
While not commonly used, P-521 is a perfectly safe choice of key
exchange algorithm.
2023-09-20 11:09:38 +01:00
Yuchen Wu 52307b145b Provide into_ssl() for ConnectConfiguration
Port from openssl-rs.
2023-09-19 22:04:59 +02:00
Christopher Patton 2fa3d96966 Use features to set key exchange preferences
Overwrite boringSSL's default key exchange preferences with safe
defaults using feature flags:

* "kx-pq-supported" enables support for PQ key exchange algorithms.
  Classical key exchange is still preferred, but will be upgraded to PQ
  if requested.

* "kx-pq-preferred" enables preference for PQ key exchange,
  with fallback to classical key exchange if requested.

* "kx-nist-required" disables non-NIST key exchange.

Each feature implies "kx-safe-default". When this feature is enabled,
don't compile bindings for `SSL_CTX_set1_curves()` and `SslCurve`. This
is to prevent the feature flags from silently overriding curve
preferences chosen by the user.

Ideally we'd allow both: that is, use "kx-*" to set defaults, but still
allow the user to manually override them. However, this doesn't work
because by the time the `SSL_CTX` is constructed, we don't yet know
whether we're the client or server. (The "kx-*" features set different
preferences for each.) If "kx-sfe-default" is set, then the curve
preferences are set just before initiating a TLS handshake
(`SslStreamBuilder::connect()`) or waiting for a TLS handshake
(`SslStreamBuilder::accept()`).
2023-09-01 14:21:35 -07:00
Ivan Nikulin 011d500460 Separate `fips` and `fips-link-precompiled` features.
Make the later compatible with `rpk` feature.
2023-08-30 11:41:20 +01:00
Ivan Nikulin bb063aa9e6 Fix Diplay panics for HandshakeError with `rpk` (fixes #140) 2023-08-03 15:00:09 +01:00
Anthony Ramine abfe2f7980 Switch boring from lazy_static to once_cell 2023-08-02 12:14:02 +01:00
Anthony Ramine af5bb39a78 Clean up and remove some unsafe code from ffi callbacks 2023-08-02 12:14:02 +01:00
Ivan Nikulin 3478bc2668
Merge pull request #83 from signalapp/private_key_to_der_pkcs8
boring: Expose PKey::private_key_to_der_pkcs8(_passphrase)
2023-07-27 10:11:02 +01:00
Ivan Nikulin d4ddd16ee2 Add fips-link-precompiled feature 2023-07-26 14:35:40 +01:00
Alessandro Ghedini f772338238 Allow specifying a custom BoringSSL source directory 2023-07-14 10:47:37 +01:00
Ivan Nikulin 0b542999d4 Address review comments 2023-07-10 14:00:52 +01:00
Ivan Nikulin d59d170c4d Update docs 2023-07-10 12:29:30 +01:00
Ivan Nikulin d1ee9bfd86 Use workspace metadata for crates 2023-07-10 11:38:18 +01:00
Ivan Nikulin c4e8a94a69 Add RPK and PQ crypto features 2023-07-07 13:50:36 +01:00
Anthony Ramine 6e751e85cb Revert "Merge pull request #108 from nox/store-clone"
This reverts commit 1c1af4b38b, reversing
changes made to da32be1fa9.

SslContextBuilder::cert_store_mut returns a &mut X509StoreBuilder
backed by a X509Store that is already shared with an existing SslContext.
2023-05-15 15:36:17 +02:00
Anthony Ramine ad2517f797 Fix build 2023-05-15 15:36:17 +02:00
Ivan Nikulin 1c1af4b38b
Merge pull request #108 from nox/store-clone
Implement ToOwned for X509StoreRef and Clone for X509Store
2023-05-11 16:25:11 +01:00
Ivan Nikulin da32be1fa9
Merge pull request #114 from nox/nox/openssl-fixes
Port security fixes from the openssl crate (fixes #111)
2023-05-11 16:24:29 +01:00
Ivan Nikulin ec52371e6b
Merge pull request #79 from signalapp/deriver-leak
boring: Fix memory leak in `Deriver`
2023-05-11 16:23:56 +01:00
Ivan Nikulin 0dd85d187b
Merge pull request #117 from nox/bump-boringssl
Update boringssl to latest upstream commit (fixes #100)
2023-05-11 16:23:28 +01:00
Ivan Nikulin 561d786c10
Merge pull request #97 from PiotrSikora/boringcrypto_4407
Update BoringCrypto to FIPS 140-2 certificate 4407.
2023-05-11 16:22:25 +01:00
Ivan Nikulin e1dc466cd1
Merge pull request #104 from tbu-/pr_doc_typo
psuedo → pseudo
2023-05-11 16:20:47 +01:00
Piotr Sikora 902e7d0c92 Update BoringCrypto to FIPS 140-2 certificate 4407.
Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
2023-05-09 10:37:32 +02:00
Anthony Ramine 6274f70726 Update boringssl to latest upstream commit
Notable commits that cause code changes here:

X509 fields notBefore and notAfter need to be specified
https://boringssl-review.googlesource.com/c/boringssl/+/49349

X509ReqBuilder only accepts X509v1 now
https://boringssl-review.googlesource.com/c/boringssl/+/52605

Some functions switched from int to size_t
https://boringssl-review.googlesource.com/c/boringssl/+/54985

CECPQ2 support was dropped
https://boringssl-review.googlesource.com/c/boringssl/+/58645

This is a breaking change.
2023-05-09 10:28:10 +02:00