add support for ECC_MAKE_PUB and ECC_CHECK_PUB crypto callbacks#451
Open
rizlik wants to merge 2 commits into
Open
add support for ECC_MAKE_PUB and ECC_CHECK_PUB crypto callbacks#451rizlik wants to merge 2 commits into
rizlik wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends wolfHSM’s ECC public-key handling by adding end-to-end support (wire messages, client APIs, crypto-callback plumbing, server handlers, and tests) for two wolfCrypt callback operations: deriving a public point from a private-only ECC key (WC_PK_TYPE_EC_MAKE_PUB) and validating ECC keys (WC_PK_TYPE_EC_CHECK_PUB_KEY). It also updates server-side public export to handle resident private-only ECC keys by deriving their public half before encoding.
Changes:
- Add new crypto wire messages + translation helpers for ECC make-public requests/responses, and extend ECC check request fields.
- Implement client API + crypto callback routing and server request handlers for ECC make-public and check-pubkey operations.
- Expand test coverage to exercise make-public and check-pubkey paths (including private-only and mismatch scenarios) and update feature documentation.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfhsm/wh_settings.h | Adds a client-build compile-time guard against WOLFSSL_VALIDATE_ECC_IMPORT due to unsafe nested transaction/buffer reuse. |
| wolfhsm/wh_message_crypto.h | Introduces ECC make-public request/response structs and extends ECC check request fields. |
| wolfhsm/wh_client_crypto.h | Adds/updates public client APIs for ECC make-public and ECC pubkey validation with detailed contract docs. |
| src/wh_message_crypto.c | Implements translation helpers for new ECC make-public messages and additional ECC check request fields. |
| src/wh_client_cryptocb.c | Routes new wolfCrypt crypto-callback ops (EC_MAKE_PUB, EC_CHECK_PUB_KEY) to wolfHSM client APIs. |
| src/wh_client_crypto.c | Implements request/response flows for wh_Client_EccMakePub and expanded wh_Client_EccCheckPubKey. |
| src/wh_server_crypto.c | Adds server-side handlers for EC_MAKE_PUB and EC_CHECK_PUB_KEY and dispatches them in crypto request handling. |
| src/wh_server_keystore.c | Uses server devId for key init in export helpers and derives ECC public half for resident private-only keys before DER export. |
| test/wh_test_crypto.c | Adds extensive ECC make-public and check-pubkey functional tests; expands DMA public export coverage for private-only ECC keys. |
| test/wh_test_check_struct_padding.c | Includes new ECC make-public structs in padding checks. |
| docs/src/5-Features.md | Updates feature list to reflect ECC public key derivation and key validation support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+407
to
+413
| ecc_key* key = info->pk.ecc_check_pub.key; | ||
| const uint8_t* pub_key = | ||
| (const uint8_t*)info->pk.ecc_check_pub.pubKey; | ||
| uint16_t pub_key_len = (uint16_t)info->pk.ecc_check_pub.pubKeySz; | ||
| int check_order = info->pk.ecc_check_pub.checkOrder; | ||
| int check_priv = info->pk.ecc_check_pub.checkPriv; | ||
|
|
| int pub_ret; | ||
|
|
||
| ret = wc_ecc_init_ex(key, NULL, INVALID_DEVID); | ||
| ret = wc_ecc_init_ex(key, NULL, server->devId); |
Comment on lines
+619
to
+621
| uint32_t curveId; /* wolfCrypt curve id, carried as int32: | ||
| * ECC_CURVE_INVALID (-1) for a custom curve. The curve | ||
| * travels with the key, so the server ignores this */ |
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.
No description provided.