5106 Commits

Author SHA1 Message Date
Brian Smith
f72ca3a422 Remove redundant copy of iqmp in RSA private keys. 2016-11-28 09:15:54 -10:00
Brian Smith
dbdbf8a287 Rename PRIVATE_KEY_PUBLIC_MODULUS_{MAX_BITS, MAX_LIMBS}. 2016-11-28 09:13:00 -10:00
Brian Smith
28f7e26612 Allow construction of BitLengths in constant expressions. 2016-11-28 09:12:58 -10:00
Brian Smith
abb3fdfc08 Fix --no-default-features build. 2016-11-23 15:07:17 -10:00
Brian Smith
5ef36f972f Note that test::rand::FixedSliceSequenceRandom isn't thread-safe. 2016-11-23 14:17:32 -10:00
Brian Smith
2539beac02 Simplify implementations of test::rand::*Random. 2016-11-23 14:11:29 -10:00
Brian Smith
2a180893ae Expose deterministic SecureRandoms in ring::test::rand. 2016-11-23 14:06:12 -10:00
Brian Smith
5a96fa8bb3 Factor out RSA padding message digest computation.
Instead of every padding verification implementation and every padding
encoding implementation doing the digesting, have `sign()` and
`verify()` to it themselves.
2016-11-23 11:38:24 -10:00
Brian Smith
a38d9a4ef9 Verify RSA PKCS#1 1.5 signatures by encode-then-check.
When we first implemented PKCS#1 1.5 signature verification we had not
implemented signature generation, so we implemented verification by
parsing the padding. Now that we have generation we can save some code
and arguably make verification safer. Also, this is the way RFC 3447
recommends to do it.
2016-11-23 09:01:36 -10:00
Brian Smith
dcba8a845f Fix definition of c::long for 64-bit non-Windows platforms. 2016-11-23 06:14:31 -10:00
David Judd
f014d94af6 RSA blinding param generation refactoring & performance improvements
Oxidize/restore special-case handling for `0b100...` range bounds,
lost when OpenSSL code was oxidized, and move RSA blinding param
generation out of limb.rs and into its own module.

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

[The code was reordered and slightly tweaked by me before it was
commited. - Brian]
2016-11-22 17:07:12 -10:00
Brian Smith
5c4627a849 Add c::long. 2016-11-22 15:44:06 -10:00
Brian Smith
1f0135d80b Use Rust 1.13 for stable builds on AppVeyor.
Rust 1.13 is the minimum supported version.
2016-11-21 14:41:26 -10:00
Brian Smith
21b0ad94b6 Fix --no-default-features build. 2016-11-18 15:55:20 -10:00
Brian Smith
ba3de7c7d3 Pass lengths as a single full block in ChaCha20-Poly1305 AEAD. 2016-11-16 11:21:34 -10:00
Brian Smith
634caf42fa Use polyfill::u64_from_usize in ring::digest. 2016-11-16 11:21:13 -10:00
Brian Smith
f9de08c6f2 Move the alignment comment in ring::digest to the type. 2016-11-15 15:35:50 -10:00
Brian Smith
14b1c56b55 0.6.0-alpha. 2016-11-15 12:12:06 -10:00
Brian Smith
f0f9b00e1a Expose RSAEncoding in the public API.
Expose `RSAEncoding` in the public API so that users of *ring* can use
it in type signatures. Add an "RSA" prefix to the exported types, since
they will be exported from `ring::signature`. Modify RSA tests to use
only the public API so as to ensure that enough of the API is public.
2016-11-15 12:02:42 -10:00
Brian Smith
5fb1fc8a5e Add and use PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN.
`PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN` is measured in bytes, whereas
`PUBLIC_MODULUS_MAX_LEN` was measured in bits.
2016-11-15 10:43:31 -10:00
Brian Smith
be08baa959 Add BitLength type and use it in RSA padding.
Besides improving type safety generally, this fixes a bug in RSA PSS
signing where the wrong value of `mod_bits` was being passed to
`Encoding::encode()`.
2016-11-15 10:43:30 -10:00
Brian Smith
4c9a9c8751 Refactor PSS encoding. 2016-11-15 10:43:29 -10:00
Brian Smith
eeb99a780e Factor out common metric calculations in PSS padding. 2016-11-15 10:43:27 -10:00
Brian Smith
18ff68f90c Factor out shared digesting logic in PSS padding. 2016-11-15 10:41:18 -10:00
Brian Smith
5be8b7f960 Fix (mod_bits - 1) % 8 == 0 case for PSS encoding.
fix encoding
2016-11-15 10:41:16 -10:00
Sam Scott
2e9ef69c23 Implement RSA-PSS signing.
-  Refactor Encoding trait to be randomised.
 -  Add RSA-PSS signing test cases.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-11-15 10:39:48 -10:00
