Skip to content

Safe guard: zero output allowed - #190

Open
rajapars wants to merge 2 commits into
miekg:masterfrom
rajapars:patch-1
Open

Safe guard: zero output allowed#190
rajapars wants to merge 2 commits into
miekg:masterfrom
rajapars:patch-1

Conversation

@rajapars

Copy link
Copy Markdown

Allowing C_EncryptUpdate to return no data (cipherlen == 0)

Allowing C_EncryptUpdate to return no data (cipherlen == 0)
Allowing C_DecryptUpdate return no data (partlen == 0)
@rajapars

Copy link
Copy Markdown
Author

C_EncryptUpdate and C_DecryptUpdate may legitimately return zero-length output. The current library behavior re-sends the same function call in this case, which leads to incorrect results (e.g., input ABCD becomes AABBCCDD).

According to PKCS#11 specification section 5.2 (Conventions), a retry is only required when the function returns CKR_BUFFER_TOO_SMALL with a non-zero required output length.

Therefore, if the function returns CKR_OK with an output length of 0, the operation should not be re-invoked

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.

1 participant