Skip to main content
Version: FILS English

Hardware password vault

A secure password manager that stores credentials on-chip and acts as a physical USB keyboard to inject them.

info

Author: Draghici Paul Adrian
Group: 1221EA
GitHub Project Link: https://github.com/UPB-PMRust-Students/fils-project-2026-UserT101

Description

My project aims to build a hardware-based password manager using the STM32U545RE microcontroller. The device securely stores user credentials in its volatile memory (storing passwords and remembering user sessions will be implemented later as an upgrade).

Through a physical rotary encoder and a 2.2" 240x320 SPI display interface, the user can unlock the vault using a Master PIN and select a specific account. Then, the STM32 will retrieve the associated password and will act as a standard Human Interface Device (HID) keyboard, injecting the keystrokes directly into the host computer.

Motivation

Firstly, I thought this idea is something very useful on a daily basis. The goal is to design a highly secure credential vault that mitigates software-based keylogging and eliminates dependence on external software for password autocompletion. By acting as an isolated external hardware device, the host PC never has direct access to the raw password database. This physical separation ensures that sensitive passwords never touch the host system's vulnerable clipboard.

Architecture

The system architecture centers around the STM32U545RE microcontroller, which orchestrates user input, visual feedback, cryptographic operations, and USB communication. The user interacts with the device via a KY-040 Rotary Encoder, navigating a text-based interface rendered on the ILI9341 SPI display.

Because the development board's onboard USB port is hardwired to the ST-LINK programmer, a dedicated USB Type-C breakout board is used to establish a direct data connection to the host PC. Upon selecting an account, the STM32 retrieves the decrypted payload from volatile memory and formats it as standard Human Interface Device (HID) keyboard reports, injecting the keystrokes over the Type-C connection.

Finally, to satisfy strict USB enumeration timing constraints, the USB peripheral is deliberately initialized only after the system completes its primary boot sequence and renders the initial UI.

Component connections

Component Diagram

Log

Week 3-4

I have defined the hardware architecture and ordered all the necessary components.

Week 5-7

I studied the technical documentation and datasheets for the ILI9341 LCD and the KY-040 rotary encoder to prepare the necessary firmware communication protocols and SPI peripheral configurations. I also researched the STM32's USB 2.0 Full Speed capabilities. Decided to go with the SPI screen because testing revealed the former I2C screen to be faulty, and because it offered better functionality.

Week 8-9

I began the hardware assembly phase by soldering the necessary header pins to the USB Type-C breakout board. I set up the initial breadboard prototype, establishing the first communication links between the ILI9341 screen and the STM32 via SPI, while testing the initial USB HID enumeration to ensure the host PC correctly recognized the microcontroller as a standard keyboard. I also researched methods for character injection.

Component Diagram

Week 9-12

Modularizing the code, creating separate files display.rs and serial.rs. Created display states, built the underlying logic. Handled graphics rendering using embedded-graphics (PIN entry screen and the scrollable selection menu), and implemented the asynchronous executor in order for the USB peripheral to poll in the background. Input interpretation: Developed the logic for the KY-040 rotary encoder.

Week 13-14

Final code testing phase, bug fixing, and improving efficiency (choosing to refresh only the UI element that is modified, not the entire screen, for example). Finalized the USB transmission to ensure flawless HID keystroke injection from the STM to the host PC.

Hardware

The central component of the system is the STM32U545RE microcontroller, which currently utilizes its internal volatile memory (RAM) to securely manage credentials during an active session. This stateless approach ensures that no sensitive data persists after power is removed.

The user interface consists of a KY-040 Rotary Encoder—providing tactile navigation and selection via its integrated push-button—paired with an ILI9341 SPI TFT screen for clear visual feedback. To bridge the hardware to the host PC, a USB Type-C Breakout Board is used to route the STM32's native USB data pins, allowing the device to act as a standalone standard keyboard (HID).

Bill of Materials

DeviceUsagePrice
STM32 Nucleo-U545REThe main microcontroller acting as the vault brain120 RON
KY-040 Rotary EncoderUser input interface (navigation and tactile button)6.50 RON
LCD SPI 2.2'' 240x320 pxDisplay interface59.99 RON
USB Type-C Data ModuleHost connectivity to establish a direct HID connection11.53 RON
Breadboard 400 pointsPrototyping hub and resistor mounting5.00 RON
40 Dupont Wires Female-FemaleDirect board-to-module connections4.50 RON
40 Dupont Wires Male-MaleBreadboard connections4.50 RON
4.7kΩ Resistors (20x)Hardware pull-ups for the encoder and signal integrity3.20 RON

Schematics

KICAD Schematic

Software

LibraryDescriptionUsage
embassy-stm32Async embedded frameworkInitializing communication and connecting peripherals
embassy-executorAsync/await executorSpawning the main hardware tasks
embassy-usbUSB protocol stackEstablishing the USB 2.0 Full Speed connection
embassy-syncAsync synchronizationProviding thread-safe channels to pass payloads between the UI and USB tasks
usbd-hidUSB HID class definitionsTransmitting decrypted keystrokes to the host PC
embedded-graphics2D graphics libraryDrawing the text-based menu UI
embedded-hal-busShared bus abstractionsProviding the ExclusiveDevice wrapper to safely manage the SPI Chip Select pin
ili9341Display driverInitializing the specific 240x320 LCD screen and managing orientation
display-interface-spiDisplay communicationAbstracting the SPI bus and Data/Command pin for the ILI9341 driver
heaplessNo-std data structuresProviding memory-safe, fixed-capacity dynamic arrays (Vec, String) without allocators
defmtDeferred formattingGenerating highly efficient, compressed debug logs
defmt-rttRTT transport for defmtTransmitting the compressed logs to the host PC via Real-Time Transfer
panic-probePanic handlerCatching fatal errors and routing the stack trace through the debug interface
  1. STM32U5 Series Documentation
  2. USB Human Interface Device (HID) Class
  3. Embassy Framework