199 Commits

Author SHA1 Message Date
Brian Smith
97d5877fbf Report unsupported RSA private key length at during key construction.
Previously, one could construct an RSA key pair "successfully" even if
the bit length of the private moduli was not evenly divisible by 512.
However, using such a key to sign something would (usually) fail on
x86-64 because the x86-64 signing code requires the modulus to be an
even multiple of 8 limbs.

Now, all keys that have private primes with lengths that aren't
multiples of 512 bits will be rejected at key construction time with
error "PrivateModulusLenNotMultipleOf512Bits".
2018-11-28 11:52:18 -10:00
Brian Smith
9968baa55d Report some details of why asymmetric keys were rejected. 2018-11-28 11:52:18 -10:00
Brian Smith
d42f9d5e21 Fix test cases in PKCS#8.
The test case was accidentally a duplicate of the one that follows it.
Fix it so that it is badly encoded in the way described in the comment.
2018-11-28 11:22:37 -10:00
Brian Smith
cb05b24123 cargo +nightly fmt.
This reformats tests/aead_tests.rs, which was accidentally omited in
the last reformatting.
2018-11-27 14:34:54 -10:00
Brian Smith
2f3c163f1e cargo +nightly fmt.
This reformats the rest of the code that hadn't been reformatted yet.
2018-11-26 19:11:42 -10:00
Brian Smith
6e98bf0568 Reformat tests/, except AEAD tests.
AEAD tests will be reformatted later.
2018-11-15 16:17:49 -10:00
Brian Smith
d249aa57a0 Make ECDSA signing known-answer tests internal unit tests.
In the near future these tests will use an internal interface that
won't be available from outside the crate.
2018-06-11 14:03:10 -10:00
Brian Smith
3220b58eee Simplify RSA test and fix the build. 2018-06-04 16:51:24 -10:00
Brian Smith
e5a4fe96f7 Initial ECDSA signing implementation.
Nonce reuse hardening and more tests will be added later.
2018-05-31 08:18:58 -10:00
Brian Smith
6ac5b5254f Implement Debug for RSAKeyPair. 2018-05-28 12:36:07 -10:00
brycx
f19e6e7fc4 Add PBKDF2-HMAC-SHA256 test vectors from RFC 7914 2018-05-21 08:15:10 -10:00
Brian Smith
2776bc7094 Don't impl Clone for RSAKeyPair yet.
I want to explore some new RSA functionality that might make `Clone`
difficult to implement, so I'm going to revert this change before
people start depending on it.
2018-05-15 08:43:41 -10:00
Brian Smith
a2694ea765 Temporarily stop checking whether p and q are too close in RSA.
Remove one use of `bit_length()` which will require non-trivial work to
replace.

This probably also improves compatibility to some extent since I doubt
many crypto libraries ensure that `p` and `q` are far enough apart
according to NIST's requirements.
2018-05-09 13:53:39 -10:00
Brian Smith
2b06760de8 Implement Clone for RSAKeyPair. 2018-05-07 14:04:50 -10:00
Gavin Li
c95e96bb48 Add support for keys where p < q
Support them by swapping (p, dP) and (q, dQ) and recalculating qInv
ourselves. Added a few test vectors for |p < q|
parsing/signing/verification.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2018-05-04 08:57:38 -10:00
Brian Smith
d42b765cb1 Rename third-party/ to third_party/.
Be consistent with BoringSSL.
2018-04-30 13:31:35 -10:00
Brian Smith
b4640165d9 Merge BoringSSL 7e9949c: Import additional test vectors from RFC 8032. 2017-12-29 12:02:42 -10:00
Brian Smith
a9fabeb5f2 Improve RSAKeyPair and RSASigningState Send/Sync test.
Use the new utility functions in `ring::test` instead of the previous
hacky way.
2017-12-27 18:13:39 -10:00
Brian Smith
7a6f3c8ddd Derive Copy and Clone for ring::signature::Signature.
Derive `Copy` and `Clone` for `Signature`.

