# ectfmitre/2026-ectf-insecure-example architecture

> Architecture diagram of the GitHub repository ectfmitre/2026-ectf-insecure-example, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ectfmitre/2026-ectf-insecure-example
- Repository: https://github.com/ectfmitre/2026-ectf-insecure-example

## Overview

This is an insecure example design for an eCTF hardware security module (HSM). A host sends control commands to the firmware, which dispatches file operations, applies PIN/permission checks, and reads or writes persistent flash; a neighboring HSM can exchange files over a separate UART interface. The repository also includes shared-secret generation and firmware-header conversion, plus an optional crypto example. Edges reflect shown calls or README statements; unsampled implementation details are not inferred.

Main entry points: [`firmware/src/HSM.c`](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/HSM.c) (Boot and dispatcher), [`firmware/src/commands.c`](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/commands.c) (Command handlers), [`firmware/src/filesystem.c`](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/filesystem.c) (File operations), [`firmware/src/host_messaging.c`](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/host_messaging.c) (Packet messaging)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["HSM firmware"]
  node_runtime["Boot and dispatcher<br/>[HSM.c]"]
  node_handlers["Command handlers<br/>[commands.c]"]
  node_security["PIN and permissions<br/>[security.c]"]
end

subgraph group_storage["Persistent storage"]
  node_filesystem["File operations<br/>[filesystem.c]"]
  node_flash["Flash access<br/>[simple_flash.c]"]
end

subgraph group_interfaces["Device interfaces"]
  node_hostmsg["Packet messaging<br/>[host_messaging.c]"]
  node_uart["UART transport<br/>[simple_uart.c]"]
  node_mspconfig["MSP configuration<br/>[ti_msp_dl_config.c]"]
  node_startup["Device startup"]
end

subgraph group_secrets["Secrets and crypto"]
  node_secretgen["Shared-secret generator<br/>[gen_secrets.py]"]
  node_secretconvert["Secret header converter"]
  node_crypto["Crypto example<br/>[simple_crypto.c]"]
end

node_host(("Host"))
node_neighbor(("Neighbor HSM"))

node_host -->|"sends commands"| node_runtime
node_runtime -->|"reads packets"| node_hostmsg
node_runtime -->|"dispatches commands"| node_handlers
node_runtime -->|"initializes filesystem"| node_filesystem
node_runtime -->|"initializes hardware"| node_mspconfig
node_handlers -->|"checks access"| node_security
node_handlers -->|"reads and writes files"| node_filesystem
node_handlers -->|"sends packets"| node_hostmsg
node_handlers -->|"exchanges file messages"| node_neighbor
node_filesystem -->|"reads and writes"| node_flash
node_hostmsg -->|"transfers bytes"| node_uart
node_uart -->|"uses peripheral config"| node_mspconfig
node_runtime -.->|"runs optional example"| node_crypto
node_runtime -.->|"uses startup support"| node_startup

click node_runtime "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/HSM.c"
click node_handlers "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/commands.c"
click node_security "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/security.c"
click node_filesystem "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/filesystem.c"
click node_flash "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/simple_flash.c"
click node_hostmsg "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/host_messaging.c"
click node_uart "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/simple_uart.c"
click node_mspconfig "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/ti_msp_dl_config.c"
click node_startup "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/startup_mspm0l222x_ticlang.c"
click node_secretgen "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/ectf26_design/src/gen_secrets.py"
click node_secretconvert "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/secrets_to_c_header.py"
click node_crypto "https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/simple_crypto.c"

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_runtime,node_handlers,node_security toneBlue
class node_filesystem,node_flash toneAmber
class node_hostmsg,node_uart,node_mspconfig,node_startup toneMint
class node_secretgen,node_secretconvert,node_crypto toneRose
class node_host,node_neighbor toneIndigo
```

## Components

### HSM firmware

- [Boot and dispatcher](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/HSM.c): `firmware/src/HSM.c`
- [Command handlers](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/commands.c): `firmware/src/commands.c`
- [PIN and permissions](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/security.c): `firmware/src/security.c`

### Persistent storage

- [File operations](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/filesystem.c): `firmware/src/filesystem.c`
- [Flash access](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/simple_flash.c): `firmware/src/simple_flash.c`

### Device interfaces

- [Packet messaging](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/host_messaging.c): `firmware/src/host_messaging.c`
- [UART transport](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/simple_uart.c): `firmware/src/simple_uart.c`
- [MSP configuration](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/ti_msp_dl_config.c): `firmware/src/ti_msp_dl_config.c`
- [Device startup](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/startup_mspm0l222x_ticlang.c): `firmware/src/startup_mspm0l222x_ticlang.c`

### Secrets and crypto

- [Shared-secret generator](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/ectf26_design/src/gen_secrets.py): `ectf26_design/src/gen_secrets.py`
- [Secret header converter](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/secrets_to_c_header.py): `firmware/secrets_to_c_header.py`
- [Crypto example](https://github.com/ectfmitre/2026-ectf-insecure-example/blob/release/firmware/src/simple_crypto.c): `firmware/src/simple_crypto.c`

### Other components

- **Host**
- **Neighbor HSM**

## Connections

- Host → Boot and dispatcher: sends commands (evidence: `firmware/src/HSM.c`)
- Boot and dispatcher → Packet messaging: reads packets (evidence: `firmware/src/HSM.c`)
- Boot and dispatcher → Command handlers: dispatches commands (evidence: `firmware/src/HSM.c`)
- Boot and dispatcher → File operations: initializes filesystem (evidence: `firmware/src/HSM.c`)
- Boot and dispatcher → MSP configuration: initializes hardware (evidence: `firmware/src/HSM.c`)
- Command handlers → PIN and permissions: checks access (evidence: `firmware/src/commands.c`)
- Command handlers → File operations: reads and writes files (evidence: `firmware/src/commands.c`)
- Command handlers → Packet messaging: sends packets (evidence: `firmware/src/commands.c`)
- Command handlers → Neighbor HSM: exchanges file messages (evidence: `firmware/src/commands.c`)
- File operations → Flash access: reads and writes (evidence: `firmware/src/filesystem.c`)
- Packet messaging → UART transport: transfers bytes (evidence: `firmware/src/host_messaging.c`)
- UART transport → MSP configuration: uses peripheral config (evidence: `firmware/src/simple_uart.c`)
- Boot and dispatcher → Crypto example: runs optional example (evidence: `firmware/src/HSM.c`)
- Boot and dispatcher → Device startup: uses startup support
