Documents a precondition in the signle-DES API - #11301
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Documents an important precondition for the single-DES APIs in wolfCrypt: callers must invoke wc_Des_SetKey() before using DES CBC/ECB operations, because Des lacks the keySet guard present in Des3 and the DES operations won’t verify initialization.
Changes:
- Add Doxygen
\noteblocks describing the “must callwc_Des_SetKey()first” precondition for DES CBC encrypt/decrypt and DES ECB encrypt. - Add a Doxygen
\notetowc_Des_SetKey()explaining the lack ofkeySetstate forDes(vsDes3) and the resulting undefined-key-material risk on misuse. - Fix a Doxygen
\satypo (wc_Des_SetKe→wc_Des_SetKey).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Can one of the admins verify this patch? |
Contributor
Author
|
retest this please |
2 similar comments
Contributor
Author
|
retest this please |
Contributor
Author
|
retest this please |
SparkiDev
approved these changes
Sep 2, 2026
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
Deshas nokeySetstate (unlikeDes3), sowc_Des_CbcEncrypt,wc_Des_CbcDecrypt, andwc_Des_EcbEncryptdo not verify thatwc_Des_SetKey()was called first, and will silently operate on undefined key material if it wasn't.\noteblocks towc_Des_SetKey,wc_Des_CbcEncrypt,wc_Des_CbcDecrypt, andwc_Des_EcbEncryptindoc/dox_comments/header_files/des3.hstating this precondition.\sa wc_Des_SetKetypo (missingy) onwc_Des_EcbEncrypt.Why doc-only
A code fix would need a
keySet-style guard added consistently across everywc_Des_CbcEncrypt/Decryptandwc_Des3_CbcEncrypt/Decryptimplementation indes3.c(~6 backend variants: generic software, STM32 CubeMX, Freescale MMCAU, ColdFire SEC, etc.), several of which also lack the check forDes3today. It would also touch the file's FIPS-boundary code segment (des3.cis placed in.fipsA$d/.fipsB$dforHAVE_FIPS_VERSION2/3). Given this is a low-severity, API-misuse-only issue (caller must skipwc_Des_SetKey()entirely to hit it) and is consistent with existing accepted-risk precedent for the same class of issue in Camellia and RC2, this PR only documents the precondition rather than reworking every backend.Scope
Single file:
doc/dox_comments/header_files/des3.h. No functional/code changes.Testing
Documentation-only change; no build or test impact.
Checklist