12905 Commits

Author SHA1 Message Date
Qiu Chaofan
b6c35d54e3 Enable getrandom for AIX 2023-10-30 12:52:46 -07:00
Brian Smith
711d9fc062 AEAD benchmarks: Rewrite to avoid macros.
When this benchmark was imported from crypto-bench to *ring* and
ported from the libtest `#[bench]` framework to Criterion.rs, we
kept the macro-based structure from the original benchmarks. However,
Criterion.rs actually supports the kind of parameterized benchmarking
we do much more naturally, and so we don't need the macros. Get rid of
them.

Also remove distinction between TLS 1.2 and TLS 1.3 AAD. These
benchmarks were originally written long ago when the TLS 1.3 draft
specified a different AAD format.

I hope this will serve as a better example of how to write such
benchmarks than it previously did.
2023-10-27 10:08:58 -07:00
Brian Smith
e7cf02f403 Agreement docs: Eliminate redundant nested peer_public_key in example. 2023-10-26 16:10:15 -07:00
Brian Smith
61ad435f09 EC: Add scalar base point multiplication test case generator.
Add a new scalar base point multiplication test case generator that
where the points are *not* Montgomery-encoded. This way we don't need
to generate different test data files when the Montgomery encoding
for a curve isn't the same for 32-bit and 64-bit targets (P-521).

This version of the generator produces the test cases for all the
scalars that the current P-256 and P-384 tests generate, in the same
format; the only exception is that the point is not
Montgomery-encoded.
2023-10-26 10:25:46 -07:00
David Benjamin
4f2adbd947 Cherry-pick BoringSSL 50418af: Add some EC base point multiplication test vectors.
`git cherry-pick 50418afb7f7e9467bd9b01b42b7732ef46b96baa`.

Bring in the test vector generator unmodified.
2023-10-26 10:25:46 -07:00
Brian Smith
6613481632 Add P-521 to mk/generate_curves.py.
Add preliminary support for P-521 but don't sync the existing
(semi-)generated code with it.
2023-10-25 13:46:08 -07:00
Brian Smith
e83cf0c0bb Add simplified elliptic curve code generator.
Add a tool to generate and/or verify NIST curve boilerplate.

Sync the existing P-256 and P-384 code with the generator.
2023-10-25 13:46:08 -07:00
Brian Smith
3565fe830f EC Suite B: Remove reudndant "point_mul" tests.
When I generated these test vectors, I gave all of them the same point: the
generator of the curve. Consequently these input files are 100% redundant
with the `point_mul_base.txt` input files. So just remove them and use the
`point_mul_base.txt` files instead.
2023-10-25 10:03:48 -07:00
Brian Smith
be27e8e259 RSA signature verification: Save one multiplication.
Use David Benjamin's idea.
2023-10-20 18:05:47 -07:00
Brian Smith
9dd6141f91 NFC EC: Reduce scope of constant ONE. 2023-10-19 13:12:12 -07:00
Brian Smith
c3fda8b4dd 0.17.5. 2023-10-18 20:58:28 -07:00
Brian Smith
a86b7fabb9 0.17.5-alpha.1. 2023-10-18 20:58:28 -07:00
Brian Smith
27aa5386a0 EC P-384: Use array types for crossing Rust<->C boundary.
Avoid using the P384_POINT type on the C side. It seems to work for all
the targets we support, for P-384, but this pattern probably doesn't
work in general. Especially due to alignment issues for 32-bit targets,
it is doubtful it would work for P-521.
2023-10-18 11:39:04 -07:00
Brian Smith
327831e6b3 P-256 nistz: Use arrays instead of P256_POINT in boundary functions.
Better match the Rust declarations of these functions. Prepare to
support more target platforms and more weird things (like P-521) that
by avoiding any kind of alignment assumptions at the language
boundary (or elsewhere).
2023-10-18 11:39:04 -07:00
Brian Smith
159f52c769 Eliminate gathering during table construction.
When `elem_exp_consttime` replaced `BN_mod_exp_mont_consttime` I did
not fully understand the way the table was constructed in the original
function. Recent BoringSSL changes clarify the table construction. Do
it the same way, to restore performance to what it was previously.

