73 Commits

Author SHA1 Message Date
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
Alessandro Ghedini
016a5d54f8 Add ChaCha20 support to QUIC header protection
This requires the addition of a constructor for aead::nonce::Iv from
an aead::block::Block.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2019-01-05 09:07:20 -10:00
Alessandro Ghedini
351ed16251 Implement QUIC header protection API
This adds a new API to the AEAD module for generating QUIC Header Protection
masks, as described in draft-ietf-quic-tls-17.

Only AES support is currently implemented, but ChaCha20 can be added later.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2019-01-04 17:42:59 -10:00
Brian Smith
5a0b6b5dec Add type-safe Aad wrapper for AEAD operations.
Reduce the possibility of confusing the AAD parameter with the
ciphertext/plaintext parameter.
2018-12-29 14:37:21 -10:00
Brian Smith
5997093fb0 Implement signature::KeyPair for RSA. 2018-12-21 15:39:26 -10:00
Brian Smith
d81973cf4c Define a signature::KeyPair trait and implement it for Ed25519. 2018-12-21 15:30:47 -10:00
Brian Smith
faaef278dc Move der under IO. 2018-12-21 15:22:30 -10:00
Brian Smith
6609177e63 Rename RSA* to Rsa*. 2018-12-21 15:21:50 -10:00
Brian Smith
b0f8ca2532 Rename ECDSAKeyPair to EcdsaKeyPair. 2018-12-21 15:21:50 -10:00
Brian Smith
0c407e4c31 Remove failed attempt at a generic public key signing API. 2018-12-21 15:21:50 -10:00
Brian Smith
be3f13aeef Better encapsulate ECC key parts. 2018-12-21 12:22:42 -10:00
Brian Smith
c8b76df6e5 Use Nonce as the type of the nonce input in AEAD. 2018-12-14 11:39:34 -10:00
Brian Smith
e79ab7b532 Factor out invariant test in AEAD test. 2018-12-14 11:39:34 -10:00
Brian Smith
8f4ecf8e1d Make PKCS#8 generation of Ed25519 keys use pkcs8::Document. 2018-12-14 11:39:34 -10:00
Brian Smith
69e1ad202a Remove RSASigningState. 2018-12-12 20:09:46 -10:00
Brian Smith
67425b7463 Enable RSA signign by default; remove rsa_signing feature. 2018-12-12 20:09:46 -10:00
Brian Smith
ce77943017 Add a TryFrom polyfill and use it for slice -> array conversions. 2018-12-10 08:56:33 -10:00
Brian Smith
2843931bb7 Switch to Rust 2018 Edition.
Switch to Rust 2018 Edition. Fix up some build breakage for different
configurations that were found in the process of testing this,
particularly `--no-default-features`.
2018-12-08 21:39:17 -10:00
Brian Smith
ec2a92a4ae Clean up imports in ed25519_tests.rs. 2018-12-08 21:39:17 -10:00
Brian Smith
948846061e cargo fix --edition && cargo +nightly fmt. 2018-12-08 21:39:17 -10:00
Brian Smith
86f6e7722d Add basic tests for chacha20_poly1305_openssh. 2018-12-08 13:10:25 -10:00
Brian Smith
66a2711601 Use NonZeroU32 in pbkdf2. 2018-12-06 11:25:10 -10:00
Brian Smith
a5e5df273c Add more RSA key length tests. 2018-11-28 12:34:39 -10:00
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