Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a new client API to dynamically switch between hardware and software cryptographic implementations at runtime. The feature allows clients to control whether the server uses hardware acceleration (via crypto callbacks) or pure software wolfCrypt implementations by modifying the server's devId field.
Changes:
- New client API with both blocking and async variants for setting crypto affinity
- Server handler to process affinity change requests with proper validation and error handling
- New message types and translation functions for client-server communication
- Comprehensive test coverage including edge cases and error conditions
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfhsm/wh_server.h | Added configDevId field to preserve original device ID configuration |
| wolfhsm/wh_message_comm.h | Defined message action, enum values, and request/response structures |
| wolfhsm/wh_error.h | Added WH_ERROR_BADCONFIG error code for configuration failures |
| wolfhsm/wh_client.h | Declared new client API functions with comprehensive documentation |
| src/wh_server.c | Implemented initialization of configDevId and request handler with validation |
| src/wh_message_comm.c | Implemented message translation functions following existing patterns |
| src/wh_client.c | Implemented client APIs with proper error handling and retry logic |
| test/wh_test_clientserver.c | Added comprehensive test coverage for various scenarios |
| docs/draft/crypto_affinity.md | Created API documentation with usage examples and return code reference |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
e3fe789 to
571a0c7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
571a0c7 to
3655e5c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9949065 to
506f420
Compare
Add SetCryptoAffinity API for runtime HW/SW crypto selection
Summary
This PR adds a new client API to dynamically switch between hardware and software cryptographic implementations at runtime. This allows clients to control whether the server uses crypto callbacks (hardware acceleration) or pure software wolfCrypt implementations.
Changes
New Client API (
wh_client.c,wh_client.h)wh_Client_SetCryptoAffinity()- blocking callwh_Client_SetCryptoAffinityRequest()/wh_Client_SetCryptoAffinityResponse()- async APINew Message Types (
wh_message_comm.c,wh_message_comm.h)WH_MESSAGE_COMM_ACTION_SET_CRYPTO_AFFINITYactionWH_CRYPTO_AFFINITY_SW/WH_CRYPTO_AFFINITY_HWenum valuesServer Handler (
wh_server.c,wh_server.h)configDevIdfield to preserve the original configured device IDdevIdbetweenINVALID_DEVID(SW) andconfigDevId(HW)New Error Code (
wh_error.h)WH_ERROR_BADCONFIG(-2010) - returned when HW affinity is requested but no HW crypto was configuredTests (
wh_test_clientserver.c)_testCryptoAffinity()to verify SW/HW switching behaviorDocumentation (
docs/draft/crypto_affinity.md)Usage