208 Commits

Author SHA1 Message Date
Brian Smith
edf5830cb2 NFC: Tests: Address clippy lint. 2023-10-01 21:36:43 -07:00
Brian Smith
a73bd052a7 Add regression test for Ed25519KeyPair::generate_pkcs8(). 2023-10-01 21:29:14 -07:00
Brian Smith
c9fd0ba48f NFC: Remove unneeded #cfg(...) in digest_tests.rs
The code is always enabled since "wasm32" was spelled wrongly. Apparently
the wasm-bindgen compatibility issue is no longer an issue.
2023-09-19 10:16:01 -07:00
Brian Smith
0a0c375b76 ci: Address Clippy 1.65 concerns. 2022-11-03 10:30:09 -07:00
Brian Smith
f4b51d78c6 Take BoringSSL 87f316d: Add note to HMAC test vectors from NIST. 2022-10-31 11:43:30 -07:00
Brian Smith
dc25ad9022 2021 Edition: Remove now-redundant imports. 2022-10-20 23:03:50 -07:00
Brian Smith
0f3bf0031a Add v2 test vectors. 2022-04-11 12:33:28 -07:00
Brian Smith
8dc1b93b24 Ed25519::{from_pkcs8, from_pkcs8_maybe_unchecked}: Also accept correct tagging public key.
See the added API documentation for more details.

Also update the test private key to the standard format.
2022-04-11 12:33:28 -07:00
Brian Smith
ff03b734f9 explicit bug test cases 2022-04-11 12:33:28 -07:00
Brian Smith
4c78629ed5 Ed25519::{from_pkcs8,from_pkcs8_maybe_unchecked}: Add test vectors for correct encoding.
These new tests have the wrong expected results because of the bug that will be fixed in the
next commit.
2022-04-11 12:33:28 -07:00
Brian Smith
2e148a4b9a Ed25519 PKCS#8 Testing: Update spec reference from draft to final RFC.
I verified the key value is the same in the draft and the final RFC.
2022-04-11 12:33:28 -07:00
Brian Smith
155231fb01 signature: Enable Ed25519 support for wasm32 targets.
Ed25519 was disabled for WebAssembly due to some unrelated issues with
getting the X25519 code working in WebAssembly. Temporarily remove the
`agreement` API when targetting WebAssembly to work around those issues
in a way that lets us enabled Ed25519.
2022-04-06 12:54:49 -07:00
Brian Smith
32b2c6c39e Ed25519 PKCS#8 testing: Pass all test vectors to both variants. 2022-02-20 19:48:19 -08:00
Brian Smith
d03059e81a Ed25519 PKCS#8 Testing: Verify that the resultant public key is correct. 2022-02-20 19:48:19 -08:00
Brian Smith
edc5916264 Ed25519 PKCS#8 Testing: Require explicit indication of success in test input.
Instead of assuming the call should be successful if there is no error, instead
require an explicit "Result = OK".
2022-02-20 19:48:19 -08:00
Brian Smith
b1d54a89b9 Ed25519 PKCS#8 testing: Factor out common logic in from_pkcs8 tests.
Prepare for improving both sets of tests.
2022-02-20 19:48:19 -08:00
Brian Smith
d97ae1fd08 wasm32: Make wasm32_c the default and only mode; remove the "wasm32_c" feature.
Always require a C compilare for wasm32, instead of trying to provide a subset
of the functionality.
2021-10-06 15:53:02 -07:00
Brian Smith
e332ac4b61 Fix cargo test --no-default-features.
Unfortunately, some of the tests require `alloc` even when the `alloc` feature
isn't enabled. That's something to address in the future.
2021-10-06 08:44:03 -07:00
Brian Smith
4726077536 RSA: Test more output buffer lengths passed to rsa::KeyPair::sign(). 2021-10-05 19:21:43 -07:00
Brian Smith
a26925cd1e digest: Make public Algorithm fields accessor functions.
This was done a long time ago for `aead` and other modules.
2021-10-04 15:37:16 -07:00
Brian Smith
f0cad0ad07 Remove BitLength, PublicModulus, PublicExponent from the public API.
Replace `rsa::PublicKey::{n,e}()` with an implementation of `From<&PublicKey>`
for `PublicKeyComponents`. This will fit better with the plans to do the same
for other public key cryptosystem types. This also allows us to remove
`BitLength` from the public API and also to remove some `Debug` implementations.
2021-09-29 13:01:25 -07:00
Brian Smith
1879c0555d RSA: Flatten API by removing public and keypair submodules.
When looking at how this would generlaize to the other public key
cryptosystems (ECDSA, ED25519, etc.), I think having fewer submodules
involved makes more sense.
2021-09-29 13:01:25 -07:00
Brian Smith
f172986113 RSA: Replace RsaSubjectPublicKey with rsa::public::Key. 2021-09-27 13:09:01 -07:00
Brian Smith
fed775d2c3 RSA: Make rsa::public::Key clonable. 2021-09-24 17:04:16 -07:00
Brian Smith
511740c29f RSA: Replace RsaSubjectPublicKey::{modulus,exponent} with rsa::Public::{Modulus,Exponent}::be_bytes().
This is a step towards removing the heap-allocated and usually-unnecessary
`public_key: RsaSubjectPublicKey` field. The new API allows the caller to
better control how it stores/allocates the component values. This also removes
a couple of infallible `unwrap()`s.