This addresses the `// TODO: Optimize this to avoid gathering`.
2023-10-18 11:14:38 -07:00
Brian Smith
19fe19124b bigint elem_exp_consttime: Get rid of entry/entry_mut indexing.
When this code was written, it wasn't clear which assembly language
functions took a pointer to the entire state vs. just a pointer to
the accumulator (etc.). Now upstream clarified things and we can
clarify this code.
2023-10-18 11:14:38 -07:00
Brian Smith
d4bf41eb00 bigint elem_exp_consttime: Add some clarifying comments. 2023-10-18 11:14:38 -07:00
Brian Smith
9a49f379e3 P-256 ECDSA verification: Clarify multiplication.
Move more of the logic for the nistz256 multiplication into Rust.
2023-10-18 09:49:30 -07:00
Brian Smith
6283ca087f P-256 ECDSA verification: Use optimized nistz256 verification.
Import the optimized nistz256 verification from BoringSSL.
2023-10-18 09:49:30 -07:00
Brian Smith
dbfbba4f1a Import ecp_nistz256_points_mul_public from BoringSSL.
From BoringSSL commit 8d71d244c0debac4079beeb02b5802fde59b94bd.

Comment it out until it is modified to work.
2023-10-18 09:49:30 -07:00
Brian Smith
30665a9759 NFC P-256: Add twin_mul method to PublicScalarOps.
Allow each curve to provide its own `twin_mul` implementation. For now,
use the same implementation we've been using.
2023-10-18 09:49:30 -07:00
Brian Smith
2a0e495903 NFC EC: DRY oneRR_mod_n.
Avoid repeating the value of `oneRR_mod_n` twice in each file.
2023-10-17 10:47:15 -07:00
Vlad Krasnov
20672b2b09 Replace limbs initializer with const from_hex
The current macro initializer is not uniform across architectures,
and doesn't work when the number of 64bit limbs is not exactly half
that of 32bit limbs, (i.e. 521 bit).
This change replaces all limbs! initializers with a new const
function with hex string initializers, which is more portable and
more ergonomic.
2023-10-16 23:18:30 -07:00
Brian Smith
057de0ff98 0.17.4. 2023-10-15 20:57:03 -07:00
Brian Smith
e0bc21f51a 0.17.4-alpha.1. 2023-10-15 12:48:10 -07:00
Brian Smith
ae376cb94e rand: Sort target_os list. 2023-10-15 12:48:10 -07:00
Brian Smith
f56cc4190d rand: Remove redundant target_os = "wasi".
It's already included as part of the `all(target_arch = "wasm32" ...)`
below.
2023-10-15 12:48:10 -07:00
tema2
4aa1b14dcf use default rand impl for hermit since getrand has it for 8 month 2023-10-15 09:00:58 -07:00
Brian Smith
9d4bb22ef8 build.rs: Sort non-MSVC C compiler flags alphabetically.
All the `-W...` flags make do difference in packaged releases,
but `-fvisibility=hidden` is a big deal, so don't hide it after
all the warning stuff.
2023-10-14 22:03:50 -07:00
Brian Smith
8909e6eddf build.rs: Don't enable MSVC SDL warnings.
They hardly matter for this codebase any more.
2023-10-14 22:03:50 -07:00
Brian Smith
65941d014f build.rs: Don't override Windows exception/RTTI/C++ compiler flags.
Use whatever cc-rs does by default. This shouldn't impact us as we
don't use C++.
2023-10-14 22:03:50 -07:00
Brian Smith
2201721cd3 build.rs: Let cc-rs choose the hardening flags, if any.
Now that we have almost no C code in *ring* there's little
need for these extra hardening flags.
2023-10-14 22:03:50 -07:00
Brian Smith
89172b4ff6 rand: Clarify wasm32-logic logic.
Require `target_arch = "wasm32"` for `target_os = "wasi"`.
2023-10-14 18:29:44 -07:00
Brian Smith
c32f7a23d8 Digest tests: Don't disable tests for wasm32 targets. 2023-10-14 18:29:44 -07:00
Brian Smith
65aa65d49a NFC: Don't treat wasm32 differently w.r.t. dead-code warnings. 2023-10-14 18:29:44 -07:00
Brian Smith
1c476cd20c AEAD tests: Address wasm32-wasi build warning & clarify use. 2023-10-14 16:50:18 -07:00
Brian Smith
2986d15484 Use -nostdlibinc for wasm32-wasi like wasm32-unknown-unknown. 2023-10-14 16:50:18 -07:00
Brian Smith
8348897d92 CI: Add wasm32-wasi to CI. 2023-10-14 16:50:18 -07:00
JanKaul
2019d8482f Add support for wasm32-wasi.
[The files changed in this commit were part of the original PR. The
original PR also changed other files, but those changes were removed.]
2023-10-14 16:50:18 -07:00
Brian Smith
da23dc037e Use small Curve25519 for wasm32 & other non-{aarch64,x86_64}.
Enable `ring::agreement` for wasm32 targets using the small
implementation of Curve25519.

