Skip to content

Update wolfHSM pointer, fix minor issues#729

Draft
padelsbach wants to merge 2 commits intowolfSSL:masterfrom
padelsbach:update-wolfhsm-submodule
Draft

Update wolfHSM pointer, fix minor issues#729
padelsbach wants to merge 2 commits intowolfSSL:masterfrom
padelsbach:update-wolfhsm-submodule

Conversation

@padelsbach
Copy link
Contributor

@padelsbach padelsbach commented Mar 19, 2026

  • Move wolfHSM submodule like to latest
  • Use host-appropriate SP math
  • Remove use of deleted whServerCryptoContext.devId in hal/sim.c
  • Remove duplicate definition of SP_WORD_SIZE in include/user_settings.h

Copy link

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #729

Scan targets checked: wolfboot-bugs, wolfboot-src
Findings: 1

Low (1)

Crypto context devId changed from INVALID_DEVID to zero

File: hal/sim.c:173
Function: (file-scope initialization)
Category: HAL implementation flaws

The whServerCryptoContext crypto initialization was changed from explicitly setting .devId = INVALID_DEVID to zero-initialization ({0}). In wolfSSL, INVALID_DEVID is typically defined as -2, so devId will now be 0 instead of -2. A devId of 0 is a valid device identifier, which could cause the HSM server's crypto operations to be routed to an unintended crypto device rather than signaling "no device". This may be intentional if the updated wolfHSM submodule (also changed in this PR) now handles devId initialization internally, but if not, it could alter crypto operation routing in the simulator.

/* Before */
whServerCryptoContext crypto[1] = {{
    .devId = INVALID_DEVID,
}};

/* After */
whServerCryptoContext crypto[1] = {0};

Recommendation: Verify that the updated wolfHSM library (commit 18c46af) initializes devId to INVALID_DEVID internally during server setup, or that a devId of 0 is now the intended sentinel value. If neither is the case, restore the explicit .devId = INVALID_DEVID initialization to ensure crypto operations are not misrouted.


This review was generated automatically by Fenrir. Findings are non-blocking.

@padelsbach
Copy link
Contributor Author

Crypto context devId changed from INVALID_DEVID to zero

This field is no longer present in wolfHSM/wolfhsm/wh_server.h

@padelsbach padelsbach mentioned this pull request Mar 19, 2026
@padelsbach padelsbach force-pushed the update-wolfhsm-submodule branch 18 times, most recently from 5302bca to 15f754f Compare March 20, 2026 22:00
@padelsbach padelsbach force-pushed the update-wolfhsm-submodule branch from 15f754f to 6f580e8 Compare March 21, 2026 01:12
src/image.c Outdated
Comment on lines +819 to +822
ret = wc_MlDsaKey_VerifyCtx(&ml_dsa, sig, ML_DSA_IMAGE_SIGNATURE_SIZE,
NULL, 0,
img->sha_hash, WOLFBOOT_SHA_DIGEST_SIZE,
&verify_res);
Copy link
Member

Choose a reason for hiding this comment

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

Why did you have to change the MlDsa verify API used here?

Copy link
Member

Choose a reason for hiding this comment

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

Just wondering if there is a reason for this, because it seems to be increasing the size of ML-DSA build by 82B. If it's needed it's not an issue and we can update the footprint limit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wolfHSM switched to the new api to pass the FIPS tests and, iiuc, the HSM is used to sign the image and that causes the wolfboot verify to fail -- this is all in the sunny day test.

I'll look into other solutions to fall back to the old API. I had attempted something here, but it's not a complete solution: wolfSSL/wolfHSM#320

Let me know if you have any ideas

@padelsbach padelsbach force-pushed the update-wolfhsm-submodule branch from 6f580e8 to 7e44671 Compare March 21, 2026 15:45
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.

3 participants