Commit Graph

3150 Commits

Author SHA1 Message Date
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
Ivan Nikulin 7cfe2065a3
Merge pull request #115 from nox/bindgen
Bump bindgen to 0.65.1
2023-05-09 23:04:37 +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 2ceb99216f Implement ToOwned for X509StoreRef and Clone for X509Store 2023-05-05 11:10:42 +02:00
Alex Gaynor b36b1705b3 Fix race condition with X509Name creation 2023-05-05 11:10:11 +02:00
Alex Gaynor 90dfe2f912 Document the horror show 2023-05-05 11:10:11 +02:00
Alex Gaynor c80e3a3ec5 Always provide an X509V3Context in X509Extension::new because OpenSSL requires it for some extensions (and segfaults without) 2023-05-05 11:10:11 +02:00
Alex Gaynor 0f28001027 Resolve an injection vulnerability in EKU creation 2023-05-05 11:10:10 +02:00
Alex Gaynor 1eea7c5271 Resolve an injection vulnerability in SAN creation 2023-05-05 11:10:10 +02:00
Rob Shearman ae0cd6b98e Add X509Name to/from DER methods
Since X509Name is more complex than a single value (it's a a sequence
of entries) it's useful to be able to serialise/deserialise to/from
flat data, and DER is a natural form for this.

So add a {i2d,d2i}_X509_NAME -sys functions, and to_der/from_der
wrappers in X509NameRef and X509Name respectively.

Originally added in https://github.com/sfackler/rust-openssl/pull/1534
2023-05-05 11:10:10 +02:00
Joshua Nitschke f8e225e6a4 Add additional function so that x509 name with specific type can be added
Originally added in https://github.com/sfackler/rust-openssl/pull/1371
2023-05-05 11:10:10 +02:00
Ivan Nikulin 4ce9c50b63
Merge pull request #116 from nox/clippy
Fix all clippy lints
2023-05-05 09:44:30 +01:00
Anthony Ramine 74b0cc0da7 Fix lints 2023-03-27 13:15:12 +02:00
Anthony Ramine 6d61bf2adb Fix google test
Sometimes google replies with 302 to redirect to another Google website
with a country-specific TLD. We don't actually care which status code
is returned, just that we successfully connect to google.com with
the HTTPS connector.
2023-03-27 13:14:40 +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
Tobias Bucher 8c2c2bd2b6 Add link in docs 2023-02-28 14:33:07 +01:00
Tobias Bucher f102b3792b psuedo → pseudo 2023-02-28 13:27:35 +01: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 34929928c4 bump version number for tokio-boring
this is necessary so we can publish a version with the `fips` feature,
even though in practice the crate is exactly the same.
2022-09-16 13:13:08 -05: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
Joshua Nelson 774e721ad9 Remove uses of `mem::uninitialized`
According to [the docs](https://doc.rust-lang.org/stable/std/mem/fn.uninitialized.html),

> Calling this when the content is not yet fully initialized causes immediate undefined behavior.
> it [is] undefined behavior to have uninitialized data in a variable even if that variable has an integer type.

Using MaybeUninit instead, as recommended by the official documentation, avoids undefined behavior by not creating a `&mut` reference to uninitialized data.
2022-09-16 12:13:55 -05:00
4JX 3841e626ae Remove T: Debug bound 2022-08-09 10:04:22 -05:00
4JX 3417b41b5b hyper-boring: Impl debug for MaybeHttpsStream 2022-08-09 10:04:22 -05:00
Jordan Rose 172b623bcc boring: Expose PKey::private_key_to_der_pkcs8(_passphrase) 2022-07-28 16:30:41 -07:00
Jordan Rose a117901fe0 boring-sys: Use the Android NDK sysroot when running bindgen 2022-07-25 19:31:59 -04:00
Ravi Khadiwala db03da82fd boring: Fix memory leak in `Deriver` 2022-07-01 12:44:04 -05: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 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
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
ilammy f7673415bf boring-sys: Use TARGET to determine iOS CMake params
The architecture alone is not enough. aarch64-apple-ios and
aarch-apple-ios-sim are both building for aarch64, but they need
slightly different CMake flags.
2022-06-03 09:11:38 -05:00
ilammy 06cf604b3a boring-sys: Pull iOS CMake params into a function 2022-06-03 09:11:38 -05:00
ilammy 570cc95c90 boring-sys: Pull Android CMake params into a function 2022-06-03 09:11:38 -05:00
Jordan Rose 00b14f6379 boring-sys: Save time by not building the bssl CLI utility
We only need libcrypto and libssl.
2022-06-02 18:48:35 -05:00
BiagioFesta 863b72b3a8 ssl/test: fix UT expectations accordingly with boringssl change
- boringssl fix:
https://boringssl.googlesource.com/boringssl/+/c02c19e0d842f54d903a9b62316476f4b9c4e3f0

- Now ALPN validation with SSL_TLSEXT_ERR_ALERT_FATAL makes the server
abort the handshake with an alarm. UT now correctly asserts
connection error on both client and server side.
2022-04-28 11:29:13 -05:00
BiagioFesta e141e834f1 Update boringssl deps for quiche 0.12.0 compatibility
- ExtensionType::TOKEN_BINDING removed from implementation
d89ec688f2

- ExtensionType::ECH_IS_INNER removed from implementation
18b6836b2f
2022-04-28 11:29:13 -05:00
ilammy e6ddc40333 boring: BigNumRef::to_vec_padded()
Wrap BN_bn2bin_padded() which comes useful for exporting fixed-length
BIGNUMs, more efficient than padding result of to_vec() afterwards.

Note that in OpenSSL the function is called BN_bn2binpad() and has
a different order of arguments. BoringSSL's BN_bn2bin_padded() also
takes the desired length as "size_t".
2022-02-12 12:20:36 -06: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
ilammy 5f327aba86 boring: Suppress Clippy warnings about missing safety docs
I'm not quite sure why these are unsafe traits, probably to prevent
implementing them for random types accidentally. However, Clippy
demands a "# Safety" section in their docs. Tell it to get lost.
2022-01-04 18:27:39 -05:00
Joshua Nelson db6867b794 Add/update changelogs 2021-12-16 13:52:38 -06:00