This is a step towards removing `io::Positive` from the public API.

This is a breaking API change.
2021-09-24 14:08:08 -07:00
Brian Smith
4a3a17fd21 RSA: Split PKCS#8-specific logic out from general RSA private key construction logic.
Prepare for the introduction of a public API for constructing RSA key pairs from
components, and for the introduction of RSA encryption APIs.
2021-09-23 10:44:03 -07:00
Brian Smith
617b09baa6 RSA: Deprecate and replace RsaKeyPair::public_modulus_len. 2021-09-23 10:43:13 -07:00
Brian Smith
8ac90f4c3e RSA: Move test_signature_rsa_pkcs1_sign_output_buffer_len to tests/.
It's only using the public API so it should be an integration test.
2021-09-22 13:55:57 -07:00
ComplexSpaces
2896a014de Add open_in_place_separate_tag API to LessSafeKey
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2021-09-16 13:24:26 -07:00
Brian Smith
1ab2d161fc Merge BoringSSL d4f877e: Reference the newer ChaCha20-Poly1305 RFC. 2021-08-17 18:59:16 -07:00
Brian Smith
be3443f5c6 Appease Clippy 1.54. 2021-08-02 21:46:17 -07:00
Jack O'Connor
fcbeeabb8b implement Clone for LessSafeKey
OpeningKey and SealingKey intentionally avoid implementing Clone,
because they're attached to a fixed nonce sequence that should be
unique. LessSafeKey isn't attached to a nonce sequence, though, and
making it Clone lets callers avoid repeating key setup work.
2021-05-04 15:20:02 -07:00
Brian Smith
2accae1e7a ECDSA: Add RNG as an input parameter to EcdsaKeyPair::from_pkcs8.
Resolve an old TODO now that we can make breaking API changes.
2021-05-04 15:17:54 -07:00
Brian Smith
2b4d07c177 AEAD tests: Fix warning for non-wasm32 targets. 2021-04-29 16:07:38 -07:00
Brian Smith
9accd874cb WebAssembly: Reduce boilerplate for running tests in WebAssembly.
Skip `digest_tests.rs` since it doesn't get built by wasm-bindgen
correctly when we do this.
2021-04-20 18:22:20 -07:00
Brian Smith
9385c6d014 Use Self more. 2021-03-22 16:11:07 -07:00
Brian Smith
e48c324695 AEAD tests: Add tests for seal_in_place_separate_tag(). 2021-02-24 05:14:07 +00:00
Brian Smith
29b5727bc1 AEAD test: Add tests for open_in_place(). 2021-02-24 05:14:07 +00:00
Brian Smith
e49a8da4e5 AEAD tests: Further refactor tests to reduce repetition. 2021-02-24 05:14:07 +00:00
Brian Smith
16e1b77f3b AEAD tests: Split test_aead into multiple functions. 2021-02-24 05:14:07 +00:00
Brian Smith
ffa5a9f88f AEAD tests: Refactor to reduce boilerplate. 2021-02-24 05:14:07 +00:00
Brian Smith
0664f59420 AEAD tests: Remove unnecessary prefixes in some test functions. 2021-02-24 05:14:07 +00:00
Brian Smith
930b97b0c9 AEAD: Make Aad implement common traits if the underlying type does. 2021-02-24 00:49:15 +00:00
Brian Smith
c6d8f58ad0 Add a Rust ChaCha20 implementation.
See the comments in fallback.rs for more details on the origin.
2021-02-23 18:39:36 +00:00
Brian Smith
d2ff5d1b3e Tests: Remove unneeded use of Result. 2021-02-11 11:20:16 -08:00
Brian Smith
f2488d6118 Agreement: Stop requiring the KDF to return a Result.
Many (most?) KDFs are infallible, so optimize for that case. If the KDF
is fallible then the result will be `Ok(Err(_))` which is messy.

This eliminates the `error_value` parameter.
2021-02-04 19:06:25 -08:00
Brian Smith
d93b954901 Remove definitions of deprecated Error::description()/cause(). 2021-02-04 17:07:41 -08:00
Brian Smith
27200d4596 Ed25519 malleability tests: Add control test case. 2020-12-17 20:55:22 -08:00
Brian Smith
01a2e429ae Merge BoringSSL 3094902: Get closer to Ed25519 boundary conditions. 2020-12-17 20:55:22 -08:00
Brian Smith
a25271beb0 Ed25519 malleability test: Add control case. 2020-12-17 20:55:22 -08:00