Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions wolfhsm/wh_flash_unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,21 @@ typedef union whFlashUnit_t {
#define WHFU_BYTES_PER_UNIT sizeof(whFlashUnit)
/* Reject unsupported layouts at compile time. */

#ifndef WOLFHSM_CFG_FLASH_UNIT_NO_ALIGN8_CHECK
struct whFlashUnitAlignmentCheck {
uint8_t byte;
whFlashUnit unit;
};
#endif

WH_UTILS_STATIC_ASSERT(sizeof(whFlashUnit) == WOLFHSM_CFG_FLASH_UNIT_SIZE,
"whFlashUnit size mismatch");
#ifndef WOLFHSM_CFG_FLASH_UNIT_NO_ALIGN8_CHECK
WH_UTILS_STATIC_ASSERT(
(offsetof(struct whFlashUnitAlignmentCheck, unit) >= 8) &&
((offsetof(struct whFlashUnitAlignmentCheck, unit) % 8) == 0),
"whFlashUnit must be aligned to 8 bytes");
#endif

#define WHFU_BYTES2UNITS(_b) (((_b) / WHFU_BYTES_PER_UNIT) + \
!!((_b) % WHFU_BYTES_PER_UNIT))
Expand Down
6 changes: 6 additions & 0 deletions wolfhsm/wh_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
* WH_ALIGN8 - Compiler-specific 8-byte alignment attribute.
* Default: Detected from the compiler
*
* WOLFHSM_CFG_FLASH_UNIT_NO_ALIGN8_CHECK - If defined, skip the compile-time
* check that whFlashUnit is 8-byte aligned. The size check is still enforced.
* When this option is defined, whFlashUnit may be less than 8-byte aligned,
* so the flash callbacks must not assume 8-byte aligned buffers.
* Default: Not defined
*
* WOLFHSM_CFG_NVM_FLASH_CRC16 - If defined, the nvm_flash backend stores a
* CRC16 of each object's metadata and data in the on-flash object state and
* verifies them: metadata when the directory is loaded, data on full-object
Expand Down
Loading