tss_esapi/
lib.rs

1// Copyright 2019 Contributors to the Parsec project.
2// SPDX-License-Identifier: Apache-2.0
3#![deny(
4    nonstandard_style,
5    dead_code,
6    improper_ctypes,
7    non_shorthand_field_patterns,
8    no_mangle_generic_items,
9    overflowing_literals,
10    path_statements,
11    patterns_in_fns_without_body,
12    unconditional_recursion,
13    unused,
14    unused_allocation,
15    unused_comparisons,
16    unused_parens,
17    while_true,
18    missing_debug_implementations,
19    //TODO: activate this!
20    //missing_docs,
21    trivial_casts,
22    trivial_numeric_casts,
23    unused_extern_crates,
24    unused_import_braces,
25    unused_qualifications,
26    unused_results,
27    missing_copy_implementations,
28    rustdoc::broken_intra_doc_links,
29)]
30//! # TSS 2.0 Rust Wrapper over Enhanced System API
31//! This crate exposes the functionality of the TCG Software Stack Enhanced System API to
32//! Rust developers, both directly through FFI bindings and through more Rust-tailored interfaces
33//! at varying levels of abstraction.
34//! Only platforms based on processors with a word size of at least 16 bits are supported.
35//!
36//! # Relevant specifications
37//! This library is built with insight from Trusted Computing Group specifications. The specs most relevant
38//! here are:
39//! * the [Trusted Platform Module Library Specification, Family “2.0”, Level 00, Revision 01.59](https://trustedcomputinggroup.org/work-groups/trusted-platform-module/)
40//! * the [TCG TSS 2.0 Enhanced System API (ESAPI) Specification, version 1.00, revision 14](https://trustedcomputinggroup.org/resource/tcg-tss-2-0-enhanced-system-api-esapi-specification/)
41//!
42//! The different parts of the first spec mentioned above (henceforth called the TPM2 spec) can be
43//! referenced individually throughout the documentation of this crate, using their part number or name.
44//! For example,
45//! [Part 1, Architecture](https://trustedcomputinggroup.org/wp-content/uploads/TCG_TPM2_r1p59_Part1_Architecture_pub.pdf)
46//! could be referenced as "the Architecture spec" or "part 1 of the TPM2 spec".
47//!
48//! The second spec mentioned above will henceforth be called the ESAPI or ESys spec.
49//!
50//! Some parts of the code relate to features or functionality defined in other specifications (such as the
51//! [Marshaling/Unmarshaling API v1, rev7 spec](https://trustedcomputinggroup.org/resource/tcg-tss-2-0-marshalingunmarshaling-api-specification/)),
52//! and in such cases the specification should be linked and referenced in full.
53//!
54//! # Code structure
55//! Our code structure is mostly derived from part 2 of the TPM2 spec.
56//! For simplicity, however, we have reduced the depth of the import tree, so most (if not all) types
57//! are at most one level away from root.
58//!
59//! Minimum supported Rust version (MSRV):
60//! We currently check with version 1.66.0 of the Rust compiler during CI builds.
61//!
62//! # Notes on code safety:
63//! * thread safety is ensured by the required mutability of the `Context` structure within the
64//!   methods implemented on it; thus, in an otherwise safe app commands cannot be dispatched in
65//!   parallel for the same context; whether multithreading with multiple context objects is possible
66//!   depends on the TCTI used and this is the responsibility of the crate client to establish.
67//! * the `unsafe` keyword is used to denote methods that could panic, crash or cause undefined
68//!   behaviour. Whenever this is the case, the properties that need to be checked against
69//!   parameters before passing them in will be stated in the documentation of the method.
70//! * `unsafe` blocks within this crate need to be documented through code comments if they
71//!   are not covered by the points of trust described here.
72//! * the TSS2.0 library that this crate links to is trusted to return consistent values and to
73//!   not crash or lead to undefined behaviour when presented with valid arguments.
74//! * the `Mbox` crate is trusted to perform operations safely on the pointers provided to it, if
75//!   the pointers are trusted to be valid.
76//! * methods not marked `unsafe` are trusted to behave safely, potentially returning appropriate
77//!   error messages when encountering any problems.
78//! * whenever `unwrap`, `expect`, `panic` or derivatives of these are used, they need to be
79//!   thoroughly documented and justified - preferably `unwrap` and `expect` should *never* fail
80//!   during normal operation.
81//! * these rules can be broken in test-only code and in tests.
82//!
83//! # Logging
84//! This crate uses the typical `log` crate for printing errors generated in method calls. If
85//! you would like to filter out these log messages, please check with your logger documentation
86//! on how to do that.
87//!
88//! Additionally, the TSS library will also generate its own log messages and these can be
89//! controlled through environment variables as explained
90//! [here](https://github.com/tpm2-software/tpm2-tss/blob/main/doc/logging.md#runtime-log-level).
91//!
92pub use abstraction::transient::TransientKeyContext;
93pub use context::Context;
94pub use error::{Error, Result, WrapperErrorKind};
95pub use tcti_ldr::TctiNameConf;
96// To replace painlessly the old Tcti structure, should maybe be deprecated at some point.
97pub use tcti_ldr::TctiNameConf as Tcti;
98
99pub use tss_esapi_sys as tss2_esys;
100pub mod abstraction;
101pub mod attributes;
102pub mod constants;
103mod context;
104mod error;
105pub mod handles;
106pub mod interface_types;
107pub mod structures;
108pub mod tcti_ldr;
109pub mod traits;
110pub mod utils;