1749 Commits

Author SHA1 Message Date
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
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
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
89172b4ff6 rand: Clarify wasm32-logic logic.
Require `target_arch = "wasm32"` for `target_os = "wasi"`.
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
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
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
8edeead004 Minimize scope of clippy::upper_case_acronyms. 2023-10-13 15:03:55 -07:00
Brian Smith
83719c4c0f AEAD/Polyfill: Use ArraySplitMap instead of ChunksFixed.
This is a step towards eliminating the `unsafe` code in `ChunksFixed`.
2023-10-13 11:29:41 -07:00
Brian Smith
32f209e0fd ChaCha20: Use ArraySplitMap to construct Iv.
This is a step towards eliminating the `unsafe` in `chunks_fixed()`.
2023-10-13 11:29:41 -07:00
Brian Smith
ff3febd530 AEAD/Polyfill: Implement ArraySplitMap and construct nonces with it.
This is a step towards eliminating the `unsafe` code in `ChunksFixed`.

chacha nonce
2023-10-13 11:29:41 -07:00
Brian Smith
75c620a5f1 ChaCha20 Polyfill: Remove ChunksFixedMut.
It is only used in one place so it isn't justified.
2023-10-13 10:38:21 -07:00
Brian Smith
f8cad224b5 AES: Remove use of ArrayEncoding.
Take a step towards reducing `unsafe` by eliminating another use of
`ArrayEncoding`.
2023-10-11 12:33:22 -07:00
Brian Smith
b1147381c9 Generalize array_flatten into an ArrayFlatten trait. 2023-10-11 12:33:22 -07:00
Brian Smith
faf347a24c AES-GCM: DRY Iv -> Block conversion. 2023-10-11 12:33:22 -07:00
Brian Smith
e6085e717f AEAD: Remove all use of ring::endian and u64 from Block.
In particular, eliminate the use of `ArrayEncoding::as_byte_array` as
we work towards removing that function because it uses `unsafe`.

Where `Block` is used in parameters to C/assembly code, I verified that
the C/assembly code uses `uint8_t *` as the function type (meaning
`uint8_t[16]`) in the BoringSSL headers. Until recently the stuff in
GCM was using `uint64_t` or a union containing `uint64_t`, which is why
block was previously defined in terms of `BigEndian<u64>`.
2023-10-11 11:35:05 -07:00
Brian Smith
797a6eece9 remove From<[u64; 2]> for Block 2023-10-11 10:14:39 -07:00
Brian Smith
e0eb70d848 Remove From<Block> for [u64; 2]. 2023-10-11 10:14:39 -07:00
Brian Smith
8a6d6f4dbe GCM: Remove use of Into<[BigEndian<u64>; 2]>.
Take a step towards removing the `u64` functionality from `Block`.
2023-10-11 10:14:39 -07:00
Brian Smith
d30dda0745 Remove LittleEndian usage from Poly1305 and delete LittleEndian.
This is a step towards eliminating `unsafe` usage in `ring::endian` by
eliminating one use of `ArrayEncoding::as_byte_array`.

Since this is the only usage of `LittleEndian`, it is removed
completely.

This simple `array_flatten` polyfill will be useful for multiple
improvements towards eliminating the unsafe code in `endian`.
2023-10-10 23:45:12 -07:00
Brian Smith
7cc44151d5 Remove use of ring::endian from aead::chacha20_poly1305_openssh.
This is a step towards removing `ArrayEncoding::as_byte_array()`.
2023-10-10 23:14:53 -07:00
Brian Smith
19c0d1e527 NFC: Safety: Remove endian::FromByteArray.
Remove one `unsafe` from `ring::endian` by completely removing `FromByteArray`.
2023-10-10 22:46:06 -07:00
Brian Smith
639ab71e64 Use CRYPTO_memcmp name the same as BoringSSL.
*ring* defined a function named `OPENSSL_memcmp` that did what
`CRYPTO_memcmp` does in BoringSSL, and BoringSSL has a different
function called `OPENSSL_memcmp`. *ring* doesn't need
`OPENSSL_memcmp` so sync the `CRYPTO_memcmp` stuff with BoringSSL.

