# benbaratte/stse architecture

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

- Interactive diagram: https://gitdiagram.com/benbaratte/stse
- Repository: https://github.com/benbaratte/stse

## Overview

This repository provides a Zephyr integration for the STSAFE secure-element library, with a shell demo and Mbed TLS adapters. The principal workflow is to initialize the device and establish a host session, then issue secure-element operations such as authentication, key management, data storage, cryptography, and randomness; certificate helpers and TLS-facing adapters extend that workflow. Platform modules supply I²C, AES, CRC, power, delay, random, and service abstractions. The README has no capability detail, and most STSELib implementation was not sampled, so core-library links are shown as unverified rather than asserted calls.

Main entry points: [`STSELib_Shell/stselib_shell.c`](https://github.com/benbaratte/stse/blob/main/STSELib_Shell/stselib_shell.c) (Command shell), [`STSELib_Shell/stselib_mbedtls.c`](https://github.com/benbaratte/stse/blob/main/STSELib_Shell/stselib_mbedtls.c) (Mbed TLS adapter), [`STSELib_Platform/stse_platform_crc.c`](https://github.com/benbaratte/stse/blob/main/STSELib_Platform/stse_platform_crc.c) (CRC adapter), [`STSELib_Shell/stselib_mbedtls.h`](https://github.com/benbaratte/stse/blob/main/STSELib_Shell/stselib_mbedtls.h) (Mbed TLS interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Secure-element APIs"]
  node_api_device["Device management"]
  node_api_auth["Device authentication"]
  node_api_keys["Key management"]
  node_api_crypto["Crypto operations"]
  node_api_storage["Data storage"]
  node_api_random["Random generation"]
end

subgraph group_core["Device and certificates"]
  node_core_transport["Frame and session"]
  node_core_device["Device state"]
  node_core_services["STSAFE-A services"]
  node_certificates["Certificate handling"]
end

subgraph group_platform["Zephyr platform"]
  node_platform_i2c["I²C transport"]
  node_platform_aes["AES primitives"]
  node_platform_crypto["Crypto primitives"]
  node_platform_crc["CRC adapter"]
  node_crc16["CRC16 implementation<br/>[crc16.c]"]
  node_platform_misc["Platform services"]
end

subgraph group_integration["Shell and TLS"]
  node_shell["Command shell<br/>[stselib_shell.c]"]
  node_mbedtls["Mbed TLS adapter<br/>[stselib_mbedtls.c]"]
  node_mbedtls_api["Mbed TLS interface<br/>[stselib_mbedtls.h]"]
end

node_user(("Embedded application"))

node_user -->|"runs commands"| node_shell
node_shell -->|"initializes device"| node_core_device
node_shell -->|"opens host session"| node_core_services
node_mbedtls -->|"reads certificate data"| node_api_storage
node_mbedtls -->|"generates ECC key"| node_core_services
node_mbedtls_api -.->|"declares interface"| node_mbedtls
node_platform_crc -->|"delegates CRC"| node_crc16
node_api_device -.->|"uses device core"| node_core_device
node_api_auth -.->|"dispatches authentication"| node_core_services
node_api_keys -.->|"dispatches key operations"| node_core_services
node_api_crypto -.->|"dispatches crypto operations"| node_core_services
node_api_storage -.->|"dispatches storage operations"| node_core_services
node_api_random -.->|"dispatches random request"| node_core_services
node_core_services -.->|"uses framing"| node_core_transport
node_core_transport -.->|"uses bus transport"| node_platform_i2c
node_core_services -.->|"uses AES primitives"| node_platform_aes
node_core_services -.->|"uses crypto primitives"| node_platform_crypto

click node_platform_i2c "https://github.com/benbaratte/stse/blob/main/STSELib_Platform/stse_platform_i2c.c"
click node_platform_aes "https://github.com/benbaratte/stse/blob/main/STSELib_Platform/stse_platform_aes.c"
click node_platform_crypto "https://github.com/benbaratte/stse/blob/main/STSELib_Platform/stse_platform_crypto.c"
click node_platform_crc "https://github.com/benbaratte/stse/blob/main/STSELib_Platform/stse_platform_crc.c"
click node_crc16 "https://github.com/benbaratte/stse/blob/main/crc16/crc16.c"
click node_platform_misc "https://github.com/benbaratte/stse/tree/main/STSELib_Platform"
click node_shell "https://github.com/benbaratte/stse/blob/main/STSELib_Shell/stselib_shell.c"
click node_mbedtls "https://github.com/benbaratte/stse/blob/main/STSELib_Shell/stselib_mbedtls.c"
click node_mbedtls_api "https://github.com/benbaratte/stse/blob/main/STSELib_Shell/stselib_mbedtls.h"

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_api_device,node_api_auth,node_api_keys,node_api_crypto,node_api_storage,node_api_random toneBlue
class node_core_transport,node_core_device,node_core_services,node_certificates toneAmber
class node_platform_i2c,node_platform_aes,node_platform_crypto,node_platform_crc,node_crc16,node_platform_misc toneMint
class node_shell,node_mbedtls,node_mbedtls_api toneRose
class node_user toneIndigo
```

## Components

### Secure-element APIs

- **Device management**
- **Device authentication**
- **Key management**
- **Crypto operations**
- **Data storage**
- **Random generation**

### Device and certificates

- **Frame and session**
- **Device state**
- **STSAFE-A services**
- **Certificate handling**

### Zephyr platform

- [I²C transport](https://github.com/benbaratte/stse/blob/main/STSELib_Platform/stse_platform_i2c.c): `STSELib_Platform/stse_platform_i2c.c`
- [AES primitives](https://github.com/benbaratte/stse/blob/main/STSELib_Platform/stse_platform_aes.c): `STSELib_Platform/stse_platform_aes.c`
- [Crypto primitives](https://github.com/benbaratte/stse/blob/main/STSELib_Platform/stse_platform_crypto.c): `STSELib_Platform/stse_platform_crypto.c`
- [CRC adapter](https://github.com/benbaratte/stse/blob/main/STSELib_Platform/stse_platform_crc.c): `STSELib_Platform/stse_platform_crc.c`
- [CRC16 implementation](https://github.com/benbaratte/stse/blob/main/crc16/crc16.c): `crc16/crc16.c`
- [Platform services](https://github.com/benbaratte/stse/tree/main/STSELib_Platform): `STSELib_Platform`

### Shell and TLS

- [Command shell](https://github.com/benbaratte/stse/blob/main/STSELib_Shell/stselib_shell.c): `STSELib_Shell/stselib_shell.c`
- [Mbed TLS adapter](https://github.com/benbaratte/stse/blob/main/STSELib_Shell/stselib_mbedtls.c): `STSELib_Shell/stselib_mbedtls.c`
- [Mbed TLS interface](https://github.com/benbaratte/stse/blob/main/STSELib_Shell/stselib_mbedtls.h): `STSELib_Shell/stselib_mbedtls.h`

### Other components

- **Embedded application**

## Connections

- Embedded application → Command shell: runs commands (evidence: `STSELib_Shell/stselib_shell.c`)
- Command shell → Device state: initializes device (evidence: `STSELib_Shell/stselib_shell.c`)
- Command shell → STSAFE-A services: opens host session (evidence: `STSELib_Shell/stselib_shell.c`)
- Mbed TLS adapter → Data storage: reads certificate data (evidence: `STSELib_Shell/stselib_mbedtls.c`)
- Mbed TLS adapter → STSAFE-A services: generates ECC key (evidence: `STSELib_Shell/stselib_mbedtls.c`)
- Mbed TLS interface → Mbed TLS adapter: declares interface (evidence: `STSELib_Shell/stselib_mbedtls.c`)
- CRC adapter → CRC16 implementation: delegates CRC (evidence: `STSELib_Platform/stse_platform_crc.c`)
- Device management → Device state: uses device core
- Device authentication → STSAFE-A services: dispatches authentication
- Key management → STSAFE-A services: dispatches key operations
- Crypto operations → STSAFE-A services: dispatches crypto operations
- Data storage → STSAFE-A services: dispatches storage operations
- Random generation → STSAFE-A services: dispatches random request
- STSAFE-A services → Frame and session: uses framing
- Frame and session → I²C transport: uses bus transport
- STSAFE-A services → AES primitives: uses AES primitives
- STSAFE-A services → Crypto primitives: uses crypto primitives
