231 Commits

Author SHA1 Message Date
Brian Smith
d0513bd767 Merge BoringSSL 53a87b7: ChaCha20-Poly1305 for Armv8 (AArch64). 2022-11-03 16:30:40 -07:00
Brian Smith
0fcbf92390 build: Fix recent symbol renaming to work on macOS. 2022-11-02 15:59:29 -07:00
Brian Smith
feae54128f Merge BoringSSL fa3fbda: P-256 assembly optimisations for Aarch64. 2022-11-02 13:15:58 -07:00
Brian Smith
1e3edb07eb ec: Avoid manual renaming of nistz256 symbols.
Make it easier to integrate the AArch64 nistz256 implementation.
2022-11-02 12:48:04 -07:00
Brian Smith
6b0050f08c Merge BoringSSL 295b313: Rename CPU feature files with underscores. 2022-10-31 16:17:20 -07:00
Brian Smith
9098bd6e30 Address latest clippy warnings. 2022-10-19 23:49:17 -07:00
Brian Smith
b2d1d00f3f Address clippy single_char_pattern in build.rs. 2022-04-07 17:40:03 -07:00
Brian Smith
155231fb01 signature: Enable Ed25519 support for wasm32 targets.
Ed25519 was disabled for WebAssembly due to some unrelated issues with
getting the X25519 code working in WebAssembly. Temporarily remove the
`agreement` API when targetting WebAssembly to work around those issues
in a way that lets us enabled Ed25519.
2022-04-06 12:54:49 -07:00
Brian Smith
d97ae1fd08 wasm32: Make wasm32_c the default and only mode; remove the "wasm32_c" feature.
Always require a C compilare for wasm32, instead of trying to provide a subset
of the functionality.
2021-10-06 15:53:02 -07:00
Brian Smith
4483f8ee55 build.rs: Don't package the intermediate files in the Cargo crate.
Don't package the inputs of the preassembly; just package the outputs.

Clarify how `mk/package.sh` interacts with `.gitignore`.

Eliminate unnecessary conditional logic in preassembly process.
2021-08-18 12:37:57 -07:00
Brian Smith
03ef33fc3b build.rs: Clarify include_dir and out_file function arguments.
Consistently use `out_file` as the argument name. Place all input arguments ahead of
output arguments.
2021-08-18 12:37:57 -07:00
Brian Smith
043c423a49 build.rs: Don't generate the C header for symbol prefixing during package.
The assembly headers used for Windows targets need to be generated during packaging so
that the assembly can be preassembled for those targets, but the C header isn't used
during packaging.
2021-08-18 12:37:57 -07:00
Brian Smith
c6f6be99f8 build.rs: Inline generate_prefix_symbols_nasm into its one caller.
Since there is only one caller, it doesn't need to be a separate function.
2021-08-18 12:37:57 -07:00
Brian Smith
74bf655d83 build.rs: Remove misleading comment.
On non-{x86,x86_64} Windows targets we also assume the C compiler
assembles. Remove the now-misleading comment.
2021-08-18 12:37:57 -07:00
Jeremy Soller
cc908a734b Add redox to LINUX_ABI 2021-08-16 12:54:43 -07:00
Alexander Ovchinnikov
ceb5b90f6e Enable building and running on Windows ARM64
I agree to license my contributions to each file under the terms given at the top of each file I changed.

Co-authored-by: Marc-André Moreau <marcandre.moreau@gmail.com>
2021-08-16 12:28:42 -07:00
Brian Smith
8fe3633ab9 build.rs: Refactor preassembly in package process in preparation for aarch64-pc-windows-msvc. 2021-08-15 16:01:32 -07:00
Brian Smith
b88024a96b build.rs: Replace Target::env with Target::is_musl.
Make the limited role of the `env` part of the target triple more clear.
2021-08-13 17:39:15 -07:00
Brian Smith
31e9f68406 build.rs: Refactor away Target::is_git to clarify logic.
Localize the use of the "is git" check to a single place and use more
descriptive variables for the various effects that this check has.

