Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions wolfcrypt/src/signature.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,10 @@ int wc_SignatureVerify(
byte hash_data[MAX_DER_DIGEST_SZ];
#endif

/* Check arguments */
if (data == NULL || data_len == 0 ||
/* Check arguments.
* data may be NULL when data_len is 0 (empty message is valid —
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

These new comments introduce a non-ASCII em dash character (—). This can cause portability/encoding issues for toolchains that assume ASCII-only C sources or have strict source-charset settings. Consider replacing it with an ASCII sequence like '-' or '--' to avoid build problems in constrained environments.

Suggested change
* data may be NULL when data_len is 0 (empty message is valid
* data may be NULL when data_len is 0 (empty message is valid -

Copilot uses AI. Check for mistakes.
* the hash of an empty string is well-defined). */
if ((data == NULL && data_len > 0) ||
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

This change introduces new behavior (allowing empty-message verify). To prevent regressions, add an automated regression test that verifies a known-good signature over an empty message (including the data == NULL, data_len == 0 case), matching the reported Wycheproof vectors.

Copilot uses AI. Check for mistakes.
sig == NULL || sig_len == 0 ||
key == NULL || key_len == 0) {
return BAD_FUNC_ARG;
Expand Down Expand Up @@ -523,8 +525,9 @@ int wc_SignatureGenerate_ex(
byte hash_data[MAX_DER_DIGEST_SZ];
#endif

/* Check arguments */
if (data == NULL || data_len == 0 ||
/* Check arguments.
* data may be NULL when data_len is 0 (signing an empty message). */
if ((data == NULL && data_len > 0) ||
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

This change introduces new behavior (allowing empty-message signing). Add an automated regression test that signs an empty message (including data == NULL, data_len == 0) and then verifies it, ensuring the previous BAD_FUNC_ARG behavior does not return.

Copilot uses AI. Check for mistakes.
sig == NULL || sig_len == NULL || *sig_len == 0 ||
key == NULL || key_len == 0) {
return BAD_FUNC_ARG;
Expand Down
Loading