Commit Graph

42 Commits

Author SHA1 Message Date
Christopher Patton 5cd912df1d Remove "pq-experimental", apply PQ patch by default
Users can override the new default behavior in the usual way. The
expectation is that the build of BoringSSL they provide the feature set
implemented by the patch.
2025-10-15 10:36:27 +01:00
Alessandro Ghedini 4cb7e260a8 Clean-up legacy FIPS options
Per BoringSSL's FIPS policy, its `main` branch is the "update branch"
for FedRAMP compliance's purposes.

This means that we can stop using a specific BoringSSL branch when
enabling FIPS, as well as a number of hacks that allowed us to build
more recent BoringSSL versions with an older pre-compiled FIPS modules.

This also required slightly updating the main BoringSSL submodule, as
the previous version had an issue when building with the FIPS option
enabled. This is turn required some changes to the PQ patch as well as
some APIs that don't seem to be exposed publicly, as well as changing
some paths in the other patches.

In order to allow a smooth upgrade of internal projects, the `fips-compat`
feature is reduced in scope and renamed to `legacy-compat-deprecated` so
that we can incrementally upgrade internal BoringSSL forks. In practice
this shouldn't really be something anyone else would need, since in
order to work it requires a specific mix of BoringSSL version and
backported patches.
2025-09-26 17:12:23 +01:00
Kornel 974c3d2db0 Ensure that ERR_LIB type can be named 2025-09-26 14:17:31 +01:00
Kornel 3116032a83 Skip Rust version detection for bindgen 2025-09-26 13:34:13 +01:00
Kornel 9bad96e48b Style nits 2025-09-26 13:33:19 +01:00
Kornel a50a39fde7 Support TARGET_CC and CC_{target} 2025-09-26 10:57:01 +01:00
Kornel c5045fb6b4 Fix patched docs.rs builds 2025-09-03 17:24:22 +01:00
Kornel 0ca11b5680 Use cargo:warning for warnings 2025-06-13 15:06:50 +02:00
Kornel 8d5fba3767 Don't link binaries on docs.rs 2025-06-13 15:06:50 +02:00
Kornel 4d178a7f9f Clippy 2025-06-05 10:16:08 +01:00
Yury Yarashevich 4ea82a2e1b Update bindgen from 0.70.1 -> 0.71.1. 2025-05-27 15:04:04 +01:00
Kornel 0327dd03c6 Fix linking SystemFunction036 from advapi32 in Rust 1.87 2025-05-26 16:30:09 +01:00
Kornel 23863ffd1b Clippy 2025-05-26 16:30:09 +01:00
Rushil Mehra 721b6fca2e
Add fips-precompiled feature to support newer versions of FIPS (#338)
Newer versions of FIPS don't need any special casing in our bindings,
unlike the submoduled boringssl-fips. In addition, many users currently
use FIPS by precompiling BoringSSL with the proper build tools and
passing that in to the bindings.

Until we adopt the Update Stream pattern for FIPS, there are two main
use cases:

1. Passing an unmodified, precompiled FIPS validated version of
   boringssl (fips-precompiled)

2. Passing a custom source directory of boringssl meant to be linked
   with a FIPS validated bcm.o. This is mainly useful if you carry
   custom patches but still want to use a FIPS validated BoringCrypto.
   (fips-link-precompiled)

This commit introduces the `fips-precompiled` feature and removes the
`fips-no-compat` feature.
2025-03-31 12:34:29 -07:00
Rushil Mehra 11630058f0
Revert "Remove "fips-no-compat", decouple "fips-compat" from "fips"" (#334) 2025-03-17 21:37:14 -05:00
Christopher Patton 57307d739e Remove "fips-no-compat", decouple "fips-compat" from "fips"
Modify the "fips" feature so that it no longer implies "fips-compat".
The latter is no longer needed for recent builds of boringSSL; users who
need older builds will need to enable "fips-compat" explicitly.

Also, remove the "fipps-no-compat" feature, as it's now equivalent to
"fips".
2025-03-16 08:43:52 +00:00
Christopher Patton c774afc859 Add feature "fips-no-compat"
As of boringSSL commit a430310d6563c0734ddafca7731570dfb683dc19, we no
longer need to make exceptions for the types of BufLen, ProtosLen, and
ValueLen, which means the "fips-compat" feature is no longer needed for
"fips" users.

Currently "fips" implies "fips-compat". To allow users to upgrade
without breaking API compatibility with boring version 4, add a new
feature, "fips-no-compat", that does not imply "fips-compat".

In boring 5, we should remove "fips-no-compat" and decouple
"fips-compat" from "fips".
2025-03-14 22:22:41 +00:00
Rushil Mehra 7ba322560f
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.
2025-02-22 17:16:53 -08:00
Rushil Mehra c3c7e16b9d 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
2025-02-19 01:30:11 -08:00
Rushil Mehra e6833b0074 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.
2025-02-18 22:37:08 -08:00
Rushil Mehra c05a339911 Support linking with a runtime cpp library
As of https://boringssl-review.googlesource.com/c/boringssl/+/66288,
libssl allows a C++ runtime dependency. As such, we need to link with a
cpp runtime library. Implementation is inspired heavily from
54c956b2e6.

Before releasing this change, we'll need to figure out a way to support
this for windows.
2025-01-06 16:08:33 +00:00
Paul Mabileau 7ac0d2105c Fix Windows build
Only with this does it work for us.

Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2024-11-27 12:56:03 -08:00
Jordan Rose 3044e9ba98 Skip bindgen 0.70's layout tests before Rust 1.77 2024-10-22 16:53:40 -07:00
Evan Rittenhouse 80e3aab37d boring-sys: include HPKE header file for bindgen
BoringSSL doesn't expose these APIs for FIPs builds, so we gate them
here as well
2024-10-17 10:18:52 -07:00
Yuchen Wu 0596b2dcab
Set MSRV to 1.70 (#279)
With the bindgen 0.70 upgrade, the default rust target is set to be 1.77,
which becomes the de facto MSRV of boring-sys since the change.

This change makes sure that the MSRV of boring-sys is kept at 1.70,
which is the same as that of bindgen.
2024-09-21 21:42:39 +02:00
0x676e67 9053b5d905
chore(boring-sys): Fix git apply patch on Windows (#261)
* chore(boring-sys): Fix git apply patch on Windows

* cargo fmt --all
2024-08-14 02:53:57 -07:00
Liu Dingming b96d2b88a4 Enable layout tests on iOS target 2024-03-24 11:11:05 -07:00
Rushil Mehra d3a42b0aeb Fix building with BORING_BSSL_PATH / BORING_BSSL_FIPS_PATH
When passing BORING_BSSL_FIPS_PATH, you need to add /lib/ to the search
path, and when passing BORING_BSSL_PATH you need to add /crypto/ and
/ssl/ to the search path.
2024-02-02 10:23:41 -08:00
Rushil Mehra 5aed467dcb Fix building with non bazel commits of boringssl
We need to add `/build/crypto` and `/build/ssl` to the library search
path to handle the case where we pass `BORING_BSSL_SOURCE_PATH` when
building without enabling any fips features. Otherwise, non bazel
commits will not work because `/build/` itself will not contain any
crypto libraries to link with
2024-02-02 14:56:55 +00:00
Anthony Ramine a8dea4a22c Introduce X509CheckFlags::UNDERSCORE_WILDCARDS 2024-01-02 15:37:36 +01:00
Jordan Rose 44f8f72a16 boring-sys: Blocklist max_align_t in bindgen
https://github.com/rust-lang/rust-bindgen/issues/1823
2023-12-14 13:25:47 +01:00
Jordan Rose 5dc531a38c boring-sys: Don't check for MSVC with target_env
x86_64-pc-windows-gnu is identified as `target_env = "msvc"` too,
but doesn't use the Visual Studio CMake generator.
2023-12-14 13:25:47 +01:00
Jordan Rose af0c36a22f boring-sys: Don't use CMake cross-compilation for macOS->iOS
(or macOS->macOS)
2023-11-30 15:03:23 +01:00
Anthony Ramine d7a13a8468 Fix clippy lint 2023-11-16 19:47:16 +01:00
Anthony Ramine 7434e35faa Introduce BORING_BSSL_SYSROOT and BORING_BSSL_EXTERNAL_TOOLCHAIN
These variables let us configure CMAKE_SYSROOT and
CMAKE_{C,CXX,ASM}_EXTERNAL_TOOLCHAIN from env variables
without needing an error-prone custom toolchain file.

Most users won't need BORING_BSSL_EXTERNAL_TOOLCHAIN, but some
packages (such as Homebrew package
messense/macos-cross-toolchains/x86_64-unknown-linux-gnu) don't
install the sysroot at the root of the GCC installation, so clang-12
cannot find crt1.o and crti.o.

Finally, we also set up CMAKE_CROSSCOMPILING and
CMAKE_{C,CXX,ASM}_COMPILER_TARGET to make cross compilation work
with compilers that have cross-compiling drivers (i.e. clang).

We can now cross build boring-sys from macOS to Linux with
fips feature turned on:

brew tap nox/misc
brew install llvm@12.0.0
export PATH="$(brew --prefix llvm@12.0.0)/bin:$PATH"

brew tap messense/macos-cross-toolchains
brew install x86_64-unknown-linux-gnu
export BORING_BSSL_FIPS_EXTERNAL_TOOLCHAIN="$(brew --prefix x86_64-unknown-linux-gnu)/toolchain"
export BORING_BSSL_FIPS_SYSROOT="$BORING_BSSL_FIPS_EXTERNAL_TOOLCHAIN/x86_unknown-linux-gnu/sysroot"

cargo build --target x86_64-unknown-linux-gnu -p boring-sys --features fips
2023-10-26 11:31:47 +01:00
Anthony Ramine ba0ea33ab4 Check for CMAKE_TOOLCHAIN_FILE when creating cmake config
We don't do anything fancy anymore for non-cross builds
and when a specific CMAKE_TOOLCHAIN_FILE is specified.
2023-10-26 11:31:47 +01:00
Anthony Ramine d8c2122c73 Continue looping if candidate cxx isn't found in verify_fips_clang_version
A basic LLVM 12 build provides clang-12 but not clang++-12, but
it does provide both clang and clang++, so we shouldn't hard fail
when first checking for clang-12 and clang++-12.
2023-10-26 11:31:47 +01:00
Anthony Ramine 9a0bd94f99 Replace feature no-patches with BORING_BSSL{,_FIPS}_ASSUME_PATCHED
Feature no-patches is ever only useful when setting other env variables
BORING_BSSL{,_FIPS}{,_SOURCE}_PATH, and it has no impact on the APIs
provided by any of the boring crates, so we may as well make it an env
variable itself so downstream users have less features to propagate
across their own crate graph.
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 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