Skip to content

Documents a precondition in the signle-DES API - #11301

Merged
SparkiDev merged 2 commits into
wolfSSL:masterfrom
miyazakh:f6776_3des
Sep 2, 2026
Merged

SparkiDev merged 2 commits into
wolfSSL:masterfrom
miyazakh:f6776_3des

Conversation

@miyazakh

Copy link
Copy Markdown
Contributor

Summary

  • Documents a precondition gap in the single-DES API: Des has no keySet state (unlike Des3), so wc_Des_CbcEncrypt, wc_Des_CbcDecrypt, and wc_Des_EcbEncrypt do not verify that wc_Des_SetKey() was called first, and will silently operate on undefined key material if it wasn't.
  • Adds \note blocks to wc_Des_SetKey, wc_Des_CbcEncrypt, wc_Des_CbcDecrypt, and wc_Des_EcbEncrypt in doc/dox_comments/header_files/des3.h stating this precondition.
  • Fixes a \sa wc_Des_SetKe typo (missing y) on wc_Des_EcbEncrypt.

Why doc-only

A code fix would need a keySet-style guard added consistently across every wc_Des_CbcEncrypt/Decrypt and wc_Des3_CbcEncrypt/Decrypt implementation in des3.c (~6 backend variants: generic software, STM32 CubeMX, Freescale MMCAU, ColdFire SEC, etc.), several of which also lack the check for Des3 today. It would also touch the file's FIPS-boundary code segment (des3.c is placed in .fipsA$d/.fipsB$d for HAVE_FIPS_VERSION 2/3). Given this is a low-severity, API-misuse-only issue (caller must skip wc_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

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Copilot AI lite review requested due to automatic review settings August 27, 2026 11:01
@miyazakh miyazakh self-assigned this Aug 27, 2026

Copilot AI 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.

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 \note blocks describing the “must call wc_Des_SetKey() first” precondition for DES CBC encrypt/decrypt and DES ECB encrypt.
  • Add a Doxygen \note to wc_Des_SetKey() explaining the lack of keySet state for Des (vs Des3) and the resulting undefined-key-material risk on misuse.
  • Fix a Doxygen \sa typo (wc_Des_SetKewc_Des_SetKey).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread doc/dox_comments/header_files/des3.h Outdated
@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

@miyazakh

Copy link
Copy Markdown
Contributor Author

retest this please

2 similar comments
@miyazakh

Copy link
Copy Markdown
Contributor Author

retest this please

@miyazakh

Copy link
Copy Markdown
Contributor Author

retest this please

@miyazakh miyazakh assigned wolfSSL-Bot and unassigned miyazakh Aug 31, 2026
@SparkiDev
SparkiDev merged commit 7bfdc9c into wolfSSL:master Sep 2, 2026
355 of 356 checks passed
@miyazakh
miyazakh deleted the f6776_3des branch September 2, 2026 10:29
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.

4 participants