As a nice side effect, the loosly-typed `warnings_are_errors` parameters
that were threaded through functions are now gone.
2021-08-13 12:29:34 -07:00
Brian Smith
f43c0a9f65 build.rs: Don't assume MSVC targets are compiled with MSVC. 2021-08-13 10:04:47 -07:00
Brian Smith
7f5cd78190 build.rs: Remove unneeded logic to filter out .S files for -msvc
targets.

There is no case where we have .S files for -msvc targets, so this
filter doesn't filter anything out. IIRC, this is stale code from when
the situation was different in the past.

This reduces the amount of logic that is specific to "-msvc" targets and
makes the work to support clang and clang-cl for Windows, and to support
AAarch64 Windows, easier to review.
2021-08-13 10:04:47 -07:00
Brian Smith
31a32711c3 build.rs: Always use ".o" for object files.
Take a step towards supporting clang as the C compiler for -msvc
targets.
2021-08-13 08:18:14 -07:00
Brian Smith
b21ccc97a2 build.rs: Use cc-rs's built-in logic for warnings-as-errors.
Take a step towards supporting Clang as the compiler for -msvc targets.
2021-08-12 20:16:25 -07:00
Brian Smith
be3443f5c6 Appease Clippy 1.54. 2021-08-02 21:46:17 -07:00
Brian Smith
ce0b0a6b9b Undo some unnecessary differences from BoringSSL. 2021-05-12 19:06:16 -07:00
Brian Smith
b86067da4e Address clippy::vec_init_then_push. 2021-05-11 18:34:48 -07:00
Brian Smith
e898b00d53 Build: Derive FFI symbol prefix and FFI lib prefix from Cargo.toml "links".
Now "links" in Cargo.toml is the only thing that needs to be manually modified
when the prefix changes.

build.rs enforces that the package name and version are consistent with the
"links" field.
2021-05-03 16:28:56 -07:00
Brian Smith
badca90d14 Simplify assembly pre-generation mechanism.
Eliminate the extra Cargo.toml that was used just for this feature. It was
too error-prone to keep it in sync with the real Cargo.toml. Having one
Cargo.toml will allow us to reliably use the `CARGO_MANIFEST_LINKS` value
to keep the symbol prefix in sync with the `links` field in Cargo.toml in
the near future.
2021-05-03 13:36:20 -07:00
Brian Smith
36854dee45 build.rs: Tell Cargo about some environment variables that are used.
This doesn't tell Cargo about environment variables used by cc-rs and
the like, but it is a step in the right direction.
2021-05-03 13:36:20 -07:00
Brian Smith
0df1844530 Pass prefix from build.rs to src/prefixed.rs through cargo:rustc-env.
Eliminate one place where the prefix would have to be manually updated.
2021-05-03 12:39:35 -07:00
Brian Smith
7886603cee Use some variant of "ring core" instead of "GFp" as a prefix for everything.
"GFp_" isn't in the code at all anymore.
2021-05-02 22:09:07 -07:00
Brian Smith
384f7d056b Replace manual FFI symbol prefixing with automatic symbol prefixing.
Revert the names used in the BoringSSL C/asm code to the names used in
BoringSSL. This substantially reduces the diff between *ring* and
BoringSSL for these files.

Use a variant of BoringSSL's symbol prefixing machinery to semi-
automatically prefix FFI symbols with the `GFp_` prefix. The names aren't
all exactly the same as before, because previously we *replaced* a
symbol's original prefix with the `GFp_` prefix; now we're prepending
`GFp_`. In the future we'll use a different prefix entirely.

This paves the way for using different prefixes for each version so that
multiple versions of *ring* can be linked into an executable at once.
2021-05-02 22:09:07 -07:00
Brian Smith
0e800b80ce build.rs: Replace manual dirty file checking with cargo:rerun-if-changed.
Simplify build.rs to make it easier to maintain. It seemed like the logic
being removed here wasn't always correct.
2021-04-30 13:37:46 -07:00
Brian Smith
508f5a3293 CI/CD: Use a GitHub-hosted copy of nasm instead of downloading it from nasm.us.
Downloading from nasm.us frequently fails. Avoid depending on it.

Change the expected location of nasm in build.rs.
2021-04-29 15:10:32 -07:00
Brian Smith
f37b8a2f3e Only use assembly code on known-compatible OS+Arch combinations.
Assume by default that an operating system does not have an ABI compatible
with the PerlAsm sources. Add all the operating systems that we've
explicitly added support for to the allowlist. Avoid trying to build or
use the PerlAsm code for those targets.

