tuf/lib.rs
1//! This crate provides an API for talking to repositories that implement The Update Framework
2//! (TUF).
3//!
4//! If you are unfamiliar with TUF, you should read up on it via the [official
5//! website](http://theupdateframework.github.io/). This crate aims to implement the entirety of
6//! the specification as defined at the [head of the `develop`
7//! branch](https://github.com/theupdateframework/tuf/blob/develop/docs/tuf-spec.txt) in the
8//! official TUF git repository.
9//!
10//! Additionally, the following two papers are valuable supplements in understanding how to
11//! actually implement TUF for a community repository.
12//!
13//! - [The Diplomat paper
14//! (2016)](https://www.usenix.org/conference/nsdi16/technical-sessions/presentation/kuppusamy)
15//! - [The Mercury paper
16//! (2017)](https://www.usenix.org/conference/atc17/technical-sessions/presentation/kuppusamy)
17//!
18//! Failure to read the spec and the above papers will likely lead to an implementation that does
19//! not take advantage of all the security guarantees that TUF offers.
20//!
21//! # Interoperability
22//!
23//! It should be noted that historically the TUF spec defined exactly one metadata format and one
24//! way of organizing metadata within a repository. Thus, all TUF implementation could perfectly
25//! interoperate. The TUF spec has moved to describing *how a framework should behave* leaving many
26//! of the detais up to the implementor. Therefore, there are **zero** guarantees that this library
27//! will work with any other TUF implementation. Should you want to access a TUF repository that
28//! uses `rust-tuf` as its backend from another language, ASN.1 modules and metadata schemas are
29//! provided that will allow you to interoperate with this library.
30//!
31//! # Implementation Considerations
32//!
33//! ## Key Management
34//!
35//! Part of TUF is that it acts as its own PKI, and there is no integration that needs to be done
36//! for managing keys.
37//!
38//! Note: No two private keys that are generated should ever exist on the same hardware. When a
39//! step says "generate `N` keys," the implication is that these `N` keys are generated on `N`
40//! devices.
41//!
42//! The first set of keys that need to be generated at the root keys that are used to sign the root
43//! metadata. The root should be defined with the following properties:
44//!
45//! - Minimum:
46//! - 3 keys
47//! - threshold of 2
48//! - Recommended:
49//! - 5 keys
50//! - threshold of 3
51//!
52//! If a threshold of root keys are compromised, then the entire system is compromised and TUF
53//! clients will need to be manually updated. Similarly, if some `X` keys are lost such that the
54//! threshold `N` cannot be reached, then clients will also need to be manually updated. Both of
55//! situations are considered critically unsafe. Whatever number of keys are used, it should be
56//! assumed that some small number may be lost or compromised.
57//!
58//! These root keys **MUST** be kept offline on secure media.
59//!
60//! ## Delegations
61//!
62//! TUF's most useful feature is the ability to delegate certain roles to sign certain targets.
63//! This is discussed in extensive detail in the aforementioned Diplomat paper. There are three
64//! problems faced when delegating trust in TUF:
65//!
66//! 1. What to do for existent accounts that have not yet created and signed TUF metadata
67//! 2. What to do when a new account registers
68//! 3. What to do when an account uploads a new target and new metadata
69//!
70//! There are several approaches for dealing with the above scenarios. We are only going to discuss
71//! on here as it is the recommended approach. This approach is taken directly from Section 6.1 of
72//! the Diplomat paper
73//!
74//! ### Maximum Security Model
75//!
76//! The top-level targets role delegates to three other roles and are listed in the following order:
77//!
78//! 1. `claimed-projects`
79//! - Terminating
80//! - Delegates to project-specific roles that have registered keys with TUF
81//! 2. `rarely-updated-projects`
82//! - Terminating
83//! - Signs all packages for all projects that have been "abandoned" or left unupdated for a long
84//! time AND have not yet registered keys with TUF
85//! 3. `new-projects`
86//! - Non-terminating
87//! - Signs all packages for all new projects as well as projects that were relegated to
88//! `rarely-updated-projects`
89//!
90//! The top-level `targets` role as well as `claimed-projects` and `rarely-updated-projects`
91//! **MUST** all use offline keys.
92//!
93//! The critical, manual step is to register new projects with TUF keys and move them into the
94//! `claimed-projects` role. Projects that refuse to register keys should have their packages
95//! periodically moved into the `rarely-updated-projects` role. Projects in either of these two
96//! roles are safe from compromise as their keys are offline. Since the keys used for the above
97//! operation are kept offline, this is periodic, manual process.
98//!
99//! ## Snapshot & Timestamp
100//!
101//! In a community repository, these two keys need to be kept online and will be used to sign new
102//! metadata on every update.
103
104#![deny(missing_docs)]
105#![allow(
106 clippy::collapsible_if,
107 clippy::implicit_hasher,
108 clippy::let_unit_value,
109 clippy::new_ret_no_self,
110 clippy::op_ref,
111 clippy::too_many_arguments
112)]
113
114pub mod client;
115pub mod crypto;
116pub mod database;
117pub mod error;
118pub mod metadata;
119pub mod pouf;
120pub mod repo_builder;
121pub mod repository;
122pub mod verify;
123
124mod format_hex;
125mod util;
126
127pub use crate::database::*;
128pub use crate::error::*;