4924 Commits

Author SHA1 Message Date
Brian Smith
279bd0a2e9 Reformat based on suggestions from rustfmt.
This is a first step toward fully-automated formatting. A custom format
is used, primarily to tell rustfmt to wrap at column 80(-ish) instead of
column 100(-ish), and to use more compact styles.

Many rustfmt suggestions for rewrapping function calls were ignored
because they did not result in the minimum number of lines and/or
because I'm still unsure the best way to format a long chain. Some
suggestions for reformatting macros were ignored because they ruined
the indention. Some other suggestions were ignored because they seemed
like bugs and/or seemed to make things clearly worse.

Further work is planned, in order to make the formatting fully
automatic.
2016-08-28 17:32:32 -10:00
Sam Scott
f5be9c34b1 Replace ChaCha20 tests with Rust code.
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-08-27 11:55:02 -10:00
Brian Smith
5b75fb123f Refactor RSA signing API to allow concurrent use of RSAKeyPair. 2016-08-27 10:50:49 -10:00
Brian Smith
d478370db3 Remove unnecssary boxing of RSA within RSAKeyPair. 2016-08-27 10:47:01 -10:00
Brian Smith
bf6ccac2db Split RSA verification- & signing- specific code into submodules. 2016-08-27 10:47:01 -10:00
Brian Smith
5212701f46 Fix build breakage with Rust Nightly.
`drop_with_repr_extern` was removed when Drop flags were removed.
2016-08-26 23:15:24 -10:00
Andre Bogus
89ab6d265c Simplify test code by using while let.
Found by Clippy.
2016-08-25 18:44:59 -10:00
Andre Bogus
3db3bf48e9 Use compound assignment operator when possible.
Found by Clippy.
2016-08-25 18:44:59 -10:00
Andre Bogus
789cb41bfa Use characters instead of strings for single-character comparisons.
Found by Clippy.
2016-08-25 18:44:58 -10:00
Andre Bogus
c260b3599f Avoid explicit specificiation of lifetimes unless necessary.
These were found by Clippy.
2016-08-25 18:44:58 -10:00
Andre Bogus
80b72639c7 use x.is_empty() instead of x.len() == 0. 2016-08-25 18:44:57 -10:00
Andre Bogus
26e73097fc Use implicit return instead of explicit return. 2016-08-25 18:44:53 -10:00
Andre Bogus
9b042331f4 Add backticks in doc comments to appease Clippy. 2016-08-25 18:44:44 -10:00
Brian Smith
48bb3edca4 Remove else after return. 2016-08-25 18:44:44 -10:00
Brian Smith
19d0d794b4 Drop mention of function name in SHA512_4 documentation.
Clippy complains about this unless "SHA512_4" is enclosed in backticks.
2016-08-25 18:44:43 -10:00
Andre Bogus
57505cd4b9 Remove unnecessary uses of & on references.
Found by Clippy.
2016-08-25 18:44:38 -10:00
pravic
a6aa30189a Fix strawberryperl link in BUILDING.md. 2016-08-24 09:50:17 -10:00
Brian Smith
b9962664ea Remove AES decryption.
AES-GCM only uses the encrypt function, even for decryption.
2016-08-24 01:40:38 -10:00
Brian Smith
6a002726e2 Remove unused crypto/bn internals. 2016-08-24 01:40:37 -10:00
Brian Smith
8e36a585d0 Fix some spelling mistakes in comments. 2016-08-24 01:40:37 -10:00
Brian Smith
e10b057679 Rust 1.11.0 or later is required; bump leftmost version number.
Rust 1.11.0 is required since some tests are using the form of
`assert!` that takes a custom error message, which is new in Rust
1.11.0.

