Commit Graph

82 Commits

Author SHA1 Message Date
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 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
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 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
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 edfe18b196 Add missing cmake files to the package 2023-08-05 14:32:02 +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 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
Ivan Nikulin 959d7c034e Reduce release bundle size by excluding PQ test data 2023-08-01 18:36:51 +01:00
Nathan Mittler 74fd7a8ce4 Adding hmac.h to included headers
This was originally going to be fixed by #101, however that PR was closed and superseded by #117, which was missing this fix.

The original problem was caused by #97, which updated boringssl to a version that included [a change that removed hmac.h from ssl.h](05b360d797).

This PR adds an include for hmac.h, so it is again available through boring-sys.
2023-08-01 19:13:19 +02:00
Ivan Nikulin 2475ef386b Reduce release bundle size by excluding PQ test data 2023-08-01 17:51:44 +01:00
Ivan Nikulin 33e3d756ff Fix builds for features that require git patches
Previously we were building from the deps directory with submodules. For publishing we were copying files in sumbodules into the package. With this we were making the package directory dirty with build artifacts and applied patches.

This commit change the build script's behaviour: sources are now copied to the output directory and then boringssl is built from there.

In addition, this commit adds files that were missing from the package for building with patches.
2023-08-01 17:33:29 +01:00
Ivan Nikulin 6435c5b8d5 Fix publishing 2023-08-01 11:32:20 +01:00
Ivan Nikulin c12bfc21f6 Release 3.0.0 2023-07-28 14:07:22 +01:00
Ivan Nikulin 4761cf7805
Merge pull request #84 from signalapp/macos-cross-compile
boring-sys: Handle cross-compiling macOS targets
2023-07-28 13:21:04 +01:00
Ivan Nikulin 4e190ad00c
Merge pull request #95 from signalapp/libsignal-arm
boring-sys: Add support for cross-compiling to Linux ARM(v7)
2023-07-28 13:20:32 +01:00
Jordan Rose a39f0c78ee boring-sys: Handle cross-compiling macOS targets
...such as compiling for Apple Silicon on an Intel Mac.
2023-07-27 13:17:40 -07:00
morph027 bb5caa43a2 boring-sys: Add support for Linux ARM(v7)
Signed-off-by: morph027 <stefan.heitmueller@gmx.com>
2023-07-27 13:15:53 -07:00
Jordan Rose 32feb4f958 boring-sys: Update Android NDK sysroot path
This longer path (inside the prebuilt toolchain included in the NDK)
has been the preferred sysroot since NDK r19. Newer NDKs no longer
have a top-level "sysroot" directory at all.
2023-07-27 13:12:57 -07: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
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
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
Anthony Ramine 530db8841b Bump bindgen to 0.65.1 2023-05-05 11:58:47 +02:00
Anthony Ramine 74b0cc0da7 Fix lints 2023-03-27 13:15:12 +02:00
Ivan Nikulin 3059ba6e10
Merge pull request #78 from signalapp/aarch64-cross-compilation
Add minimal cross-compilation support for Windows and AArch64 Linux
2022-09-27 16:14:52 +01:00
Joshua Nelson da2c13e761 Update changelogs and bump version numbers 2022-09-16 13:03:26 -05:00
Joshua Nelson bd4f8d58ef Fix clippy warnings 2022-09-16 12:13:55 -05:00
Jordan Rose a117901fe0 boring-sys: Use the Android NDK sysroot when running bindgen 2022-07-25 19:31:59 -04:00
Jordan Rose 3bbb1b94b6 Add minimal cross-compilation support for Windows and AArch64 Linux
Cross-compiling to AArch64 Linux can be done with a CMake toolchain
file, along with setting the correct compiler and include paths in the
environment.

Cross-compiling from X64 Windows to ARM64 Windows doesn't look at the
toolchain at all, because CMake + Visual Studio can already
cross-compile. Unfortunately, the Visual Studio CMake generator
doesn't set CMAKE_SYSTEM_PROCESSOR, which is what the BoringSSL
CMakeLists.txt is looking at to choose the architecture. For now,
disable the use of assembly when cross-compiling on Windows (assuming
that the Visual Studio generator will be used there).
2022-06-27 18:01:55 -07:00
msoxzw 74a453d8b0 MSVC generator hack should be only applied to MSVC 2022-06-17 15:13:36 -05:00
Alexis (Poliorcetics) Bourget ccc0128cba chore: update to bindgen 1.60 2022-06-07 02:17:18 -05:00
ilammy 76ba5429d7 boring-sys: Disable alignment tests for iOS ARM64 targets
As pointed out in the comment, bindgen generates tests that cause
compiler warnings about misaligned references. bindgen people are
aware of the issue, but we have to deal with our warnings that are
treated as errors. For the time being, suppress alignment tests
on platforms that are known to be triggering UB.

I suspect that other non-x86 platforms are affected as well, but I can't
get the tests to compile for those tests at the moment, so I'm not sure.
Dealing with the issues one platform at a time.
2022-06-03 09:11:38 -05:00
ilammy 51e99ea9c0 boring-sys: Configure "rustc-cdylib-link-arg" only for macOS targets
cfg!() is evaluated for the host OS executing build.rs script.
What we need here is to look whether we are building *for* macOS.

Otherwise, for example, builds for iOS on macOS will try to add this
flag, causing warnings since rustc does not build cdylibs on iOS.
2022-06-03 09:11:38 -05:00
ilammy 11910f1e7c boring-sys: Pass "-isysroot" to bindgen for iOS builds
When bindgen generates bindings for iOS, it must be told to use iOS
sysroot with all the standard C headers. Otherwise it tries using
the host macOS headers and fails miserably.
2022-06-03 09:11:38 -05:00
ilammy d3486e40c5 boring-sys: Support "aarch64-apple-ios-sim" targets
"aarch64-apple-ios" is for iOS devices running ARM64.

"aarch64-apple-ios-sim" is for iOS Simulator running on M1 macs.
2022-06-03 09:11:38 -05:00