On top of this, we can build fallback logic for using Rust (or C)
implementations for those targets that aren't compatible with the
assembly.
2021-04-20 15:45:28 -07:00
Brian Smith
501fc4eeaa Replace *ring*'s P-256 arithmetic with BoringSSL's P-256 arithmetic.
Use Fiat Crypto for non-x86_64 platforms, like BoringSSL. Continue
using the nistz256 code on Windows, differently from BoringSSL.

Make *ring* more consistent with BoringSSL.
2021-02-10 12:20:26 -08:00
Vlad Krasnov
34424d829d Enable the integrated assembly x86-64 ChaCha20-Poly1305 implementation from BoringSSL 2021-01-26 10:12:14 -08:00
Brian Smith
b9d7d089d9 Remove #![forbid(warnings)]; reply on Clippy in CI/CD instead.
The newest Rust Nightly is getting stricter about `forbid(warnings)`
which breaks the build.

Use "deny" instead of "forbid". And only deny when running Clippy in
CI/CD, so that when hacking on *ring* we don't have to deal with
warnings right away; we now only have to deal with them when we're ready
to submit a change to be merged.
2020-12-03 17:40:33 -08:00
Brian Smith
15c823a571 Build: Replace use of Yasm with use of Nasm for Windows assembly.
Match BoringSSL. According to the Chromium discussion about nasm, it
is also substantially faster.
2020-11-25 16:32:53 -08:00
Brian Smith
034bfe7143 Avoid opportunistically including system header files.
Don't use the presence of a header to determine whether to include it. Instead,
communicate from build.rs whether system header files should be used.
2020-11-24 09:22:50 -08:00
Brian Smith
7bac725679 Allow cross-compiling to *-linux-musl (except x86_64) w/o a sysroot.
Avoid requiring a sysroot for *-linux-musl targets when using Clang.

Add one AAarch64 and one 32-bit ARM MUSL target to GitHub Actions.

Use Rust 1.48's `-Clink-self-contained=yes` in CI for musl targets.

Support the non-default variants of the *-musl targets.
2020-11-24 09:22:50 -08:00
Brian Smith
f26bae0a6a Add support for aarch64-apple-darwin.
Change the static CPU feature detection logic to assume all aarch64-apple-* targets
have the same capabilities as far as the features we use are concerned.

Use the "ios64" PerlAsm flavour for aarch64-apple-darwin, like OpenSSL upstream does.

Add (build-only) cross-compilation jobs to GitHub Actions.
2020-11-18 00:00:12 -08:00
Brian Smith
f19c4f626b Remove dead crypto/fipsmodule/modes/internal.h. 2020-11-17 23:55:28 -08:00
Brian Smith
bbf935c17b Switch Poly1305 implementation to the BoringSSL implementation.
Previously the OpenSSL implementation was being used. Switch to the BoringSSL
version.

Switching to the BoringSSL implementation will make it easier to refactor the CPU feature
detection, which is important for upcoming ports.

This switch will also implicitly add support for BTI and pointer authentication for
Poly1305.

This is based on BoringSSL 63d06626d3a104868eee622e8e56d9f2dd643366.
2020-11-17 10:19:30 -08:00
Brian Smith
72abf71710 build.rs: Sort header files alphabetically 2020-11-17 10:19:30 -08:00
Brian Smith
6fcbd8905e build.rs: Remove printing of environment variables.
Avoid any potential for leaking sensitive environment variables that would
be irrelevant to the build.
2020-11-12 18:10:20 -08:00
Brian Smith
e19b16e9f8 build.rs: Take clippy's advice about unwrap_or_else. 2020-11-11 16:46:41 -08:00
Brian Smith
d05e9b19dc build.rs: Take clippy's advice about into_iter(). 2020-11-11 16:46:41 -08:00
Brian Smith
b7ff765577 build.rs: Take Clippy's advice about useless conversions. 2020-11-11 16:46:41 -08:00
Brian Smith
2befd3268e build.rs: Take Clippy's advice about removing unneeded &s. 2020-11-11 16:46:41 -08:00