87 Commits

Author SHA1 Message Date
Brian Smith
cfe46261e8 Remove untrusted from the ring::signature signing API. 2019-04-05 16:21:41 -10:00
Brian Smith
306d163613 Refactor ring::signature verification API.
Introduce `UnparsedPublicKey`. Remove public use of `untrusted::Input`.
Replace `signature::verify()` with `UnparsedPublicKey::verify()`.
2019-04-05 16:21:40 -10:00
Brian Smith
998229f1e9 Rename RsaPublicKey to RsaSubjectPublicKey`.
We'll probably use the name `RsaPublicKey` for something else.
2019-04-05 16:01:31 -10:00
Brian Smith
c40df473cb Update to latest untrusted prerelease. 2019-04-05 09:45:53 -10:00
Brian Smith
9f80946c13 Merge hmac::{SigningKey, VerificationKey} as hmac::Key. 2019-04-04 14:40:33 -10:00
Brian Smith
c125b2b4b1 Stop renaming symbols when publicly exporting them.
Rust tooling (rustdoc, and rustc error reporting) doesn't handle very well
the renaming of a symbol when exporting it.
2019-04-04 13:20:48 -10:00
Brian Smith
5baeb39aba HKDF: Make API safer.
Reduce the likelihood that `info` and `out` parameters would get confused.
Eliminate potential to panic in the new API.
2019-03-29 14:57:48 -10:00
Brian Smith
f1d85e614b HKDF: Avoid an unnecessary loop iteration.
When `out` is the same length as the digest output an extra iteration
of HMAC was executed and then thrown away. Avoid that extra iteration.

Note that an extra iteration is still done in the degenerate case where
`out` is empty, because it's better to optimize for the case where `out`
isn't empty.

The output is exactly the same as before.
2019-03-29 14:31:32 -10:00
Brian Smith
6ec8f34c57 HKDF: Make extract and expand methods. 2019-03-29 14:31:11 -10:00
Brian Smith
9addfcebdf Use distinct types for HKDF Salt and Prk. 2019-03-28 18:01:19 -10:00
Brian Smith
d712f6493b Avoid unnecessarily-named explicit lifetime parameters. 2019-03-06 14:04:39 -10:00
Andy Russell
c51221d329 convert doc comment to regular comment 2019-02-20 03:57:05 -10:00
Brian Smith
ab0726d0cd Embed test data into test executables.
Embed test data files into test executables so that file I/O isn't
necessary during tests. This allows the tests to run on platforms that
don't have file I/O. It also makes it easier to run the tests on a
separate (virtual) machine from the build machine since the test
automation no longer needs to keep track of the test files.
2019-02-02 13:21:02 -10:00
Brian Smith
abbb616b57 Implement Debug for OpeningKey and SealingKey. 2019-01-23 16:40:16 -10:00
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