Repository navigation
Add crypto callback support for SM 2 and SM4 - #513
Draft
padelsbach wants to merge 6 commits into
Draft
padelsbach wants to merge 6 commits into
padelsbach wants to merge 6 commits into
Conversation
padelsbach
force-pushed
the
sm-crypto-cb
branch
from
August 21, 2026 19:58
cbad8b9 to
2827a61
Compare
padelsbach
force-pushed
the
sm-crypto-cb
branch
from
October 14, 2026 18:49
66f45b1 to
fb98535
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
SM4 DMA lengths can truncate silently, and advertised SM3 offloading remains unimplemented.
3 open findings
What changed in this PR
Adds SM2 and SM4 offloading to wolfHSM’s crypto callback infrastructure, with optional SM-enabled builds.
Changes:
- Adds client/server operations, wire messages, and SM4 DMA support.
- Adds interoperability, cached-key, streaming, and DMA tests.
- Enables SM builds and installs pinned wolfsm sources in CI.
| File | Description |
|---|---|
| wolfhsm/wh_message_crypto.h | Defines SM2/SM4 wire messages. |
| wolfhsm/wh_client_crypto.h | Declares SM2/SM4 client APIs. |
| test/wh_test_check_struct_padding.c | Checks new message layouts. |
| test/Makefile | Adds SM=1 option. |
| test/config/user_settings.h | Enables SM algorithms for testing. |
| test-refactor/wh_test_list.c | Registers SM2/SM4 tests. |
| test-refactor/posix/Makefile | Adds SM=1 option. |
| test-refactor/misc/wh_test_check_struct_padding.c | Checks new message layouts. |
| test-refactor/client-server/wh_test_crypto_sm4.c | Tests SM4 modes and DMA. |
| test-refactor/client-server/wh_test_crypto_sm2.c | Tests SM2 operations and cached keys. |
| src/wh_server_crypto.c | Implements SM2/SM4 server handlers. |
| src/wh_message_crypto.c | Adds message translation functions. |
| src/wh_client_cryptocb.c | Dispatches SM2/SM4 callbacks. |
| src/wh_client_crypto.c | Implements client requests and responses. |
| docs/src/6-Utilities.md | Documents SM test prerequisites. |
| .github/actions/checkout-wolfssl/action.yml | Pins dependencies and enables SM testing. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (needed != inSize) { | ||
| return WH_ERROR_BADARGS; | ||
| } | ||
| if (req.input.sz != req.output.sz) { |
| } | ||
| if (ret == 0) { | ||
| ret = wc_ecc_sm2_verify_hash(sig, sigLen, hash, sizeof(hash), | ||
| &verified, hsmKey); |
| /* SM2/SM3/SM4 Options, set by SM=1. Needs wolfsm installed into wolfSSL. */ | ||
| #ifdef WOLFHSM_CFG_TEST_SM | ||
| #define WOLFSSL_SM2 | ||
| #define WOLFSSL_SM3 |
padelsbach
force-pushed
the
sm-crypto-cb
branch
from
November 14, 2026 00:35
2118645 to
108ab86
Compare
padelsbach
force-pushed
the
sm-crypto-cb
branch
from
November 14, 2026 01:39
108ab86 to
e8f2334
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Add SM2 and SM4 support. No async support.