How stefanberger/libtpms works
Main Components
• Public API Layer: Represent the “include/” directory content (headers like tpm_error.h, tpm_library.h, tpm_memory.h, etc.) – these form the public interface that external applications (for example, Qemu) will link against.
• TPM Implementations:
– TPM 1.2 Components: Show the submodule in “src/tpm12” responsible for TPM commands and state for the TPM 1.2 standard.
– TPM 2.0 Components: Illustrate the “src/tpm2” directory, which is substantial and contains many files organized by function (e.g., command processing, session management, context handling, and state marshaling).
• Cryptographic & Helper Modules:
– Under “src/tpm2/crypto” (and specifically “src/tpm2/crypto/openssl”), include cryptographic functions, such as those supporting RSA, ECC, hashing, and related functions.
– Optionally, denote any helper routines (memory, error handling, debugging facilitators).
• Build and Configuration System:
– Include the autotools build system (configure.ac, bootstrap.sh, autogen.sh, Makefile.am) as components that drive the build pipeline.
• Testing and Fuzzing:
– Represent the “tests/” directory that contains a variety of tests (functional tests, fuzzers using libFuzzer, OSS-fuzz integration, and CVE reproductions) as a separate testing harness.
Relationships and Data Flow
• Additionally, illustrate that the Build System encapsulates components (the compilation, configuration, and testing processes) and that the Testing/Fuzzing components interact with the library to ensure robustness.
Architectural Patterns
• Separation of Concerns: Clearly separate the publicly exposed API from internal implementations.
• Modular Design: Distinguish the TPM versions (TPM 1.2 vs. TPM 2.0) and the cryptographic support as independent but communicating modules.
• Integration-Focused Design: Emphasize that libtpms intentionally exposes only a narrow API so that it minimizes dependencies and simplifies integration with external systems.