# trustedcomputinggroup/tpm architecture

> Architecture diagram of the GitHub repository trustedcomputinggroup/tpm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/trustedcomputinggroup/tpm
- Repository: https://github.com/trustedcomputinggroup/tpm

## Overview

This is the official TPM 2.0 reference implementation, with a TCP simulator for exercising the TPM as a device. The principal workflow is a client sending a protocol-encapsulated command to the simulator, which bridges it to TPM command processing and returns a response. The TPM implementation also covers authorization sessions, cryptography, NV state, and platform signals. The map preserves these major runtime areas; unsampled internal wiring is shown only where documented or marked unverified.

Main entry points: [`TPMCmd/tpm/src/main/SessionProcess.c`](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/main/SessionProcess.c) (Command processing), [`TPMCmd/Simulator/src/TcpServer.c`](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/Simulator/src/TcpServer.c) (TCP server), [`TPMCmd/tpm/src/command`](https://github.com/trustedcomputinggroup/tpm/tree/main/TPMCmd/tpm/src/command) (TPM commands), [`TPMCmd/tpm/src/subsystem/Session.c`](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/subsystem/Session.c) (Session lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sim["Simulator interface"]
  node_tcp["TCP server<br/>[TcpServer.c]"]
  node_protocol["TCP protocol<br/>[TpmTcpProtocol.h]"]
  node_rpc["Simulator bridge<br/>[TPMCmdp.c]"]
end

subgraph group_core["TPM command runtime"]
  node_executor["Command processing<br/>[SessionProcess.c]"]
  node_commands["TPM commands"]
  node_marshal["Marshalling<br/>[Marshal.c]"]
  node_nvcommands["NV commands"]
end

subgraph group_security["Security services"]
  node_sessions["Session lifecycle<br/>[Session.c]"]
  node_sessioncmd["Session commands<br/>[StartAuthSession.c]"]
  node_policy["Policy authorization<br/>[PolicyAuthorize.c]"]
  node_crypto["Cryptographic operations<br/>[CryptUtil.c]"]
  node_cryptoapi["Crypto interfaces<br/>[CryptoInterface.h]"]
end

subgraph group_platform["Platform state"]
  node_nv[("NV persistence<br/>[NVMem.c]")]
  node_platform["Platform services"]
  node_profile["TPM configuration"]
end

node_client(("TSS client"))

node_client -->|"sends commands"| node_tcp
node_tcp -.->|"handles messages"| node_protocol
node_tcp -.->|"dispatches requests"| node_rpc
node_rpc -.->|"submits command"| node_executor
node_executor -.->|"marshals responses"| node_marshal
node_executor -.->|"dispatches commands"| node_commands
node_executor -->|"processes sessions"| node_sessions
node_sessioncmd -->|"creates sessions"| node_sessions
node_policy -->|"gets session"| node_sessions
node_commands -.->|"uses cryptography"| node_crypto
node_crypto -.->|"uses interface"| node_cryptoapi
node_nvcommands -.->|"accesses NV"| node_nv
node_executor -.->|"uses platform hooks"| node_platform
node_profile -.->|"configures command set"| node_commands
node_tcp -.->|"returns responses"| node_client

click node_tcp "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/Simulator/src/TcpServer.c"
click node_protocol "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/Simulator/include/TpmTcpProtocol.h"
click node_rpc "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/Simulator/src/TPMCmdp.c"
click node_executor "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/main/SessionProcess.c"
click node_commands "https://github.com/trustedcomputinggroup/tpm/tree/main/TPMCmd/tpm/src/command"
click node_marshal "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/support/Marshal.c"
click node_sessions "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/subsystem/Session.c"
click node_sessioncmd "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/command/Session/StartAuthSession.c"
click node_policy "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/command/EA/PolicyAuthorize.c"
click node_crypto "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/crypt/CryptUtil.c"
click node_cryptoapi "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/cryptolibs/common/include/CryptoInterface.h"
click node_nvcommands "https://github.com/trustedcomputinggroup/tpm/tree/main/TPMCmd/tpm/src/command/NVStorage"
click node_nv "https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/Platform/src/NVMem.c"
click node_platform "https://github.com/trustedcomputinggroup/tpm/tree/main/TPMCmd/Platform/src"
click node_profile "https://github.com/trustedcomputinggroup/tpm/tree/main/TPMCmd/TpmConfiguration/TpmConfiguration"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tcp,node_protocol,node_rpc,node_client toneBlue
class node_executor,node_commands,node_marshal,node_nvcommands toneAmber
class node_sessions,node_sessioncmd,node_policy,node_crypto,node_cryptoapi toneMint
class node_nv,node_platform,node_profile toneRose
```

## Components

### Simulator interface

- [TCP server](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/Simulator/src/TcpServer.c): `TPMCmd/Simulator/src/TcpServer.c`
- [TCP protocol](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/Simulator/include/TpmTcpProtocol.h): `TPMCmd/Simulator/include/TpmTcpProtocol.h`
- [Simulator bridge](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/Simulator/src/TPMCmdp.c): `TPMCmd/Simulator/src/TPMCmdp.c`

### TPM command runtime

- [Command processing](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/main/SessionProcess.c): `TPMCmd/tpm/src/main/SessionProcess.c`
- [TPM commands](https://github.com/trustedcomputinggroup/tpm/tree/main/TPMCmd/tpm/src/command): `TPMCmd/tpm/src/command`
- [Marshalling](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/support/Marshal.c): `TPMCmd/tpm/src/support/Marshal.c`
- [NV commands](https://github.com/trustedcomputinggroup/tpm/tree/main/TPMCmd/tpm/src/command/NVStorage): `TPMCmd/tpm/src/command/NVStorage`

### Security services

- [Session lifecycle](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/subsystem/Session.c): `TPMCmd/tpm/src/subsystem/Session.c`
- [Session commands](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/command/Session/StartAuthSession.c): `TPMCmd/tpm/src/command/Session/StartAuthSession.c`
- [Policy authorization](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/command/EA/PolicyAuthorize.c): `TPMCmd/tpm/src/command/EA/PolicyAuthorize.c`
- [Cryptographic operations](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/src/crypt/CryptUtil.c): `TPMCmd/tpm/src/crypt/CryptUtil.c`
- [Crypto interfaces](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/tpm/cryptolibs/common/include/CryptoInterface.h): `TPMCmd/tpm/cryptolibs/common/include/CryptoInterface.h`

### Platform state

- [NV persistence](https://github.com/trustedcomputinggroup/tpm/blob/main/TPMCmd/Platform/src/NVMem.c): `TPMCmd/Platform/src/NVMem.c`
- [Platform services](https://github.com/trustedcomputinggroup/tpm/tree/main/TPMCmd/Platform/src): `TPMCmd/Platform/src`
- [TPM configuration](https://github.com/trustedcomputinggroup/tpm/tree/main/TPMCmd/TpmConfiguration/TpmConfiguration): `TPMCmd/TpmConfiguration/TpmConfiguration`

### Other components

- **TSS client**

## Connections

- TSS client → TCP server: sends commands
- TCP server → TCP protocol: handles messages
- TCP server → Simulator bridge: dispatches requests
- Simulator bridge → Command processing: submits command
- Command processing → Marshalling: marshals responses
- Command processing → TPM commands: dispatches commands
- Command processing → Session lifecycle: processes sessions (evidence: `TPMCmd/tpm/src/main/SessionProcess.c`)
- Session commands → Session lifecycle: creates sessions (evidence: `TPMCmd/tpm/src/command/Session/StartAuthSession.c`)
- Policy authorization → Session lifecycle: gets session (evidence: `TPMCmd/tpm/src/command/EA/PolicyAuthorize.c`)
- TPM commands → Cryptographic operations: uses cryptography
- Cryptographic operations → Crypto interfaces: uses interface
- NV commands → NV persistence: accesses NV
- Command processing → Platform services: uses platform hooks
- TPM configuration → TPM commands: configures command set
- TCP server → TSS client: returns responses
