403 Commits

Author SHA1 Message Date
Brian Smith
ed27bbb24d Factor out gfp_little_endian_bytes_from_scalar from ecp_nistz256.
Factor out duplicate code. Parameterize the code on the size of the
scalar it works on and move it to a place that can be used by the
upcoming ecp_nistz384.
2016-07-09 10:30:45 -10:00
Brian Smith
916ad46366 Use nistz256 on all platforms. 2016-07-06 12:44:32 -10:00
Brian Smith
c7f8220c6a Rename crypto/ec/p256-x86_64 -> crypto/ec/ecp_nistz256.
The code is still only used on x86-64, but in the future *ring* will
use it on more platforms. With that in mind, switch to the old OpenSSL
names, which reflect that better. The table was renamed to have an
".inc" extension because we're #including it in ecp_nistz256.c. The
and making sure the `alignas` stuff stays in sync.
2016-07-06 11:37:06 -10:00
Brian Smith
6c224a6a73 Use Xcode 7.3 in Travis CI. 2016-07-06 09:31:55 -10:00
Brian Smith
bf55fc2533 Clarify licensing of P-256 implementation of mul/sqr mod n.
Remove the assembly language changes to p256-x86_64-asm from
commit ee8b0e68ccabbb976ef835be8ec26417b1e431c2. Import the changes
that Shay Gueron posted to the openssl-dev mailing list, subject
"[openssl-dev] [openssl.org #3810] [PATCH] Improved P256 ECC
performance by means of a dedicated function for modular inversion
modulo the P256 group order".

Adjust the code in the new file so that it builds on Windows using Yasm
by using the new label names that come from a later version of the
patch in response to my code review long ago. Also, clean up the
whitespace a bit.
2016-07-06 09:31:51 -10:00
Brian Smith
cf6dfad269 Remove the dependency on the num crate.
Now we don't have to trust that `num` is doing the math correctly. The
code generator is going away anyway. It's a good idea in theory but in
practice it wasn't worth its complexity.
2016-07-03 10:38:08 -10:00
Brian Smith
224c1e02e5 Auto-generate Travis CI targets for ARM and AAarch64. 2016-07-03 08:35:26 -10:00
Brian Smith
c84e4118f8 Fix formatting in the description of disable_dev_urandom_fallback. 2016-07-03 08:35:26 -10:00
Brian Smith
abfb6c9470 Require the rsa_signing feature for RSA signing. 2016-07-03 08:35:25 -10:00
Brian Smith
ecd9a5b307 Merge BoringSSL fdd8e9c: Switch perlasm calling convention. 2016-06-30 16:55:00 -10:00
Brian Smith
4f56f1b320 Refactor ECDH private keygen to be constant time & heap-free.
Avoid using the heap during private key generation. Use constant time
comparisons when verifying that the private key is in range. Move the
logic that doesn't need to be constant-time to Rust, leaving only the
constant-time comparisons in C. Adjust the rest of the internal
private key stuff to take into account these changes.
2016-06-30 15:26:40 -10:00
Brian Smith
614353c46e Implement ECDH agreement in Rust.
This unfortunately required a lot of refactoring. The inversion mod q
is now implemented with using a constant-time algorithm, unlike before,
but the point multiplications themselves are still using variable-time
implementations on most platforms, like before.

Note that the inversion algorithm is constant-time, but the primitive
operations that it is comprised of might not be fully constant-time
(yet).
2016-06-30 15:26:39 -10:00
Brian Smith
9bfb6d3cff Add new constant-time utilities for field elements & scalars.
The changes to crypto/internal.h and crypto/constant_time_test.c were
copied from the analogous tests for the |unsigned int| variants from
BoringSSL.
2016-06-30 15:26:37 -10:00
Brian Smith
e34adcc092 Implement ECDSA verification in Rust; use Gregory Maxwell's trick.
The twin multiplication is still done using the existing point
multiplication code.
2016-06-28 20:12:26 -10:00
Brian Smith
e1c436dcc1 Define P-256 and P-384 field multiplication & squaring functions. 2016-06-24 13:20:47 -10:00
Brian Smith
35d5a43f1b Remove unused RSA key generation code.
Also remove BIGNUM code that's no longer used after removing RSA
keygen.