Also fix includes in Cargo.toml. Also remove pregenerated/*, which
don't need to be in version control, but which can't be in .gitignore
(if they are, then `cargo package` and `cargo publish` don't work).
2016-08-24 00:38:29 -10:00
Brian Smith
a3543b968d X25519: Check peer public key length.
The X25519 code was assuming the ring::agreement code was doing it. The
ring::agreement code assumed the X25519 code was doing it.

Without this, if the peer's public key is too short, there would be an
out-of-bounds read.
2016-08-24 00:32:24 -10:00
Brian Smith
baae7b50b0 Use Rust 1.11.0 on Appveyor.
This is required because we're using the `assert!` syntax that allows
custom error messages, and that wasn't stable in previous versions.
2016-08-23 17:46:02 -10:00
Brian Smith
85609e29e9 Remove BN_CTX. 2016-08-23 13:25:14 -10:00
Brian Smith
54beddbcbd Remove BN_CTX from BN_mod_exp_mont_vartime & its callers. 2016-08-23 13:25:13 -10:00
Brian Smith
8d382c263a Remove BN_CTX from everything but BN_mod_exp_mont_vartime & its callers. 2016-08-22 10:55:43 -10:00
Brian Smith
43cb96508a Remove BN_CTX usage from BN_from_montgomery; rename to BN_from_mont. 2016-08-22 10:52:55 -10:00
Brian Smith
0984e094fe Replace BN_mul with BN_mul_no_alias, which doesn't require BN_CTX. 2016-08-22 10:52:54 -10:00
Brian Smith
1ab61fa874 Stop using BN_CTX in BN_{mod_inverse_odd, div, nnmod, MONT_CTX_set}. 2016-08-22 10:52:54 -10:00
Brian Smith
30b4b5bb9f Add back prototype of BN_rand to bn_test_lib.h. 2016-08-22 10:33:00 -10:00
Brian Smith
3b9031181f Remove prototypes of already-removed functions. 2016-08-22 10:12:08 -10:00
Brian Smith
1206420d94 Fix typo in bn.h comment. 2016-08-22 10:11:51 -10:00
Brian Smith
9cf1e168e7 Replace scalar_is_in_range with direct use of Range. 2016-08-22 10:08:32 -10:00
Brian Smith
1bc7c7fcfd Adapt the ECDH key generation tests to test Range::sample_into_limbs. 2016-08-22 10:02:05 -10:00
Brian Smith
36a91ba649 Expand Range::are_limbs_within tests. 2016-08-22 10:01:44 -10:00
Brian Smith
bb520362ca Simplify conversions from masks => bool => Err to masks => Err. 2016-08-22 10:01:42 -10:00
Brian Smith
01fea0f4a3 Expand and clarify comments regarding origin of sample_into_limbs. 2016-08-22 10:01:42 -10:00
Brian Smith
ee97b4309e Factor out most-significant-limb masking and test it. 2016-08-22 10:01:41 -10:00
Brian Smith
d25ceb61a5 Make RAND_bytes test-only.
It is only used in the tests, and it is one of the things that
creates linkage conflicts when people try to link OpenSSL forks with
*ring*.
2016-08-22 10:01:41 -10:00
David Judd
f96d6403ec Make BN_rand test-only.
It was already only used in tests, so only compile it in tests,
and remove now-unused modes.

I agree to license my contributions to each file under the terms
given at the top of each file I changed.
2016-08-22 10:01:40 -10:00
Brian Smith
0a8efedb51 Use Limb::max_value() instead of defining MAX_LIMB. 2016-08-22 10:01:39 -10:00
Brian Smith
ef7a07cdf3 Describe limb ordering in just one place. 2016-08-22 10:01:39 -10:00
David Judd
7cbe5d76fb Replace BN_rand_range C implementation with call to Rust.
The random key generation code is adapted from that used for EC,
but temporarily duplicated, with the following changes:
- A Range struct wrapping Limb slices used as ranges
- Instead of converting bytes to limbs, generate random bytes directly
  into the Limb slice, temporarily casting it to u8
- Add support for ranges with zero bits in the most significant limb
  by masking those bits in the generated random bytes

Also remove the `min_inclusive` parameter from BN_rand_range_ex,
since in practice it is always 1.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-08-22 10:01:38 -10:00
Brian Smith
7d7ac56929 Remove pub from extern declarations in src/rand.rs. 2016-08-21 11:15:02 -10:00
Peter Reid
e7cd8ee766 Fix HKDF test; it was not comparing actual to expected output.
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-08-18 12:25:37 -10:00
Brian Smith
c56690d356 Fix indention of Fn/FnOnce/FnMut where clauses. 2016-08-18 12:19:57 -10:00
Brian Smith
a7b02de2dc Avoid storing unused/redundant copies of {n, p, q} in RSA.
|d| is only used in rsa_check_key. |n|, |p|, and |q| are already stored
in |mont_n|, |mont_p|, |mont_q|.
2016-08-18 12:19:57 -10:00
Brian Smith
82b40be68d Require non-NULL BN_MONT_CTX for |BN_mod_exp_mont_consttime|.
Since |BN_MONT_CTX_set| is not protected against side channels,
encourage callers to call it explicitly, once, and reuse the
|BN_MONT_CTX|, instead of relying on |BN_mod_exp_mont_consttime|
to recreate it each time. All the existing callers already passed a
non-NULL |BN_MONT_CTX_set|, so this is just deleting dead (test-only)
code.
2016-08-17 18:19:04 -10:00
Brian Smith
c2ee5d3a52 Remove unused constant_time_lt_size_t.
The code that used it was rewritten a while ago.
2016-08-17 15:04:22 -10:00
Brian Smith
cef7e4cf7a Remove ring::digest::Algorithm::nid.
This is a leftover thing from when `ring::digest` was primarily written
in terms of the OpenSSL digest API.
2016-08-17 15:02:16 -10:00