Skip to content

F-3800, F-3801, F-3802: fix truncation in wh_client_crypto.c#366

Open
padelsbach wants to merge 1 commit into
wolfSSL:mainfrom
padelsbach:f-3800
Open

F-3800, F-3801, F-3802: fix truncation in wh_client_crypto.c#366
padelsbach wants to merge 1 commit into
wolfSSL:mainfrom
padelsbach:f-3800

Conversation

@padelsbach
Copy link
Copy Markdown
Contributor

No description provided.

@padelsbach padelsbach marked this pull request as ready for review May 14, 2026 18:08
Copy link
Copy Markdown

@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 #366

Scan targets checked: wolfhsm-crypto-bugs, wolfhsm-src

No new issues found in the changed files. ✅

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses output truncation bugs in the client-side crypto APIs by returning WH_ERROR_BUFFER_SIZE and reporting the required output size (via in/out length pointers) instead of silently truncating signatures / outputs. It also adds regression tests in the refactored client/server test suite to validate the corrected behavior for Ed25519, RSA, and ML-DSA.

Changes:

  • Update wh_Client_Ed25519Sign, wh_Client_RsaFunction, and wh_Client_MlDsaSign to fail with WH_ERROR_BUFFER_SIZE (and report required size) rather than truncating.
  • Add new client-side regression tests covering “buffer too small” behavior for Ed25519, RSA, and ML-DSA.
  • Register the new tests in the refactored test runner list.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/wh_client_crypto.c Removes silent truncation in several client crypto response handlers and reports required output sizes.
test-refactor/client-server/wh_test_crypto.c Adds new “buffer too small” regression tests for Ed25519, RSA, and ML-DSA client APIs.
test-refactor/wh_test_list.c Registers the new tests so they run in the refactored client test group.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wh_client_crypto.c
Comment on lines +3421 to 3431
if (sig != NULL) {
if (res->sigSz > *inout_sig_len) {
ret = WH_ERROR_BUFFER_SIZE;
}
else {
memcpy(sig, res_sig, res->sigSz);
}
*inout_sig_len = sig_len;
}
if ((sig != NULL) && (sig_len > 0)) {
memcpy(sig, res_sig, sig_len);
if (inout_sig_len != NULL) {
*inout_sig_len = res->sigSz;
}
Comment thread src/wh_client_crypto.c
Comment on lines +4219 to +4229
if (out != NULL) {
if (res->outLen > *inout_out_len) {
ret = WH_ERROR_BUFFER_SIZE;
}
*inout_out_len = out_len;
if ((out != NULL) && (out_len > 0)) {
memcpy(out, res_out, out_len);
else {
memcpy(out, res_out, res->outLen);
}
}
if (inout_out_len != NULL) {
*inout_out_len = res->outLen;
}
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.

4 participants