Return NOT_COMPILED_IN from wc_BufferKey{Encrypt,Decrypt} for unknown cipherType - #11049
Open
holtrop-wolfssl wants to merge 2 commits into
Open
Return NOT_COMPILED_IN from wc_BufferKey{Encrypt,Decrypt} for unknown cipherType#11049holtrop-wolfssl wants to merge 2 commits into
holtrop-wolfssl wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes wc_BufferKeyEncrypt() / wc_BufferKeyDecrypt() so that an unhandled info->cipherType no longer returns success after a successful PBKDF1 step, instead correctly returning NOT_COMPILED_IN. It also adds API tests to lock in the behavior for an enum value that is valid but intentionally not dispatched by these functions.
Changes:
- Preserve the default
ret = NOT_COMPILED_INby avoiding reuse ofretfor the PBKDF1 return code inwc_BufferKey{Encrypt,Decrypt}. - Add an API test that asserts an unknown/unhandled
cipherTypereturnsNOT_COMPILED_INfor both encrypt and decrypt paths. - Register the new test in the API test decl header.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| wolfcrypt/src/wc_encrypt.c | Keeps ret at NOT_COMPILED_IN unless a supported cipher dispatch arm runs (prevents false success on unknown cipher). |
| tests/api/test_wc_encrypt.h | Registers the new unknown-cipher test in the API test list. |
| tests/api/test_wc_encrypt.c | Adds coverage ensuring unknown/unhandled cipherType returns NOT_COMPILED_IN. |
Suppressed comments (1)
wolfcrypt/src/wc_encrypt.c:293
- On PBKDF1 failure,
keymay contain partially-derived sensitive material (seewc_PBKDF1_ex()writing tokeybefore later hash errors). The early-return path should explicitly zerokeybefore freeing/checking it to avoid leaving key material in memory and to preventwc_MemZero_Check()from aborting ifkeywas modified before the error.
if ((pbkdf1_ret = wc_PBKDF1(key, password, passwordSz, info->iv, PKCS5_SALT_SZ, 1,
(int)info->keySz, hashType)) != 0) {
#ifdef WOLFSSL_SMALL_STACK
XFREE(key, NULL, DYNAMIC_TYPE_SYMMETRIC_KEY);
#elif defined(WOLFSSL_CHECK_MEM_ZERO)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
holtrop-wolfssl
force-pushed
the
f-7397
branch
2 times, most recently
from
August 5, 2026 17:12
1f84f79 to
327f24f
Compare
Contributor
Author
|
retest this please (fips ready config failed in PRB-master-job) |
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.
Description
Return NOT_COMPILED_IN from wc_BufferKey{Encrypt,Decrypt} for unknown cipherType
Fixes F-7397
Testing
How did you test?
Checklist