Brian Smith
8cb3673417 Factor out common logic in internal RSA padding interface.
Factor out the duplicate checks that `m` is fully consumed.
2016-11-15 10:39:34 -10:00
Brian Smith
ba8199b175 Expand RSA PKCS#1 1.5 signature documentation. 2016-11-15 10:39:33 -10:00
Brian Smith
0ce0643f95 Expand documentation for RSA-PSS signatures. 2016-11-15 10:39:32 -10:00
Brian Smith
7520d283eb Fix (mod_bits - 1) % == 0 case in RSA PSS verification.
Output the extra leading zero byte when necessary.

Rename parameters in the `Encoding` interface to match the
specification and update the implementations to use the updated
variable names.
2016-11-15 10:39:32 -10:00
Sam Scott
4e5145157c Implement RSA-PSS verification.
-  Add tests for RSA-PSS verification from NIST test cases.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-11-15 10:39:28 -10:00
Brian Smith
8acfc1d733 Annotate crypto/ec/*.inl and include/openssl/*.h files as C files. 2016-11-14 19:46:11 -10:00
Brian Smith
9a29275a6d Remove unused FileTest methods. 2016-11-14 19:05:19 -10:00
Brian Smith
b1afa746d2 Sort modules in lib.rs. 2016-11-14 12:58:48 -10:00
Brian Smith
7198caac92 Move definition of BIGNUM. 2016-11-14 12:54:34 -10:00
Brian Smith
78b63ae525 Correct minor issues in the ECDSA documentation. 2016-11-13 19:06:39 -10:00
Brian Smith
f14ca175a8 Simplify ring::init::init_once() using statement-level #[cfg()].
Statement-level `#[cfg()]` is newly stable in Rust 1.13.
2016-11-12 14:00:29 -10:00
Brian Smith
3890c4aaf3 Use the new assert_ne!() and debug_assert_ne!(). 2016-11-12 14:00:21 -10:00
Brian Smith
424d276014 Make PositiveInteger::into_raw() safer.
At the time the code was written, I didn't know `mut self` was an
option.

With the new move semanticsfor `into_raw()`, more of the complexity of
the pointer handling can be removed as there's no potential for any
null dereference.
2016-11-12 12:52:05 -10:00
Brian Smith
7ca6c31d77 Implement Drop directly on the private RSA structure.
With Rust 1.13 it is now OK to implement `Drop` on `extern "C"`
types, since drop flags were dropped.
2016-11-12 12:04:32 -10:00
Brian Smith
03af755b70 Deny unused_unsafe now that Rust 1.13 is released.
This lint had to be disabled due to differing views of how `unsafe` is
to be used for `extern "C"` variables between Rust 1.13 and earlier
versions. Now Rust 1.13 is the oldest supported version so all
supported versions agree.
2016-11-12 11:43:21 -10:00
Brian Smith
d438afc2b3 Use correct script name in convert_nist_rsa_test_vectors.py. 2016-11-12 11:43:21 -10:00
Brian Smith
4dc2a59153 Zero the plaintext when AEAD tag validation fails, not data after. 2016-11-10 08:47:07 -10:00
Brian Smith
03ce40dcb9 Add SHA-384 digest of input file to NIST RSA test vectors. 2016-11-09 16:04:40 -10:00
Brian Smith
1045c8f89a Regenerate NIST RSA PKCS#1 1.5 test vectors with updated conversion script.
There are no semantic changes, just minor formatting changes. The "NIST
test vectors are bad and we should feel bad"-type comments seem to apply
to all the NIST test vectors for all algorithms so it's not useful to
have that note (just) in this file.
2016-11-09 15:54:20 -10:00
Brian Smith
563c2c3be5 Tweak convert_nist_rsa_test_vectors.py.
These were changes identified during code review.
2016-11-09 15:54:03 -10:00
Sam Scott
bbbb2fe172 Update python script to reformat NIST RSA signature tests.
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-11-09 12:07:18 -10:00
Brian Smith
17d533863c Match algorithm names in PKCS#1 tests the way upcoming PSS tests do. 2016-11-09 12:07:17 -10:00
Brian Smith
ec9bbdb4c0 Stop skipping some RSA signing tests on ARM Android.
This workaround for slow test runs is no longer necessary and didn't
seem to work all the time anyway.
2016-11-09 11:46:45 -10:00
Brian Smith
c190392f17 Put NIST test vector conversion script in src/rsa. 2016-11-09 11:46:13 -10:00