Commit Graph

3082 Commits

Author SHA1 Message Date
Anthony Ramine f5f47dd5a7 Remove feature rpk from hyper-boring and tokio-boring
Feature rpk in boring doesn't do anything unless you
explicitly use `SslAcceptor::rpk` or `SslContext::rpk_builder`,
and neither of these types are directly reachable if the
user depends only on tokio-boring or hyper-boring, which
means you still need to explicitly depend on the boring crate
to use RPK, in which case you can enable the feature there.
2023-10-23 15:06:23 +02: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 ebea825d18 Don't read BORINGSSL_BUILD_DIR anymore
It's actually unused.
2023-10-23 12:28:12 +02:00
Anthony Ramine 6b52c1e93c Don't use env::current_dir in build script
The current directory from a build script executed by cargo
is always the manifest dir, so we may as well only use
the manifest dir.
2023-10-23 12:28:12 +02:00
Anthony Ramine 0d25d74cd6 Introduce struct Config in build script
Using a struct improves navigation of the build script,
as we can rely on rust-analyzer to help us check how
a feature flag or an environment variable is used,
as opposed to grepping for multiple env::var calls
or #[cfg] attributes.

This commit also removes some obsolete blocks of code
related to the now defunct ndk-old-gcc and fuzzing features.
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 ea96015b66 Remove futures from ex data slots once they resolve 2023-10-10 09:22:36 +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
Anthony Ramine 1c790f7277 Introduce AsyncStreamBridge
This encapsulates a bit better the unsafety of task context
management to invoke async code from inside boring.
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 0a2013a6d5 Introduce helper module in tokio-boring tests 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
Alexis (Poliorcetics) Bourget f67498cf00 deps: update to bindgen 0.68 2023-10-09 13:25:45 +02: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
Ivan Nikulin 4749c525e4 Update Cargo.toml 2023-09-13 12:38:03 +01:00
Ivan Nikulin e02d03b5e0 Update RELEASE_NOTES 2023-09-13 12:38:03 +01:00
Ivan Nikulin 255409cb98 Update RELEASE_NOTES 2023-09-13 12:38:03 +01:00
Manuel Olguín Muñoz c2cd349132 Release 3.0.5 2023-09-13 12:38:03 +01:00
Manuel Olguín Muñoz bdbef2003f tweaks for ergonomic linking 2023-09-13 12:38:03 +01: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 5d6ca7e19c Introduce `no-patches` feature 2023-09-01 09:28:27 +01:00
Eliza Weisman 190fb900a0 run `publish --dry-run` instead of `pacakge` on CI
As suggested by @inikulin in
https://github.com/cloudflare/boring/pull/159#issuecomment-1697324821
2023-08-30 14:54:18 +01:00
Eliza Weisman e9318132d8 fix missing space in cargo package CI command 2023-08-30 14:54:18 +01:00
Eliza Weisman 3056660c86 ci: run the cargo package check for all targets 2023-08-30 14:54:18 +01:00
Eliza Weisman 2345c2f988 boring-sys: include all files needed to build FIPS
This commit modifies the Cargo `include` field for `boring-sys` to
include all the files necessary to actually build the FIPS-certified
revision of BoringSSL. Currently, some of these files are missing (see
#157 for details on this).

This branch improves on my previous approach in PR #158, which switched
from using a Cargo `include` to a Cargo `exclude`. Using `exclude`
rather than `include` resulted in a much larger crates.io package, but
at the time, I thought this was less likely to result in breakage in the
future, because I was concerned about the inability to verify that the
set of excludes/includes can build a new pinned `boringssl` git revision
without having to actually publish a crates.io release.

However, as @nox pointed out in [this comment][1], `cargo package` can
be used to verify a build with the `exclude`s/`include`s applied. This
branch therefore adds `cargo package` steps to CI that check that the
package can actually be built. This way, we are able to make a much
smaller change to the included files, resulting in a smaller package
published to crates.io.

On this branch, the package is 6.7MiB compressed, which is not much
larger than it was previously:

```
    Finished dev [unoptimized + debuginfo] target(s) in 55.65s
    Packaged 1851 files, 33.7MiB (6.7MiB compressed)
```

Fixes #157
Closes #158

[1]: https://github.com/cloudflare/boring/pull/158#issuecomment-1693067112,
2023-08-30 14:54:18 +01:00
Eliza Weisman c8d52a7614 add CI jobs to run `cargo package` 2023-08-30 14:54:18 +01:00
Paolo Barbolini ed91cce367 Fix -Z minimal-versions 2023-08-30 12:19:04 +01: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 a6e35a46b6 Bump version in Cargo.toml 2023-08-05 14:36:12 +01:00
Ivan Nikulin c482097d96 Release 3.0.4 2023-08-05 14:34:05 +01:00
Ivan Nikulin edfe18b196 Add missing cmake files to the package 2023-08-05 14:32:02 +01:00
Ivan Nikulin 55d2731a18 Release 3.0.3 2023-08-05 14:03:58 +01:00
Manuel Olguín Muñoz 57e54be907 Fix missing .trim() when verifying FIPS module name 2023-08-05 13:54:26 +01:00
Ivan Nikulin bb063aa9e6 Fix Diplay panics for HandshakeError with `rpk` (fixes #140) 2023-08-03 15:00:09 +01:00
Ivan Nikulin 308f0405bd Release 3.0.2 2023-08-03 13:38:59 +01:00
Ivan Nikulin 7fd29555b6 Fix feature gates for fips-link-precompiled 2023-08-03 13:38:59 +01:00