-
Notifications
You must be signed in to change notification settings - Fork 24
Static code analysis fixes #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
fd1520f
65c4089
665c4c1
148e1d6
33efd26
dc5bd0d
c8d6a4d
99ebafd
9ff0150
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3839,7 +3839,10 @@ CK_RV C_DigestInit(CK_SESSION_HANDLE hSession, | |||||||||
| WP11_Session_SetOpInitialized(session, init); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| rv = ret; | ||||||||||
| if (ret != 0 && ret != (int)CKR_MECHANISM_INVALID) | ||||||||||
| rv = CKR_FUNCTION_FAILED; | ||||||||||
| else | ||||||||||
| rv = ret; | ||||||||||
| WOLFPKCS11_LEAVE("C_DigestInit", rv); | ||||||||||
| return rv; | ||||||||||
| } | ||||||||||
|
|
@@ -3892,7 +3895,9 @@ CK_RV C_Digest(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, | |||||||||
| session); | ||||||||||
| *pulDigestLen = hashLen; | ||||||||||
|
|
||||||||||
| return ret; | ||||||||||
| if (ret < 0) | ||||||||||
| return CKR_FUNCTION_FAILED; | ||||||||||
| return CKR_OK; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
@@ -3936,7 +3941,9 @@ CK_RV C_DigestUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart, | |||||||||
|
|
||||||||||
| ret = WP11_Digest_Update(pPart, (word32)ulPartLen, session); | ||||||||||
|
|
||||||||||
| return ret; | ||||||||||
| if (ret < 0) | ||||||||||
| return CKR_FUNCTION_FAILED; | ||||||||||
| return CKR_OK; | ||||||||||
LinuxJedi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
@@ -3979,7 +3986,9 @@ CK_RV C_DigestKey(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hKey) | |||||||||
|
|
||||||||||
| ret = WP11_Digest_Key(obj, session); | ||||||||||
|
|
||||||||||
| return ret; | ||||||||||
| if (ret < 0) | ||||||||||
| return CKR_FUNCTION_FAILED; | ||||||||||
LinuxJedi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| return CKR_OK; | ||||||||||
|
||||||||||
| return CKR_OK; | |
| return (CK_RV)ret; |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C_DigestFinal() maps BUFFER_E (returned when the caller-provided digest buffer is too small) to CKR_FUNCTION_FAILED. This loses the PKCS#11-required CKR_BUFFER_TOO_SMALL signal; please translate BUFFER_E to CKR_BUFFER_TOO_SMALL (and only use CKR_FUNCTION_FAILED for true internal failures).
| if (ret == BUFFER_E) | |
| return CKR_BUFFER_TOO_SMALL; |
LinuxJedi marked this conversation as resolved.
Show resolved
Hide resolved
LinuxJedi marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -154,7 +154,7 @@ static CK_RV checkPinLen(CK_ULONG pinLen) | |||||
| #else | ||||||
| if (pinLen > WP11_MAX_PIN_LEN) | ||||||
| #endif | ||||||
| return CKR_PIN_INCORRECT; | ||||||
| return CKR_PIN_LEN_RANGE; | ||||||
|
||||||
| return CKR_PIN_LEN_RANGE; | |
| return CKR_PIN_INCORRECT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C_Digest() maps any negative return from WP11_Digest_Single() to CKR_FUNCTION_FAILED. WP11_Digest_Single can return BUFFER_E when the output buffer is too small, which should be surfaced as CKR_BUFFER_TOO_SMALL (similar to how C_GetAttributeValue maps BUFFER_E). Consider translating BUFFER_E to CKR_BUFFER_TOO_SMALL instead of collapsing it into CKR_FUNCTION_FAILED.