Commit Graph

16 Commits

Author SHA1 Message Date
Nick Mathewson dcec7ca2dc llcrypto: Don't take or return "unescorted" ed25519 keys.
Per #798, we want to make sure that we never pass around an
`ed25519::SecretKey`; only an `ed25519::Keypair` (or
`ExpandedKeypair`).  This is because, when you're computing an
ed25519 signature, you have to use the public key as one of your
inputs, and if you ever use a mismatched public key you are
vulnerable to a nonce reuse attack.

(For more info see
https://moderncrypto.org/mail-archive/curves/2020/001012.html )
2023-05-18 11:00:43 -04:00
Nick Mathewson bf04641c68 Disable clippy::unlinlined-format-args
This warning kind of snuck up on us! (See #748)  For now, let's
disable it.  (I've cleaned it up in a couple of examples, since
those are meant to be more idiomatic and user-facing.)

Closes #748.
2023-01-27 08:27:47 -05:00
Nick Mathewson 889206cde4 Complete our migration to base64ct.
This is in lieu of upgrading to the latest base64 crate, which has
a different API from the old one.  Since we have to migrate either
way, we might as well use base64ct everywhere.

I don't think that most of these cases _require_ constant-time
base64, but it won't hurt.
2023-01-20 08:06:30 -05:00
Ian Jackson a773a753b3 Merge branch 'fix-nightly-clippy' into 'main'
Fix nightly clippy

See merge request tpo/core/arti!729
2022-09-22 16:45:52 +00:00
Nick Mathewson 657914f778 Add a new constant-time is_zero() check for RsaIdentity
There are some places in the protocol where we have an all-zero RSA
identity that does not truly represent a key, but rather represents
an absent or unknown key.  For these, it's better to use
`RsaIdentity::is_zero` instead of manually checking for a set of
zero bytes: it expresses the intent better, and ensures that the
operation is constant-time.

I am deliberately not introducing a more general IsZero trait here,
or implementing is_zero for anything else: This is the only one we
seem to need right now.  We can generalize it later if we have to.
2022-09-20 09:13:31 -04:00
trinity-1686a 8e7a904260 fix clippy::needless_borrow 2022-09-10 14:39:47 +02:00
Nick Mathewson 967ea67b7d Use testing_rng() in tests throughout our crates.
This only affects uses of thread_rng(), and affects them all more or
less indiscriminately.  One test does not work with
ARTI_TEST_PRNG=deterministic; the next commit will fix it.
2022-06-02 14:56:42 -04:00
Nick Mathewson aaab6f3812 Upgrade to AES 0.8
Now that we require Rust 1.56, we can upgrade to AES 0.8.  This
forces us to have some slight API changes.

We require cipher 0.4.1, not cipher 0.4.0, since 0.4.0 has
compatibility issues with Rust 1.56.
2022-04-26 12:16:22 -04:00
Nick Mathewson 2f6bc6bdc4 squash! Bump every crate's edition to 2021.
Remove all `use` statements for `TryFrom` and `TryInto`.  These are
now redundant in Rust 2021.
2022-04-25 13:06:26 -04:00
Nick Mathewson b6452b4812 Add a from_hex method for RsaIdentity.
We perform this operation in a bunch of places, and most of them
use hex::decode().  That's not great, since hex::decode() has to do
heap allocation.  This implementation uses hex::decode_to_slice(),
which should be faster.

(In the future we might choose to use one of the faster hex
implementations, but I'm hoping that this change will be sufficient
to get hex decoding out of our profiles.)

Part of #377.
2022-03-04 08:55:34 -05:00
Ian Jackson 7a4369e240 tor-llcrypto: Add test case for RsaIdentity formatting
I'm going to change the code that does this, so add a test first
to check the output doesn't change.

At some point we should have more RSA tests.
2022-03-02 16:25:01 +00:00
Nick Mathewson dd55f5ce2d Remove clippy::needless_borrow exception in CI.
This exception is no longer necessary now that the underlying CI bug
is fixed.
2022-02-20 09:09:38 -05:00
Ian Jackson 7be3bf6339 Temporarily disable some clippy lints on nightly 2022-02-02 21:57:30 +00:00
Daniel Eades e7bbe9e7a1 address lint warnings 2021-12-09 13:51:42 +00:00
Nick Mathewson fb591c51b4 tor-llcrypto: Put currently unused functions behind features.
We don't currently need a couple of the key manipulation features
that we have, since we aren't yet doing relays or onion service
clients.

Part of #125
2021-11-12 11:56:05 -05:00
Nick Mathewson 557a0ff40b Move all crates into a `crates` subdirectory.
This will cause some pain for now, but now is really the best time
to do this kind of thing.
2021-08-27 09:53:09 -04:00