Skip to content

feat: use page size for key/trailer manipulation - #965

Open
vhdirk wants to merge 1 commit into
wolfSSL:masterfrom
vhdirk:hal-set-key-page-size
Open

vhdirk wants to merge 1 commit into
wolfSSL:masterfrom
vhdirk:hal-set-key-page-size

Conversation

@vhdirk

@vhdirk vhdirk commented Oct 30, 2026

Copy link
Copy Markdown

This commit introduces WOLFBOOT_PAGE_SIZE as the smallest possible erase unit.
Together with FLASHBUFFER_SIZE, this lowers the amount of ram needed for key/trailer manipulation

This is more a conversation starter than anything else. I don't know if sector/page size is a universal concept. I imagine page size could also be smaller than key size, so that would be problematic

This commit introduces WOLFBOOT_PAGE_SIZE as the smallest possible erase
unit.
Together with FLASHBUFFER_SIZE, this lowers the amount of ram needed for
key/trailer manipulation

This is more a conversation starter than anything else. I don't know if
sector/page size is a universal concept. I imagine page size could also
be smaller than key size, so that would be problematic
Copilot AI balanced review requested due to automatic review settings October 30, 2026 16:03

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.

🟡 Changes recommended

The changes can write before ENCRYPT_CACHE when trailer data does not fit and lose encryption keys on write-once flash because page-based placement conflicts with sector-based key selection and readers.

3 open issues
What changed in this PR

This PR introduces page-sized flash operations for encryption-key and trailer-magic updates, as a step toward reducing wolfBoot’s staging RAM requirements.

Changes:

  • Adds WOLFBOOT_PAGE_SIZE, defaulting to WOLFBOOT_SECTOR_SIZE.
  • Uses page-sized alignment, copying, erasing, and writing in hal_set_key().
  • Changes write-once redundant-copy offsets to use page size.
File Description
src/​libwolfboot.c Adds the page-size fallback and applies page sizing to encryption-key updates.

Review effort: Balanced

Comment thread src/libwolfboot.c
Comment on lines +2751 to +2752
addr_align = addr & (~(WOLFBOOT_PAGE_SIZE - 1));
addr_off = addr & (WOLFBOOT_PAGE_SIZE - 1);
Comment thread src/libwolfboot.c
Comment on lines +2765 to +2766
addr_align = addr & (~(WOLFBOOT_PAGE_SIZE - 1));
addr_align -= (!sel_sec * WOLFBOOT_PAGE_SIZE);
Comment thread src/libwolfboot.c
Comment on lines +168 to +170
#ifndef WOLFBOOT_PAGE_SIZE
#define WOLFBOOT_PAGE_SIZE WOLFBOOT_SECTOR_SIZE
#endif
@dgarske

dgarske commented Oct 30, 2026

Copy link
Copy Markdown
Member

Hi @vhdirk thanks for this pull request. I do not see you on our contributor agreement list. To get setup please send an email to support at wolfssl dot com and reference this pull request and include details about your project and location. Are you planning any additional contributions? Thanks, David Garske, wolfSSL

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