Skip to content

Backport 3.6: Fix inconsistent docs for mbedtls_sha3_finish and mbedtls_sha3 olen - #10850

Open
AaryanCdry wants to merge 1 commit into
Mbed-TLS:mbedtls-3.6from
AaryanCdry:fix/sha3-docs-olen
Open

Backport 3.6: Fix inconsistent docs for mbedtls_sha3_finish and mbedtls_sha3 olen#10850
AaryanCdry wants to merge 1 commit into
Mbed-TLS:mbedtls-3.6from
AaryanCdry:fix/sha3-docs-olen

Conversation

@AaryanCdry

Copy link
Copy Markdown

Summary

The documentation of mbedtls_sha3_finish() and mbedtls_sha3() states that olen must equal 28/32/48/64 for SHA3-224/256/384/512, implying an error if olen is larger. However, the implementation silently accepts olen larger 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 olen is the output buffer size, and it must be at least the digest size, not exactly equal.

Change

- *                 SHA-3 384 and SHA-3 512 \c olen must equal to 28, 32, 48 and 64,
+ *                 SHA-3 384 and SHA-3 512 \c olen must be at least 28, 32, 48 and 64,

Applied to both mbedtls_sha3_finish and mbedtls_sha3 function docs.

Test

A unit test verifying olen > digest_size does not return an error would ideally accompany this change. The maintainer noted this would be welcome in a follow-up.

Fixes #10844

@gilles-peskine-arm
gilles-peskine-arm changed the base branch from development to mbedtls-3.6 July 31, 2026 18:16
@gilles-peskine-arm gilles-peskine-arm changed the title Fix inconsistent docs for mbedtls_sha3_finish and mbedtls_sha3 olen Backport 3.6: Fix inconsistent docs for mbedtls_sha3_finish and mbedtls_sha3 olen Jul 31, 2026
@gilles-peskine-arm

Copy link
Copy Markdown
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 mbedtls-3.6 branch.

Also, please amend your commit to add a signoff line to the commit message (git commit --amend --signoff), to indicate that your submission compiles to dco.txt.

@gilles-peskine-arm gilles-peskine-arm added needs-backports Backports are missing or are pending review and approval. priority-medium Medium priority - this can be reviewed as time permits size-xs Estimated task size: extra small (a few hours at most) labels Jul 31, 2026
@gilles-peskine-arm gilles-peskine-arm added needs-work needs-ci Needs to pass CI tests labels Jul 31, 2026
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

Copy link
Copy Markdown
Author

Hi @gilles-peskine-arm — done on both counts. The commit has been rebased on top of the current head of mbedtls-3.6 (f4a1ace) and amended with a Signed-off-by line. Thanks for the review!

@gilles-peskine-arm gilles-peskine-arm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review and removed needs-work needs-backports Backports are missing or are pending review and approval. needs-ci Needs to pass CI tests labels Aug 3, 2026
@gilles-peskine-arm gilles-peskine-arm moved this to Next 3 items in Community Aug 3, 2026
@gilles-peskine-arm

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review priority-medium Medium priority - this can be reviewed as time permits size-xs Estimated task size: extra small (a few hours at most)

Projects

Status: Next 3 items
Status: In Development

Development

Successfully merging this pull request may close these issues.

mbedtls_sha3_finish documentation inconsistent with implementation

2 participants