Backport 3.6: Fix inconsistent docs for mbedtls_sha3_finish and mbedtls_sha3 olen - #10850
Open
AaryanCdry wants to merge 1 commit into
Open
Backport 3.6: Fix inconsistent docs for mbedtls_sha3_finish and mbedtls_sha3 olen#10850AaryanCdry wants to merge 1 commit into
AaryanCdry wants to merge 1 commit into
Conversation
Contributor
|
You started from an old state of the project, which won't pass the CI anymore. Please rebase your commit on top of the current head of the Also, please amend your commit to add a signoff line to the commit message ( |
Change the documentation of mbedtls_sha3_finish() and mbedtls_sha3() to state that olen must be at least the digest size (28, 32, 48, or 64 for SHA3-224/256/384/512) rather than must equal it. The implementation accepts olen larger than the digest size — it silently writes the digest and ignores the excess. The previous docs incorrectly suggested that olen larger than the digest size would be an error. Fixes Mbed-TLS#10844 Signed-off-by: AaryanCdry <AaryanCdry@users.noreply.github.com>
AaryanCdry
force-pushed
the
fix/sha3-docs-olen
branch
from
August 1, 2026 00:57
3814b8f to
874f087
Compare
Author
|
Hi @gilles-peskine-arm — done on both counts. The commit has been rebased on top of the current head of |
Contributor
|
This code still exists in TF-PSA-Crypto 1.1 and development, but it's no longer a public interface, so backporting is optional. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The documentation of
mbedtls_sha3_finish()andmbedtls_sha3()states thatolenmust equal 28/32/48/64 for SHA3-224/256/384/512, implying an error ifolenis larger. However, the implementation silently acceptsolenlarger than the digest size and writes only the digest, ignoring the excess buffer.This has been confirmed by the maintainer (#10844): the intent is that
olenis the output buffer size, and it must be at least the digest size, not exactly equal.Change
Applied to both
mbedtls_sha3_finishandmbedtls_sha3function docs.Test
A unit test verifying
olen > digest_sizedoes not return an error would ideally accompany this change. The maintainer noted this would be welcome in a follow-up.Fixes #10844