Add some utilities for testing `Clone`, `Copy`, `Send`, and `Sync`
and use them to test that `Signature` implements these traits.
2017-12-27 15:53:35 -10:00
Brian Smith
72f5e2ebf0 Avoid trying to disable removed fat_ptr_transmutes antifeature.
The antifeature was removed from rustc in 2014, according to a new warning,
so this was doing nothing.
2017-12-24 09:50:10 -10:00
Brian Smith
7b7d562e76 Be stricter with lints in the rest of tests/*.rs. 2017-08-27 12:31:17 -10:00
Brian Smith
118c634c2e Be stricter with lints in tests/agreement_tests.rs. 2017-08-27 12:31:01 -10:00
Brian Smith
270226b23f Do strict linting in tests/rsa_tests.rs. 2017-08-27 12:26:06 -10:00
Brian Smith
b73e2a248b Generalize PBKDF2 to work with any digest algorithm. 2017-06-09 17:47:35 -10:00
Brian Smith
dde61c2945 Add SHA-512/256. 2017-06-09 17:47:34 -10:00
Brian Smith
a04bdddf4d Move PBKDF2 functional tests to tests/. 2017-06-08 12:11:47 -10:00
Brian Smith
eb73404257 Move HMAC functional tests to tests/. 2017-06-08 12:01:35 -10:00
Brian Smith
5884ed3149 Move HKDF functional tests to tests/. 2017-06-08 12:01:34 -10:00
Brian Smith
c035ea67e1 Move iterated X25519 test to tests/agreement_tests.rs. 2017-06-08 12:01:33 -10:00
Brian Smith
f95cf64e57 Move agreement functional tests to tests/agreement_tests.rs.
Also remove ring::agreement::EphemeralKeyPair::from_test_vector().
2017-06-08 12:01:26 -10:00
Brian Smith
8dc0b9811c Move AEAD functional tests to tests/. 2017-06-08 10:41:05 -10:00
Brian Smith
c66da3e5bf Remove the dashes in Debug output for ring::digest types.
This will make the output for the upcoming SHA-512/256 more sensible.
2017-06-07 13:20:27 -10:00
Brian Smith
0cc5bde692 Add digest_ prefix to digest tests.
This makes them run with `cargo test digest`.
2017-06-07 13:20:23 -10:00
Brian Smith
eed6898211 Move digest functional tests to tests/. 2017-06-07 13:20:15 -10:00
Brian Smith
f66121467d Switch to ? syntax in ring::rsa. 2017-05-17 21:41:17 -10:00
Brian Smith
209329e059 Support ECPrivateKey with a parameters field in PKCS#8.
Don't generate them, but do accept them.
2017-05-17 10:05:25 -10:00
Brian Smith
eb3843e4dd Add PKCS#8 generation to ECDSAKeyPair. 2017-05-17 09:05:46 -10:00
Brian Smith
d7ee87e785 Add ring::signature::ECDSAKeyPair with PKCS#8 import. 2017-05-16 18:14:15 -10:00
Brian Smith
30093dd947 Convert RSA PKCS#8 tests to file tests. 2017-05-16 18:00:02 -10:00
Brian Smith
e52904256b Move RSA signing & verification functional tests to tests/. 2017-05-13 22:37:26 -10:00
Brian Smith
0124565a52 Move ECDSA integration/functional tests to tests/. 2017-05-13 00:34:45 -10:00
Brian Smith
93cdb56916 Rename tests/pkcs8_test.rs to tests/rsa_tests.rs. 2017-05-12 16:26:50 -10:00
Brian Smith
c78d5d9ef4 Add additional Ed25519 PKCS#8 tests. 2017-05-09 15:01:37 -10:00
Brian Smith
74c54980ea Add some PKCS#8 v2 Ed25519 private key test cases. 2017-05-07 13:30:42 -10:00
Brian Smith
0f60416266 Update Ed25519 PKCS#8 support to account for extra octet string.
The private key is wrapped in an extra octet string.
2017-05-07 11:42:22 -10:00
Brian Smith
eacd3b8fa0 Add Ed25519 PKCS#8 support. 2017-05-07 10:21:18 -10:00
Brian Smith
79207747a4 Replace Ed25519KeyPair::from_bytes() with from_seed_and_public_key(). 2017-05-07 09:28:28 -10:00
Brian Smith
f587947fd7 Convert Ed25519 tests to from unit tests to integration tests.
They are integration tests.
2017-05-07 09:23:58 -10:00
Brian Smith
e3581da4fe Add support for deserializing RSA keys from PKCS#8. 2017-04-30 11:52:45 -10:00