Note in particular that `BN_mod_word` has a bug in it. There is a patch
in OpenSSL and BoringSSL; see BoringSSL
67cb49d045f04973ddba0f92fe8a8ad483c7da89 and OpenSSL
e82fd1b4574c8908b2c3bb68e1237f057a981820 and OpenSSL
e4c4b2766bb97b34ea3479252276ab7c66311809. The BoringSSL/OpenSSL fixes
don't look 100% right to me, because the callers of `BN_mod_word` don't
appear to be checking for the `(BN_ULONG)-1` error return value
correctly.
2016-06-22 18:07:11 -10:00
Brian Smith
7f4f5d16e0 Add GCC 6 to Travis CI. 2016-06-15 09:19:57 -10:00
Brian Smith
a35bc63840 Revert "Attempt to fix libstd/rustc version mismatch on Travis CI."
This reverts commit 1bee3b5534620f52c3f20f54c988d674e3d1f7ee, which
only made things worse.
2016-06-02 08:39:50 -10:00
Brian Smith
d0d0f7ebda Revert "Another attempt at fixing Nightly builds on Travis CI."
This reverts commit b7cbb00eb0d34d79120fa239e86c3bfaca35ff58, as it
didn't fix anything and probably made things worse.
2016-06-02 08:39:50 -10:00
Brian Smith
b7cbb00eb0 Another attempt at fixing Nightly builds on Travis CI. 2016-06-02 08:21:24 -10:00
Brian Smith
1bee3b5534 Attempt to fix libstd/rustc version mismatch on Travis CI. 2016-06-02 08:09:13 -10:00
Brian Smith
7ff5a71b3d Revert "Validate ECC public key points in Rust."
This reverts commit 2bc643bd3b57228e023f311848d8453021dec1bb. It
turns out that bn_mul_mont doesn't work like I expected on one
platform.
2016-06-02 01:33:18 -10:00
Brian Smith
b6331570d0 Disable Clang builds on Travis CI.
The LLVM project has disabled the APT servers that are used to source
clang, so clang builds won't succeed.
2016-06-02 00:54:32 -10:00
Brian Smith
2bc643bd3b Validate ECC public key points in Rust. 2016-05-31 11:21:29 -10:00
Brian Smith
56c3103c58 Remove nistp256 implementation.
The upcoming refactoring of the ECDSA signature verification involves
always using Montgomery-encoded field elements, but nistp256 doesn't
use Montgomery encoding.
2016-05-31 11:19:30 -10:00
Brian Smith
b7fc6162fc Refactor ring::ec and ring::agreement.
Split P-256 and P-384 stuff into its own submodule of `ring::ec` in
preparation for implementing more of the logic for those curves in
Rust. Use the name "Suite B" instead of "NIST" to be more precise.
Move some of the non-ECC-specific key agreement logic into
`ring::agreement.
2016-05-31 11:19:20 -10:00
Brian Smith
1f020f30a3 Add and remove some comments about the build configuration. 2016-05-29 18:26:12 -10:00
Brian Smith
31780f4713 Remove now-unused crypto/test_util.{cc, h}. 2016-05-29 10:52:04 -10:00
Brian Smith
0e8c77a2b8 Remove support for building with VS2013; VS2015+ is now required. 2016-05-29 10:52:03 -10:00
Brian Smith
dcdf473828 Use assembly language implementations of Poly1305. 2016-05-26 19:48:01 -10:00
Pietro Monteiro
f185fe5936 Set CFLAGS, CXXFLAGS and perlasm FLAVOUR when building for iOS.
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-05-25 13:44:40 -10:00
Brian Smith
556ea4e7b2 Remove C RSA signing, encryption, and padding code. 2016-05-24 21:09:31 -10:00
Brian Smith
a4732f81da Parse NIST ECC public keys using ring::input. 2016-05-24 12:44:41 -10:00
Brian Smith
f816427ede Remove crypto/bytestring and remaining users. 2016-05-24 10:56:52 -10:00
Brian Smith
abf9bd8605 Remove crypto/rsa/rsa_asn1.c and crypto/rsa/rsa_test.cc. 2016-05-24 07:17:49 -10:00
Brian Smith
c9a0ffb6c6 Do the ASN.1 parsing of ECDSA signatures using ring::der. 2016-05-23 18:05:27 -10:00
Brian Smith
8ee7b80a8c Remove old ECDSA signing code, as well as EC_KEY.
The ECDSA signing logic will get redone, and when it is redone it
won't depend on `EC_KEY`. The ECDH code already was redone to avoid
`EC_KEY`.
2016-05-23 17:27:31 -10:00
Brian Smith
b779a0e1ab Remove crypto/ec/ecdsa_test.cc.
New ECDSA verification tests were added to `ring::ec::ecdsa`, and
ECDSA signing isn't exposed as part of the API, so it is OK to
remove the bad testing that is done here.

In particular, note that ecdsa_test cannot find a problem in the ECC
math that would cause both the signer and verifier to compute the same
(wrong) answer, since the signature generation and signature
verification use the same math routines.
2016-05-23 17:04:46 -10:00
Brian Smith
880b89760d Rework the API and implementation of ECDH.
Instead of having `ring::agreement::EphemeralKeyPair`, we now have
`ring::agreement::EphemeralPrivateKey`, which doesn't store the public
key. This is slightly more memory-efficient because in real-world
protocols we don't need to do anything with the public key except send
it to the peer.

The interface between the Rust and C code was changed with an eye
towards making it easy to add X25519 support. New, simpler, C code
implementing ECDH (for NIST curves) replaces the old code in
crypto/ecdh. In particular, now `EC_KEY` isn't used at all for ECDH.

Finally, add the test vectors for ECDH P-256 and P-384 from the NIST
website. These test vectors don't test the most interesting cases,
however.
2016-05-23 11:20:43 -10:00
Pietro Monteiro
72616bbf05 Build and test on ARM Android.
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-05-19 17:11:32 -10:00
Brian Smith
0462247918 Use getrandom on Linux when available. 2016-05-19 08:58:02 -10:00
Pietro Monteiro
d731947332 Correctly set TARGET variables when building for Android.
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-05-12 15:47:41 -10:00
Pietro Monteiro
37892c5258 Improve ARM configuration on Travis CI.
Use ubuntu's gcc packages for 32 and 64-bit ARM. Use hard-float on
32-bit ARM. Use travis_wait on slow arm tests.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-05-12 15:46:00 -10:00
Brian Smith
a7ddc0154a Fix typo in mk/appveyor.bat. 2016-05-10 11:24:55 -10:00
Brian Smith
4421e7c552 Reduce tested versions of GCC and Clang.
Travis CI runs just take way too long with this huge matrix, so prune
it to something more manageable.
2016-05-06 17:17:58 -10:00
Brian Smith
63b10be8e3 Eliminate duplication of QEMU install on Travis CI. 2016-05-06 17:11:30 -10:00
Pietro Monteiro
1a1f458e3b Cache kcov after installing it to speed up coverage builds. 2016-05-06 16:51:00 -10:00
Pietro Monteiro
f59aa7d7a9 Use Ubuntu Trusty to run ARM tests on backported QEMU 2.5. 2016-05-06 16:46:33 -10:00
Brian Smith
d9a765bf04 Generate debug information for asm code on non-Windows platforms too.
Debug info is already generated for asm code on Windows
by psasing `--dformat=cv8` to yasm. Do similar on other platforms.
Hopefully this will improve code coverage analysis of the asm code.
2016-04-29 14:28:07 -10:00
Brian Smith
c447603837 Run cargo test earlier in CI builds. 2016-04-29 10:54:28 -10:00