Skip to content

puf: fix transmit-only UART HAL and add an interactive INTERACTIVE=1 demo mode - #623

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:puf_interactive_uart
Open

puf: fix transmit-only UART HAL and add an interactive INTERACTIVE=1 demo mode#623
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:puf_interactive_uart

Conversation

@dgarske

@dgarske dgarske commented Aug 31, 2026

Copy link
Copy Markdown
Member

No description provided.

@dgarske dgarske self-assigned this Aug 31, 2026
Copilot AI lite review requested due to automatic review settings August 31, 2026 18:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the PUF STM32H5 example to support a UART RX path (previously TX-only) and introduces an optional interactive demo build mode (INTERACTIVE=1) that provides a UART-driven menu for stepping through enrollment/reconstruction and a controlled noise sweep.

Changes:

  • Extend the bare-metal USART3 HAL to configure RX (PD9), enable RE, and add blocking uart_getc() plus uart_drain().
  • Add a new interactive demo program (main_interactive.c) and a Makefile switch to build it.
  • Document the new interactive mode and its behavior in puf/README.md.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
puf/stm32.c Adds USART3 RX support (PD9 AF7 + RE) and input helpers for interactive UART menu.
puf/README.md Documents INTERACTIVE=1 build and the interactive UART menu/demo behavior.
puf/Makefile Adds INTERACTIVE switch to select main_interactive.c and forces PUF_TEST=1 when interactive.
puf/main_interactive.c New UART-driven interactive PUF demo with enrollment, reconstruction, helper dump, and noise sweep.
Suppressed comments (2)

puf/main_interactive.c:269

  • wolfCrypt_Init() return value is ignored; if initialization fails, the demo continues and calls wolfCrypt/PUF APIs in an undefined state. Capture and handle the error (at least print and halt) like main.c does.
    hal_init();
    wolfCrypt_Init();

puf/main_interactive.c:196

  • Return values from the two wc_PufDeriveKey() calls are ignored. If derivation fails, the demo prints/uses whatever is left in k1/k2. Propagate and handle the error before printing the keys.
    wc_PufDeriveKey(&ctx, (const byte*)"nv-integrity", 12, k1, sizeof(k1));
    wc_PufDeriveKey(&ctx, (const byte*)"device-identity", 15, k2, sizeof(k2));
    printf("  same silicon, same helper data, two HKDF contexts:\r\n");

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread puf/main_interactive.c Outdated
Comment on lines +122 to +125
wc_PufGetHelperData(&ctx, g_helper, sizeof(g_helper));
wc_PufGetIdentity(&ctx, g_id, sizeof(g_id));
wc_PufDeriveKey(&ctx, (const byte*)"nv-integrity", 12, key, sizeof(key));

@dgarske
dgarske force-pushed the puf_interactive_uart branch 5 times, most recently from 5ebd9b9 to 3ba6cda Compare September 1, 2026 20:00
@dgarske dgarske assigned wolfSSL-Bot and aidangarske and unassigned dgarske Sep 2, 2026
@dgarske
dgarske requested a review from aidangarske September 2, 2026 17:17

@aidangarske aidangarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skoll Code Review

Scan type: review

Overall recommendation: REQUEST_CHANGES
Findings: 10 total — 9 posted, 1 skipped
9 finding(s) posted as inline comments (see file-level comments below)

Posted findings

  • [High] Mode switching can silently leave the wrong firmware in Buildpuf/Makefile:64-68
  • [High] INTERACTIVE does not override a command-line PUF_TEST=0puf/Makefile:37
  • [High] Interactive mode does not build with the supported stable wolfSSLpuf/main_interactive.c:84
  • [High] Rejected blobs are committed as enrolled global statepuf/main_interactive.c:314-345
  • [Medium] A loaded prior-boot blob invalidates the controlled noise sweeppuf/main_interactive.c:155-170
  • [Medium] The recovery checksum is never verifiedpuf/main_interactive.c:292-318
  • [Medium] A health-band pass is presented as proof of a cold-boot readoutpuf/main_interactive.c:396-397
  • [Medium] The new interactive target is not compiled by CIpuf/Makefile:64-65
  • [Low] README lists option 4 twicepuf/README.md:81-82

Skipped findings

  • [Medium] wolfCrypt initialization failure is ignored

Review generated by Skoll

Comment thread puf/Makefile
Comment thread puf/Makefile Outdated
Comment thread puf/main_interactive.c
Comment thread puf/main_interactive.c Outdated
Comment thread puf/main_interactive.c
Comment thread puf/main_interactive.c
Comment thread puf/main_interactive.c
Comment thread puf/Makefile
Comment thread puf/README.md Outdated

@aidangarske aidangarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add some CI for the PUF work we have now or at least build it in CI?

@aidangarske aidangarske assigned dgarske and unassigned wolfSSL-Bot and aidangarske Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants