Commit Graph

57 Commits

Author SHA1 Message Date
0x676e67 7ee98f663e
sync upstream (#54)
* 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.

* Expose EVP_HPKE_KEY

* Expose client/server-side ECH

Resolves https://github.com/cloudflare/boring/issues/282

* Clean up ECH tests

* Expose SSL_set_enable_ech_grease

* Use corresponds macro

* build: Fix the build for 32-bit Linux platform (#312)

build: Fix the build for 32-bit Linux platform

* Set CMAKE_BUILD_PARALLEL_LEVEL to available_parallelism

cmake-rs' jobserver doesn't work reliably, if at all. One workaround is
to set CMAKE_BUILD_PARALLEL_LEVEL to available_parallelism(). On my
machine it shaves ~35 seconds off of boring-sys builds.

* Expose SSL_CTX_set1_ech_keys from SslContextRef

We currently expose this method on `SslContextBuilder`, which is fine
for bootstrapping an `SSL_CTX`, but subsequent attempts to set ECH keys
(like during key rotation) can only happen via `SslContextRef`. Also
update the method on the builder to take an immutable reference to self
because the API is thread safe.

* Bump cmake-rs to improve Mac OS build parallelism

There's a bug on OSX that prevents the CMake jobserver from working
properly, and so CMake defaults to a single-threaded build. It's not
clear when this is actually going to get fixed, so recent versions of
cmake-rs just disable the jobserver and have CMake fall back to the
number of available cores:
https://github.com/rust-lang/cmake-rs/pull/229

This means we don't need e6833b0074

* Release 4.14.0 (#317)

* Actually expose SslEchKeys

* Address clippy lints

* Revert "Refactor!: Introduce a Cargo feature for optional Hyper 0 support"

This reverts commit 49d5a61163.

* Revert "Refactor!: Remove strict `TokioIo` response requirement from `hyper_boring::v1::HttpsConnector`"

This reverts commit e518c2444a.

* Introduce a builder pattern for SslEchKeys + make set_ech_keys take a reference (#320)

Previously, set_ech_keys would consume the SslEchKeys struct to enforce
the requirement that the struct is immutable after initializing it on a
SSL_CTX. The problem with this is that it requires applications to
needlessly reallocate the SslEchKeys struct if they want to initialize
keys on multiple SSL_CTXs, which is a pretty common pattern. To work
around this, we introduce a builder (SslEchKeysBuilder) that requires
mutable access to add keys to the underlying struct. set_ech_keys takes
in a reference to SslEchKeys, which can only be made via consuming the
builder.

* Revert cmake bump (for now) as it is overly restrictive (#321)

Some users of boring have issues with newer versions of cmake. Because
we have an alternative solution, we can hold off on the bump for now.

---------

Co-authored-by: Bas Westerbaan <bas@cloudflare.com>
Co-authored-by: Alessandro Ghedini <alessandro@cloudflare.com>
Co-authored-by: Evan Rittenhouse <erittenhouse@cloudflare.com>
Co-authored-by: Kornel <kornel@cloudflare.com>
Co-authored-by: Rushil Mehra <rmehra@cloudflare.com>
Co-authored-by: Rushil Mehra <84047965+rushilmehra@users.noreply.github.com>
2025-02-23 19:42:23 +08:00
Paul Mabileau 49d5a61163 Refactor!: Introduce a Cargo feature for optional Hyper 0 support
Closes #294. Requires breaking changes. The default v0 is changed in
favor of v1, but v0 is still kept available, just in a forced module
path. It enables dependency de-duplication when consuming it.

Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2024-12-07 21:07:31 +00:00
Kornel 1946603e15 Work around Rust settings inconsistent iOS SDK version 2024-11-28 11:21:39 -08:00
Rushil Mehra 7bb3647406 (ci): brew link x86 toolchain for macos13 runner
It seems we need to manually symlink the x86_64-unknown-linux-gnu
toolchain for the macos13 runner. Also, we don't need to overwrite the
python version anymore

Fixes https://github.com/cloudflare/boring/issues/285
2024-10-24 09:49:47 -07:00
Hrushikesh Deshpande d3177a4300 Create semgrep.yml
Creating Semgrep.yml file - Semgrep is a tool that will be used to scan Cloudflare's public repos for Supply chain, code and secrets. This work is part of Application & Product Security team's initiative to onboard Semgrep onto all of Cloudflare's public repos.

In case of any questions, please reach out to "Hrushikesh Deshpande" on cf internal chat.
2024-10-14 11:33:22 -04:00
Anthony Ramine 193bf3b9d7
Implement optional Hyper 1 support in hyper-boring (#246) 2024-09-18 13:24:35 +02:00
Rushil Mehra a7bfe0d92c Fix macos FIPS crossbuild 2024-08-15 15:09:02 -07:00
Rushil Mehra 8786cda639 (ci): Fix macos crossbuild action by forcing brew link w python@3.11 2024-07-24 18:19:22 +01:00
Rushil Mehra b7baacc047 Fix workflows file, pin mac os FIPS crossbuild runner to macos-13
The macos-13 runner uses intel chips and thus x86, so clang 12.0.0 is
easily available.
2024-06-26 16:13:58 +01:00
Ivan Nikulin d9f7e4daf6 Fix crosscompile 2024-05-31 09:38:29 +01:00
Anthony Ramine a8dea4a22c Introduce X509CheckFlags::UNDERSCORE_WILDCARDS 2024-01-02 15:37:36 +01:00
Chris Eager dd281f6ab6 Swap build and run order; always build 2023-12-14 13:25:47 +01:00
Jordan Rose 4d66ada007 Use gcc/g++ as the compilers for windows-gnu, not Clang 2023-12-14 13:25:47 +01:00
Jordan Rose 016d5cb61e Always run tests in bash
This is only necessary for the windows-gnu target, but causes no
issues anywhere else.
2023-12-14 13:25:47 +01:00
Jordan Rose 8b86852d8a Add arm64-macos cross-compile to CI 2023-12-14 13:25:47 +01:00
Jordan Rose f82f3fcb0f Add custom linker for Android cross-compilation 2023-12-14 13:25:47 +01:00
Jordan Rose 16327cf5c5 Add custom environment for ARM Linux cross-compilation 2023-12-14 13:25:47 +01:00
Chris Eager 2f62df492b Build tests even for cross-compiling 2023-12-14 13:25:47 +01:00
Jordan Rose 1028909b40 Remove musl test; there's no standard musl C++ setup for us to use 2023-12-14 13:25:47 +01:00
Chris Eager 08c417a97e Make arm and Android builds check-only 2023-12-14 13:25:47 +01:00
Chris Eager f5583312c5 Add matrix.apt_packages 2023-12-14 13:25:47 +01:00
Chris Eager bccb80b115 Refactor check-only and extra-test-args 2023-12-14 13:25:47 +01:00
Chris Eager bbe8cd1b9e Add relevant `--target` to `cargo test` in CI 2023-12-14 13:25:47 +01:00
Anthony Ramine 0f74eade4b Add CI for cross-building from macOS 2023-10-26 11:31:47 +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
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 c8d52a7614 add CI jobs to run `cargo package` 2023-08-30 14:54:18 +01:00
Ivan Nikulin d4ddd16ee2 Add fips-link-precompiled feature 2023-07-26 14:35:40 +01:00
Ivan Nikulin 0b542999d4 Address review comments 2023-07-10 14:00:52 +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
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 7215070e22 Use ubuntu-20.04 image for FIPS build
Later ubuntu images don't provide clang-7 anymore.
2023-03-27 12:59:13 +02:00
ilammy 87cdcee599 ci: Test builds for iOS targets
While it's possible to build Rust tests into an iOS app, start up
a simulator instance, upload the tests there, and launch them --
that's a bit involved process. For now, just check that BoringSSL
compiles for the specified target. Use "--all-targets" to check
all targets, including the unit tests.
2022-06-03 09:11:38 -05:00
ilammy 4c5ffc7723 ci: Don't run tests when targeting iOS
Even if "cargo test --target ${arch}-apple-ios" cross-compiles tests,
it's not possible to actually run them on the host macOS, as that's
a different execution environment.

Although, I guess, we could try only building tests with "--no-run",
GitHub Actions do not make it easy to construct command lines based
on matrix parameters. Thus it's easier to disable these steps, and
the following commit adds a "--no-run" step with "--target".
2022-06-03 09:11:38 -05:00
Braden Ehrat 1507689c5b
Add fips-3678 feature (#52)
* Add rerun-if-env-changed instructions for BORING_* variables

* Use X509_get0_notBefore() and X509_get0_notAfter() instead of X509_getm_notBefore() and X509_getm_notAfter().

According to
https://www.openssl.org/docs/man1.1.0/man3/X509_getm_notBefore.html,
"X509_getm_notBefore() and X509_getm_notAfter() are similar to
X509_get0_notBefore() and X509_get0_notAfter() except they return
non-constant mutable references to the associated date field of the
certificate".

* Only update boringssl submodule if BORING_BSSL_PATH not provided

* Allow BORING_BSSL_LIB_PATH to control link search

* Add fips feature

* Use X509_set_notAfter unconditionally for FIPS compatibility

This is equivalent according to
https://boringssl.googlesource.com/boringssl/+/c947efabcbc38dcf93e8ad0e6a76206cf0ec8072

The version of boringssl that's FIPS-certified doesn't have `X509_set1_notAfter`.
The only difference between that and `X509_set_notAfter` is whether they're const-correct,
which doesn't seem worth having two different code-paths.

* Check out fips commit automatically

* Verify the version of the compiler used for building boringssl

NIST specifies that it needs to be 7.0.1; I originally tried building with clang 10 and it failed.
Theoretically this should check the versions of Go and Ninja too, but they haven't given me trouble in practice.

Example error:
```
   Compiling boring-sys v1.1.1 (/home/jnelson/work/boring/boring-sys)
error: failed to run custom build command for `boring-sys v1.1.1 (/home/jnelson/work/boring/boring-sys)`

Caused by:
  process didn't exit successfully: `/home/jnelson/work/boring/target/debug/build/boring-sys-31b8ce53031cfd83/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=BORING_BSSL_PATH

  --- stderr
  warning: missing clang-7, trying other compilers: Permission denied (os error 13)
  warning: FIPS requires clang version 7.0.1, skipping incompatible version "clang version 10.0.0-4ubuntu1 "
  thread 'main' panicked at 'unsupported clang version "cc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0": FIPS requires clang 7.0.1', boring-sys/build.rs:216:13
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

* Add Github actions workflow testing FIPS

Co-authored-by: Joshua Nelson <jnelson@cloudflare.com>
2022-01-31 16:11:33 -06:00
Frank Denis 05c6a41270 Use bindgen to automatically generate boring-sys
This ensures that all the Rust functions, types and constants
always match the actual BoringSSL definitions.

It also removes quite a lot of manually maintained code, as well
as the need for systest.

The value for `SslOptions::ALL`, for example, was wrong. On current
BoringSSL versions, this is a no-op, and is set to `0`.

Clearing it does nothing. So, the `clear_ctx_options` test, that
passed by accident, was adjusted to use a different option.

The `libc` crate is not required, as we only use it for types that
are already defined in the standard library. It was removed from
`boring-sys`. The same can be done to other crates later.
2021-02-12 15:03:45 +01:00
Ivan Nikulin f4096d8afd Add hyper-boring 2020-11-11 20:29:54 +00:00
Ivan Nikulin ec45baa6d8 Revive CI 2020-11-11 19:01:29 +00:00
Ivan Nikulin fc07d7dfbb Fix doc comments 2020-11-11 18:08:14 +00:00
Steven Fackler 16a0e6f674 Test openssl-errors on windows 2020-08-15 15:18:32 -04:00
Steven Fackler 2f98f1c821 Fix CI branch 2020-06-06 16:32:27 -07:00
Steven Fackler 7546bfd148 Ignore default verify paths test on windows 2020-06-06 13:58:44 -07:00
Steven Fackler 60118dddad test env lookup 2020-06-06 13:58:44 -07:00
Steven Fackler 52c1b6fdc2 set vcpkg root 2020-06-06 13:58:44 -07:00
Steven Fackler a9a092a9ff run stuff 2020-06-06 13:58:44 -07:00
Steven Fackler 5f59ee012e update vcpkg 2020-06-06 13:58:44 -07:00
Steven Fackler 6f7501b034 Move vcpkg build to github actions 2020-06-06 13:58:44 -07:00