This eliminates unnecessary differences from BoringSSL.
2023-10-09 15:17:19 -07:00
Brian Smith
29fb82717c Arithmetic Tests: Remove superfluous use of libstd/alloc.
arithmetic/montgomery is used in code that doesn't require `alloc`, so
make its integration test also not require `alloc`.
2023-10-08 20:02:11 -07:00
Brian Smith
19c5094cd0 Remove #![doc(html_root_url)].
Documentation isn't hosted on briansmith.org anymore.
2023-10-06 21:37:59 -07:00
Tom Dryer
2afc921340 Allow accessing signature::UnparsedPublicKey bytes
Implement `AsRef<[u8]>` for `signature::UnparsedPublicKey`, making it
possible to access the bytes of the public key. For consistency, I did
the same for `agreement::UnparsedPublicKey`, although it already has a
`bytes` method. `agreement::PublicKey` already uses the `AsRef<[u8]>`
approach.

Also, add missing `Debug` implementation for
`signature::UnparsedPublicKey`.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2023-10-06 11:07:03 -07:00
Brian Smith
a2ca505bb0 Enable FE25519_ADX X25519 on x86-64 except Windows. 2023-10-06 09:54:59 -07:00
Brian Smith
af7c37f8af Enable FE25519_ADX Curve25519 base point mult. except on Windows. 2023-10-06 09:54:59 -07:00
Brian Smith
5aa224c4bc Import constant_time_conditional_memcpy from BoringSSL.
Previously we didn't need it. Now we do.
2023-10-06 09:54:59 -07:00
Brian Smith
5a5f6d71c6 NFC: Reduce scope of #[allow(unused_variables)] in X25519. 2023-10-04 11:26:12 -07:00
Luis Cruz
8387c3953e Add apple tvos support 2023-10-03 11:54:18 -07:00
Brian Smith
c4a6ec8662 ECC: Better encapsulate Curve25519 base point multiplication.
Combine some `unsafe` blocks and create a more logical interface.
2023-10-02 15:18:28 -07:00
Brian Smith
e4a85afb58 ARM & Aarch64: Add ability to disable hardware crypto for testing. 2023-10-01 21:29:57 -07:00
Noel Tautges
0bf9d2ac1f Encode public key in Ed25519 PKCS#8 v2 template with a primitive encoding to conform with spec and make it parse with der >=0.5 2023-10-01 21:29:14 -07:00
Brian Smith
6e82dd3c75 Add powerpc-unknown-linux-gnu support. 2023-10-01 18:25:37 -07:00
Ulrich Weigand
079a4faef6 Support big-endian platforms 2023-10-01 14:33:16 -07:00
Brian Smith
7b1937d3a8 NFC: CPU: Clarify safety invariants around OPENSSL_armcap_P. 2023-10-01 14:25:39 -07:00
Brian Smith
bad63fb73f CPU: ARM: Remove bogus static assertion about 32-bit ARM.
It is possible that a 32-bit ARM target could have static crypto CPU features.
2023-09-30 22:28:29 -07:00
Brian Smith
301f31671b NFC: Polyfill const_option feature. 2023-09-30 20:25:46 -07:00
Brian Smith
901441fd59 MSRV 1.61.0: Use cfg!(target_feature) for static AARCH64 feature detection. 2023-09-30 17:41:26 -07:00
Eric Richter
c163528d3e cpu/arm: allow dead code in cpu/arm mod when building on non-arm
Other architectures may not need to do feature checks, and therefore
Feature::available, Feature::mask, etc are never used/read.

This snippet mirrors the similar bit at the top of cpu/intel.

Signed-off-by: Eric Richter <erichte@linux.ibm.com>
2023-09-30 17:18:58 -07:00
Jessica Hamilton
f5c5014f12 Enable Haiku platform. 2023-09-30 14:34:26 -07:00