# yipeng-zhou/embedded-systems-security architecture

> Architecture diagram of the GitHub repository yipeng-zhou/embedded-systems-security, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yipeng-zhou/embedded-systems-security
- Repository: https://github.com/yipeng-zhou/embedded-systems-security

## Overview

This is a collection of XMC4500 embedded-systems and security assignments rather than one unified application. The clearest runtime workflow is in Assignment 2: receive a USB virtual-serial packet, parse it, encrypt its payload, and return a packet; Part C uses libsodium and a hardware-targeted random implementation. Assignment 3 demonstrates USB HID keyboard behavior, while Assignment 1 and the example projects are separate exercises. Relationships below are limited to calls visible in sampled entry points or references in the source index; unsampled implementation details are not inferred.

Main entry points: [`Assignment2/PartC/main.c`](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/main.c) (Part C runtime), [`Assignment2/PartA/main.c`](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartA/main.c) (Part A runtime), [`Assignment2/PartB/main.c`](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartB/main.c) (Part B runtime), [`Assignment3/PartA/main.c`](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment3/PartA/main.c) (Keyboard HID app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_crypto["Packet Crypto Assignments"]
  node_a2a_main["Part A runtime<br/>[main.c]"]
  node_a2a_serial["Virtual serial<br/>[VirtualSerial.c]"]
  node_a2a_packets["Packetizer<br/>[packetizer.c]"]
  node_a2a_crypto["Encryption<br/>[crypto.c]"]
  node_a2b_main["Part B runtime<br/>[main.c]"]
  node_a2b_serial["Virtual serial<br/>[VirtualSerial.c]"]
  node_a2b_packets["Packetizer<br/>[packetizer.c]"]
  node_a2b_crypto["Encryption<br/>[crypto.c]"]
  node_a2c_main["Part C runtime<br/>[main.c]"]
  node_a2c_serial["Virtual serial<br/>[VirtualSerial.c]"]
  node_a2c_packets["Packetizer<br/>[packetizer.c]"]
  node_a2c_crypto["Crypto interface<br/>[crypto.c]"]
  node_sodium["libsodium API<br/>[sodium.h]"]
  node_rng["XMC random source"]
end

subgraph group_hid["USB HID Assignment"]
  node_hid_main["Keyboard HID app<br/>[main.c]"]
  node_hid_driver["HID interface<br/>[KeyboardHID.c]"]
  node_hid_codes["German key codes"]
  node_hid_descriptors["USB descriptors<br/>[Descriptors.c]"]
end

subgraph group_examples["Exercises And Examples"]
  node_parta["Assignment 1 Part A<br/>[PartA.c]"]
  node_partb["Assignment 1 Part B<br/>[PartB.c]"]
  node_hwtest["Hardware test app<br/>[main.c]"]
  node_hwserial["Test virtual serial<br/>[VirtualSerial.c]"]
  node_hwdesc["Test USB descriptors<br/>[Descriptors.c]"]
  node_usb_demo["USB demo app<br/>[main.c]"]
  node_dimming["Dimming exercise<br/>[dimming.c]"]
end

node_host(("USB host"))

node_host -.->|"sends data"| node_a2a_serial
node_a2a_main -->|"initializes USB"| node_a2a_serial
node_a2a_main -->|"receives and sends"| node_a2a_packets
node_a2a_main -->|"encrypts payload"| node_a2a_crypto
node_host -.->|"sends data"| node_a2b_serial
node_a2b_main -->|"initializes USB"| node_a2b_serial
node_a2b_main -->|"receives and sends"| node_a2b_packets
node_a2b_main -->|"encrypts payload"| node_a2b_crypto
node_host -.->|"sends data"| node_a2c_serial
node_a2c_main -->|"initializes USB"| node_a2c_serial
node_a2c_main -->|"receives and sends"| node_a2c_packets
node_a2c_main -->|"encrypts payload"| node_sodium
node_a2c_main -->|"selects implementation"| node_rng
node_hid_main -->|"uses HID interface"| node_hid_driver
node_hid_main -->|"uses key codes"| node_hid_codes
node_hid_main -.->|"configures USB descriptors"| node_hid_descriptors
node_hwtest -->|"echoes serial data"| node_hwserial
node_hwtest -.->|"configures USB descriptors"| node_hwdesc
node_usb_demo -->|"echoes received bytes"| node_host

click node_a2a_main "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartA/main.c"
click node_a2a_serial "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartA/VirtualSerial.c"
click node_a2a_packets "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartA/packetizer.c"
click node_a2a_crypto "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartA/crypto.c"
click node_a2b_main "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartB/main.c"
click node_a2b_serial "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartB/VirtualSerial.c"
click node_a2b_packets "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartB/packetizer.c"
click node_a2b_crypto "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartB/crypto.c"
click node_a2c_main "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/main.c"
click node_a2c_serial "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/VirtualSerial.c"
click node_a2c_packets "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/packetizer.c"
click node_a2c_crypto "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/crypto.c"
click node_sodium "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/sodium.h"
click node_rng "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/randombytes_salsa20XMC_random/randombytes_salsa20XMC_random.c"
click node_hid_main "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment3/PartA/main.c"
click node_hid_driver "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment3/PartA/KeyboardHID.c"
click node_hid_codes "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment3/PartA/german_keyboardCodes.h"
click node_hid_descriptors "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment3/PartA/Descriptors.c"
click node_parta "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment1/PartA/PartA.c"
click node_partb "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment1/PartB/PartB.c"
click node_hwtest "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/example_hw_test/main.c"
click node_hwserial "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/example_hw_test/VirtualSerial.c"
click node_hwdesc "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/example_hw_test/Descriptors.c"
click node_usb_demo "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/example_usb_project/main.c"
click node_dimming "https://github.com/yipeng-zhou/embedded-systems-security/blob/master/exercise_dimming/dimming.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_a2a_main,node_a2a_serial,node_a2a_packets,node_a2a_crypto,node_a2b_main,node_a2b_serial,node_a2b_packets,node_a2b_crypto,node_a2c_main,node_a2c_serial,node_a2c_packets,node_a2c_crypto,node_sodium,node_rng toneBlue
class node_hid_main,node_hid_driver,node_hid_codes,node_hid_descriptors toneAmber
class node_parta,node_partb,node_hwtest,node_hwserial,node_hwdesc,node_usb_demo,node_dimming toneMint
class node_host toneIndigo
```

## Components

### Packet Crypto Assignments

- [Part A runtime](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartA/main.c): `Assignment2/PartA/main.c`
- [Virtual serial](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartA/VirtualSerial.c): `Assignment2/PartA/VirtualSerial.c`
- [Packetizer](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartA/packetizer.c): `Assignment2/PartA/packetizer.c`
- [Encryption](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartA/crypto.c): `Assignment2/PartA/crypto.c`
- [Part B runtime](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartB/main.c): `Assignment2/PartB/main.c`
- [Virtual serial](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartB/VirtualSerial.c): `Assignment2/PartB/VirtualSerial.c`
- [Packetizer](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartB/packetizer.c): `Assignment2/PartB/packetizer.c`
- [Encryption](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartB/crypto.c): `Assignment2/PartB/crypto.c`
- [Part C runtime](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/main.c): `Assignment2/PartC/main.c`
- [Virtual serial](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/VirtualSerial.c): `Assignment2/PartC/VirtualSerial.c`
- [Packetizer](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/packetizer.c): `Assignment2/PartC/packetizer.c`
- [Crypto interface](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/crypto.c): `Assignment2/PartC/crypto.c`
- [libsodium API](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/PartC/sodium.h): `Assignment2/PartC/sodium.h`
- [XMC random source](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment2/randombytes_salsa20XMC_random/randombytes_salsa20XMC_random.c): `Assignment2/randombytes_salsa20XMC_random/randombytes_salsa20XMC_random.c`

### USB HID Assignment

- [Keyboard HID app](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment3/PartA/main.c): `Assignment3/PartA/main.c`
- [HID interface](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment3/PartA/KeyboardHID.c): `Assignment3/PartA/KeyboardHID.c`
- [German key codes](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment3/PartA/german_keyboardCodes.h): `Assignment3/PartA/german_keyboardCodes.h`
- [USB descriptors](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment3/PartA/Descriptors.c): `Assignment3/PartA/Descriptors.c`

### Exercises And Examples

- [Assignment 1 Part A](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment1/PartA/PartA.c): `Assignment1/PartA/PartA.c`
- [Assignment 1 Part B](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/Assignment1/PartB/PartB.c): `Assignment1/PartB/PartB.c`
- [Hardware test app](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/example_hw_test/main.c): `example_hw_test/main.c`
- [Test virtual serial](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/example_hw_test/VirtualSerial.c): `example_hw_test/VirtualSerial.c`
- [Test USB descriptors](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/example_hw_test/Descriptors.c): `example_hw_test/Descriptors.c`
- [USB demo app](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/example_usb_project/main.c): `example_usb_project/main.c`
- [Dimming exercise](https://github.com/yipeng-zhou/embedded-systems-security/blob/master/exercise_dimming/dimming.c): `exercise_dimming/dimming.c`

### Other components

- **USB host**

## Connections

- USB host → Virtual serial: sends data
- Part A runtime → Virtual serial: initializes USB (evidence: `Assignment2/PartA/main.c`)
- Part A runtime → Packetizer: receives and sends (evidence: `Assignment2/PartA/main.c`)
- Part A runtime → Encryption: encrypts payload (evidence: `Assignment2/PartA/main.c`)
- USB host → Virtual serial: sends data
- Part B runtime → Virtual serial: initializes USB (evidence: `Assignment2/PartB/main.c`)
- Part B runtime → Packetizer: receives and sends (evidence: `Assignment2/PartB/main.c`)
- Part B runtime → Encryption: encrypts payload (evidence: `Assignment2/PartB/main.c`)
- USB host → Virtual serial: sends data
- Part C runtime → Virtual serial: initializes USB (evidence: `Assignment2/PartC/main.c`)
- Part C runtime → Packetizer: receives and sends (evidence: `Assignment2/PartC/main.c`)
- Part C runtime → libsodium API: encrypts payload (evidence: `Assignment2/PartC/main.c`)
- Part C runtime → XMC random source: selects implementation (evidence: `Assignment2/PartC/main.c`)
- Keyboard HID app → HID interface: uses HID interface (evidence: `Assignment3/PartA/main.c`)
- Keyboard HID app → German key codes: uses key codes (evidence: `Assignment3/PartA/main.c`)
- Keyboard HID app → USB descriptors: configures USB descriptors
- Hardware test app → Test virtual serial: echoes serial data (evidence: `example_hw_test/main.c`)
- Hardware test app → Test USB descriptors: configures USB descriptors
- USB demo app → USB host: echoes received bytes (evidence: `example_usb_project/main.c`)
