1
1
//! `tor-llcrypto`: Low-level cryptographic implementations for Tor.
2
//!
3
//! # Overview
4
//!
5
//! The `tor-llcrypto` crate wraps lower-level cryptographic
6
//! primitives that Tor needs, and provides a few smaller pieces of
7
//! cryptographic functionality that are commonly required to
8
//! implement Tor correctly.
9
//!
10
//! This crate is part of
11
//! [Arti](https://gitlab.torproject.org/tpo/core/arti/), a project to
12
//! implement [Tor](https://www.torproject.org/) in Rust.
13
//! Many other crates in Arti depend on it.
14
//!
15
//! You probably wouldn't want to use this crate for implementing
16
//! non-Tor-based protocols; instead you should probably use the other
17
//! crates that it depends on if you have a low-level protocol to
18
//! implement, or a higher-level cryptographic system if you want to
19
//! add security to something else.  It is easy to accidentally put
20
//! these functions together in ways that are unsafe.
21
//!
22
//! ## Why a separate crate?
23
//!
24
//! Why do we collect and re-export our cryptography here in
25
//! `tor-llcrypto`, instead of having the different crates in Arti use
26
//! underlying cryptographic crates directly?
27
//!
28
//! By wrapping our cryptography in this crate, we ensure that we're
29
//! using the same implementations across our ecosystem, and provide
30
//! a single place to upgrade and test our cryptography.
31
//!
32
//! ## Adding to `tor-llcrypto`
33
//!
34
//! Any low-level cryptographic algorithm that is used by at least two
35
//! other crates in Arti is a candidate for inclusion in
36
//! `tor-llcrypto`, especially if that algorithm's purpose is not
37
//! specific to any single piece of the Tor algorithm.
38
//!
39
//! Cryptographic _traits_ (like those from RustCrypto) don't have to
40
//! go in `tor-llcrypto`, since they are interfaces rather than
41
//! implementations.
42
//!
43
//! # Contents
44
//!
45
//! Encryption is implemented in [`cipher`]: Currently only AES is
46
//! exposed or needed.
47
//!
48
//! Cryptographic digests are in [`d`]: The Tor protocol uses several
49
//! digests in different places, and these are all collected here.
50
//!
51
//! Public key cryptography (including signatures, encryption, and key
52
//! agreement) are in [`pk`].  Older parts of the Tor protocol require
53
//! RSA; newer parts are based on Curve25519 and Ed25519. There is
54
//! also functionality here for _key manipulation_ for the keys used
55
//! in these symmetric algorithms.
56
//!
57
//! The [`util`] module has some miscellaneous compatibility utilities
58
//! for manipulating cryptography-related objects and code.
59
//!
60
//! # Features
61
//!
62
//! `relay` -- enable cryptography that's only used on relays.
63
//!
64
//! `hsv3-client` -- enable cryptography that's only needed when running
65
//! as a v3 onion service client.
66

            
67
#![deny(missing_docs)]
68
#![warn(noop_method_call)]
69
#![deny(unreachable_pub)]
70
#![warn(clippy::all)]
71
#![deny(clippy::await_holding_lock)]
72
#![deny(clippy::cargo_common_metadata)]
73
#![deny(clippy::cast_lossless)]
74
#![deny(clippy::checked_conversions)]
75
#![warn(clippy::cognitive_complexity)]
76
#![deny(clippy::debug_assert_with_mut_call)]
77
#![deny(clippy::exhaustive_enums)]
78
#![deny(clippy::exhaustive_structs)]
79
#![deny(clippy::expl_impl_clone_on_copy)]
80
#![deny(clippy::fallible_impl_from)]
81
#![deny(clippy::implicit_clone)]
82
#![deny(clippy::large_stack_arrays)]
83
#![warn(clippy::manual_ok_or)]
84
#![deny(clippy::missing_docs_in_private_items)]
85
#![deny(clippy::missing_panics_doc)]
86
#![warn(clippy::needless_borrow)]
87
#![warn(clippy::needless_pass_by_value)]
88
#![warn(clippy::option_option)]
89
#![warn(clippy::rc_buffer)]
90
#![deny(clippy::ref_option_ref)]
91
#![warn(clippy::semicolon_if_nothing_returned)]
92
#![warn(clippy::trait_duplication_in_bounds)]
93
#![deny(clippy::unnecessary_wraps)]
94
#![warn(clippy::unseparated_literal_suffix)]
95
#![deny(clippy::unwrap_used)]
96

            
97
pub mod cipher;
98
pub mod d;
99
pub mod pk;
100
pub mod util;