Use the small Curve25519 implementation of Curve25519 (and
P-256) for all targets except for Aarch64 and x86-64.

Besides being smaller, the small implementations are likely
more resistant to compiler-introduced side-channels, which
is especially important for the wasm32 virtual machine and
other targets that we don't QA as thoroughly as AAarch64
and x86-64.

Bring in the previously-removed definition of `fe_mul_llt`
from BoringSSL as of commit
8d71d244c0debac4079beeb02b5802fde59b94bd.
2023-10-14 16:49:57 -07:00
Brian Smith
0f8386dce2 CI: Don't test benchmarks in test and test-features jobs.
Benchmarks require Rust 1.65 or later currently due to benchmark-only
dependencies.

Also, benchmarks add a lot of downloading/build time because they have
many more dependencies. So, skipping them in these jobs makes them
faster.
2023-10-14 11:54:52 -07:00
Brian Smith
06e5d3b9e1 CI: Run tests for armv7-unknown-linux-musleabihf. 2023-10-13 17:56:01 -07:00
Brian Smith
99ab6db360 Add arm-unknown-linux-gnueabi testing to CI.
Replace arm-unknown-linux-gnueabihf in `test` since we already have
another gnueabihf target.
2023-10-13 17:45:30 -07:00
andoalon
08413016bf Don't manually specify optimization flags for MSVC (cc-rs takes care)
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2023-10-13 16:56:03 -07:00
Brian Smith
e7aedb26c6 Change documentation & unnecessary qualification warnings.
Don't warn during `cargo build` or `cargo test`, but deny them
in `mk/clippy.sh` so that they are caught in CI. Limit `cargo build`
warnings to things that matter during the edit/test cycle.
2023-10-13 16:11:25 -07:00
Brian Smith
ce184528d1 NFC: Remove outdated comment about old behavior of derive(...). 2023-10-13 16:11:25 -07:00
Brian Smith
f78a8418fa Remove some superfluous warning allow(...) overrides. 2023-10-13 16:11:25 -07:00
Brian Smith
bafde9dba7 Clippy: Move lint configuration to lib.rs. 2023-10-13 16:11:25 -07:00
Brian Smith
ff2cc71e94 Require wasm-bindgen-test 0.3.37.
This is the minimum we've tested.
2023-10-13 15:07:44 -07:00
Brian Smith
aa01858787 Require getrandom 0.2.10.
This is the minimum we've tested.
2023-10-13 15:07:44 -07:00