9221 Commits

Author SHA1 Message Date
Brian Smith
8df14638df cargo +nightly fmt. 2019-02-02 13:00:07 -10:00
Erick Tryzelaar
e08b833c9a Add support for fuchsia's CPRNG source
This is another attempt for ring to support fuchsia, by directly
calling `zx_cprng_draw` to generate random byte strings. This avoids
having to pull in an extra dependency (which #634 did). With this
change, all the ring tests pass on fuchsia.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.

Closes #428
2019-02-01 11:57:41 -10:00
Erick Tryzelaar
912c976f9b Add support for fuchsia cpu feature detection
This adds support for detecting arm features on a fuchsia device,
which uses the `zx_system_get_features` syscall to extract out
this information, which is described here:

https://fuchsia.googlesource.com/zircon/+/master/docs/syscalls/system_get_features.md

The feature constants can be found here:

https://fuchsia.googlesource.com/zircon/+/master/system/public/zircon/features.h

The type `zx_status_t` and ZX_OK are defined here:

https://fuchsia.googlesource.com/zircon/+/master/system/public/zircon/types.h#39
https://fuchsia.googlesource.com/zircon/+/master/system/public/zircon/errors.h#14

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2019-02-01 11:57:41 -10:00
Brian Smith
050d61647a 0.14.4 2019-01-31 10:12:25 -10:00
Brian Smith
b64f347424 Revert "Enable Kcov on macOS builds."
This reverts commit 8f8b74e2c84cf406f941e28c40710f59f776bece due to
frequent build breakage on Travis CI for macOS debug builds.
2019-01-31 08:44:21 -10:00
Brian Smith
a051eb6e32 Speed up the construction of HMAC keys.
It didn't occur to me that people would care very much about optimizing
the key construction step, but
https://brycx.github.io/2018/08/06/hmac-and-precomputation-optimization.html
indicates otherwise.
2019-01-31 00:29:41 -10:00
Brian Smith
154ca296ce Replace libstd with spin crate in cpu::cache_detected_features.
Eliminate one of the two remaining problems with `#![no_std]` support
and reduce platform variance.
2019-01-30 23:18:48 -10:00
Pietro Monteiro
8f8b74e2c8 Enable Kcov on macOS builds.
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2019-01-30 23:15:35 -10:00
Brian Smith
88d3279cba Attempt to fix markdown rendering of API level documentation in README.md. 2019-01-30 16:55:08 -10:00
Brian Smith
5c8c13e6d8 Expand and clarify documentation about Android testing. 2019-01-30 16:48:57 -10:00
Brian Smith
4442eaffec Minimize the use of as in DER parsing. 2019-01-30 16:45:59 -10:00
Pietro Monteiro
49ec4809b6 Build Android targeting API 26 and test with API 24 system image.
Testing with API 24 images because there are no API 26 ARM images available.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2019-01-30 16:42:31 -10:00
Brian Smith
c7f0eadf0f Move ARM CPU feature caching from C to Rust.
Some of the targets in Rust's `cross` toolchains have old libc headers
that don't have sys/auxv.h, and we want to do this in Rust anyway.

Unfortunately, in the process of doing so, I found out that
`libc::getauxval()` isn't available in enough places either, so we skip
dealing with *that* too.
2019-01-28 14:33:31 -10:00
Brian Smith
387a6965ff Move remaining AEAD feature detection from C to Rust. 2019-01-28 14:33:31 -10:00
Brian Smith
980cc01c0b Move Curve25519 ARM NEON detection from C to Rust. 2019-01-28 14:33:31 -10:00
Brian Smith
3dfbe3bf6b Do GCM CPU feature detection in Rust.
Rename some GCM assembly functions so that all functions that do the
same thing the same way have the same name, to make the dispatching
logic simpler.

Thread CPU feature caching witnesses through the GCM dispatching logic
to make feature detection less error-prone.

Start an internal Rust API for feature detection.
2019-01-28 14:33:31 -10:00
Brian Smith
df627f6650 Represent detected CPU features as an object. 2019-01-28 14:33:31 -10:00
Brian Smith
c90a802d82 cargo +nightly fmt. 2019-01-28 14:33:31 -10:00
Brian Smith
38a2237a74 Revert "Allow Aad to own its contents."
This reverts commit c1c9c2221ef26c7cb808ffe79dad4217bd7f431b.

I am looking at improving the API in a different way, so I'm undoing
this change to reduce churn in the interim.
2019-01-25 09:57:26 -10:00
Brian Smith
abbb616b57 Implement Debug for OpeningKey and SealingKey. 2019-01-23 16:40:16 -10:00
Brian Smith
c15607558e Simplify use of derive_debug_via_field! when there is no type alias. 2019-01-23 16:39:19 -10:00
Brian Smith
c1c9c2221e Allow Aad to own its contents.
This allows `Aad` to be returned by value from functions, which is useful in
many cases.
2019-01-23 08:18:28 -10:00
Ian Chamberlain
7b8bfa745a Remove misplaced code block boundary
The "Submodules and file naming" section ended with three backticks (` ``` `), which caused the next section to be unformatted instead of using proper Markdown formatting.
2019-01-23 08:15:46 -10:00
Brian Smith
5f670008e3 Push use of Aad type down to the aead::gcm. 2019-01-22 17:19:39 -10:00
Brian Smith
7bad631ec0 Define GCM128_KEY the same way in both Rust and C. 2019-01-22 17:12:14 -10:00
Brian Smith
576cfc4813 Remove string.h dependency from gcm.c. 2019-01-22 17:12:14 -10:00
Brian Smith
4b1a699488 Remove redundant lifetime parameters from AEAD internal functions.
Follow-up on 0e80eeb2aa05615b3bab00af32c387c53115e6ac by simplifying
things furtuer.
2019-01-22 16:43:31 -10:00
Brian Smith
eec4d82f95 0.14.3. 2019-01-22 16:35:11 -10:00
Brian Smith
0e80eeb2aa Loosen lifetime requirements for aead::open_in_place().
Tying the lifetime of the `aad` parameter to the lifetime of the
input/output buffer was an accident. Separate them.
2019-01-22 10:07:42 -10:00
Brian Smith
1445fa4367 Improve and test various key type Clone/Debug implementations. 2019-01-19 19:56:02 -10:00
Brian Smith
8bdf5806bb Replace unimplemented!() with unreachable!() in AES-GCM.
The line is unreachable.
2019-01-19 17:24:30 -10:00
Pietro Monteiro
0f246702f1 Re-enable and update Kcov.
Run on Rust stable.
Install C++ compiler and other Kcov dependencies.
Don't install sources and packages that are not needed.
Update Kcov to the latest version.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2019-01-19 17:15:50 -10:00
Pietro Monteiro
59b550c074 Travis CI changed its defaults to sudo enabled Ubuntu Trusty.
Removed unnecessary `sudo` entries.
Make `distro` explicit in case we want to mix Linux build environments.
Adjust compiler packages to the correct defaults.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2019-01-19 17:15:42 -10:00
Brian Smith
af1bd64d0f Stop disabling -Wcast-align. 2019-01-19 10:12:40 -10:00
Brian Smith
4c345bca47 Enable -Wconversion and -Wsign-conversion. 2019-01-19 10:12:40 -10:00
Brian Smith
5369ae46bd Remove currently-unused elem_exp_vartime test code. 2019-01-19 09:20:39 -10:00
Brian Smith
7ee3976792 Add (coverage) test for rsa::bigint::PublicExponent Debug formatting. 2019-01-19 09:14:50 -10:00
Brian Smith
278d64c569 Add (coverage) test for rsa::bigint::Modulus. 2019-01-19 09:09:17 -10:00
Brian Smith
81d5662da6 Start running kcov in CI again.
Restrict code coverage to X86_64 for now.

We need to investigate the build faliures for 32-bit x86 before we can
enable it for that architecture.
2019-01-18 15:38:29 -10:00
Brian Smith
4a1a843d96 Remove dead code in build script for "default clang" on Linux.
This code was a no-op, which can be seen by running
mk/update-travis-yml.py and observing that it didn't change anything.
2019-01-18 15:35:05 -10:00
Brian Smith
52c0e56dda 0.14.2. 2019-01-18 12:50:06 -10:00
Brian Smith
36039cf0b6 Fix x86-64 integrated AES-GCM feature detection.
The integrated code path requires CLMUL too.
2019-01-18 12:50:06 -10:00
Brian Smith
b9a6d04826 Remove unnecessary implicit signed/unsigned conversion in aes.c. 2019-01-18 12:50:06 -10:00
Brian Smith
ee9dc7ad52 Prevent implicit type conversion in crypto/fipsmodule/bn/generic.c.
`num >= 4` is not the same as `num & ~3`. This is pretty much a no-op
change because we expect that we'll never encounter a situation where
`num` is too large to be represented as a 32-bit integer.
2019-01-18 12:43:31 -10:00
Brian Smith
0cd9bf6f64 Use C instead of assembly fallback code in GCM on X86_64.
This will ensure that this code is tested in CI and is being compiled
by MSVC; previously this C code wasn't being tested at all because all
platforms we use for testing were taking other code paths.
2019-01-18 12:40:41 -10:00
Brian Smith
225f6b0c3a Fix GCM on Aarch64 platforms without PMULL, e.g. Raspberry Pi 3.
The GHASH part of the tag was effectively being truncated to 16 bits
each round because of a type confusion error. Prior to commit
c4e76592fb2983cd17d20882bf391377b9c44395, the `Xi` parameter of
`GFp_gcm_ghash_4bit` was `uint64_t Xi[2]` and it worked correctly.
In c4e76592fb2983cd17d20882bf391377b9c44395 the type was changed to
`uint8_t Xi[16]`. Most of the code was adapted to the new type,
except these two lines. In particular, note that in that commit that
`GFp_gcm_gmult_4bit` did have the same change made to it.

This only affects AAarch64 platforms without PMULL. X86, X86_64,
and 32-bit ARM have only assembly language code for GCM that is used
instead, so they are unaffected. AAarch64 platforms with PMULL, e.g.
most phones, are not affected because they will use the PMULL-based
code. Consequently, this code wasn't being tested in CI or in most
other configurations.

The C compilers didn't catch this because Clang and GCC do not enable
`-Wconversion` even when `-Wextra` is provided, and because this code
is never compiled with MSVC. A future commit will change both of these
aspects. I verified that MSVC 2017 catches this bug immediately as soon
as allow it to be compiled for X86_64.
2019-01-18 12:36:06 -10:00
Brian Smith
94d4c810c6 Remove now-unused GHASH_CHUNK in gcm.c. 2019-01-16 17:19:23 -10:00
Brian Smith
87031013b7 0.14.1. 2019-01-15 08:07:57 -10:00
Brian Smith
902e3c7b6a cargo +nightly fmt. 2019-01-14 18:07:57 -10:00
Brian Smith
7d60a6690a Fix formatting of ring::rsa::verification module doc comment. 2019-01-14 18:07:39 -10:00