Commit Graph

9240 Commits

Author SHA1 Message Date
Nolan Leake
9ea9ad65e6 Add symbols/cfi for assembly functions.
This is needed for some binary analysis programs (BOLT, in this case) to
find all the code.  A little ugly since we're putting labels that are
named as if they are local only in the global symbol table, but whatever,
there is plenty ugly and weird stuff in these assembly functions...
2019-02-22 23:19:28 -08:00
Nolan Leake
9da699f981 On x86_64, put constants in .rodata
Previously, they were in .text, which while not ideal, works just fine.  The
wrinkle is that since they were all in the same segment, no relocations were
generated for references to them.  Which again works just fine, until you
try to rewrite binaries.  In our case, using BOLT to add Spectre V1/V2
mitigations.  Moving them to .rodata is cleaner and forces the assembler
to generate the relocations that BOLT needs.
2019-02-22 23:19:28 -08:00
Jeffrey Griffin
7e80345321 SGX compatibility 2019-02-22 23:19:28 -08:00
Brian Smith
ef85df4781 0.14.6 2019-02-08 09:35:42 -10:00
Brian Smith
78b18778c7 Remove unused alignof macros. 2019-02-06 14:40:56 -10:00
Brian Smith
dbdc510653 Simplify endian conversion in C code.
The relevant Clang bugs have been fixed and the code that uses these
functions is basically unused on Windows so MSVC's optimizer is
irrelevant to it.
2019-02-06 14:39:49 -10:00
Brian Smith
dd5f7fec81 Move SYS_GETRANDOM stuff from C to Rust. 2019-02-05 19:41:48 -10:00
Brian Smith
52e46fe5eb Remove dead code in crypto.c. 2019-02-05 19:41:48 -10:00
Brian Smith
5dc4dda179 Use libc's types instead of defining our own ring::c.
As far as I know, `libc` is available for every target now. Especially
since the introduction of `bssl::Result` we hardly reference these
types, other than `size_t`. This will help get rid of crypto/crypto.c.
2019-02-05 19:41:48 -10:00
Brian Smith
e53936a348 On Windows, use winapi RtlGenRandom and associated types.
Now that Cargo can do target-specific dependencies, don't bother defining
this stuff ourselves.
2019-02-05 19:41:48 -10:00
Brian Smith
0261c4fafd Fix type declaration of GFp_p256_scalar_sqr_rep_mont.
See https://boringssl.googlesource.com/boringssl/+/23e1a1f2d3c4ca0121eb93eb7d210501f9702317
and the review comments of that commit for more details.
2019-02-05 19:41:48 -10:00
Dylan MacKenzie
98d7a92bc0 Remove 192-bit AES support in ARM assembly.
192-bit key support still exists in AES implementation for ARMv8.
Remove it, and leave comments documenting where code was removed.

As far as I can tell 192-bit keys are not supported in either the ARMv4
or vector-permutation based ARMv7 implementations.

This continues the work in
- 1103cf29df
- b3e91be71e
- and #707.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2019-02-05 14:57:43 -10:00
Brian Smith
03e6ef8c01 Avoid including <sys/syscall.h> on targets we already know about.
When cross-compiling to i686-unknown-linux-gnu from
x86_64-unknown-linux-gnu I found that this header wasn't found and the
build broken. Avoid that happening by only including this header when
we don't already know what it will tell us.
2019-02-02 16:08:12 -10:00
Brian Smith
32cf372b32 Remove last, superfluous, stdlib.h dependency. 2019-02-02 16:08:12 -10:00
Brian Smith
1194b80cb4 Simplify constant_time_test & remove its stdlib.h dependency.
Remove the trivial stdlib.h dependency from the test. Now the test
works more like other tests, so it's a double win.
2019-02-02 16:08:12 -10:00
Brian Smith
bd96baa7e4 Remove <stdio.h> dependency from tests.
SGX targets don't necessarily have file I/O and some embedded targets
don't either.

Do this in a minimal-effort way since this test file should get
replaced soon anyway.
2019-02-02 16:08:12 -10:00
Brian Smith
4a8140fa01 0.14.5. 2019-02-02 16:06:07 -10:00
Brian Smith
083972b6f8 Fix typo. 2019-02-02 14:04:18 -10:00
Brian Smith
ab0726d0cd Embed test data into test executables.
Embed test data files into test executables so that file I/O isn't
necessary during tests. This allows the tests to run on platforms that
don't have file I/O. It also makes it easier to run the tests on a
separate (virtual) machine from the build machine since the test
automation no longer needs to keep track of the test files.
2019-02-02 13:21:02 -10:00
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 8f8b74e2c8 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 c1c9c2221e.

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 0e80eeb2aa 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