memory.c: add wc_ConstantCompare wrapper.#10867
Open
philljj wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new public wolfCrypt API wrapper wc_ConstantCompare() (patterned after the existing wc_ForceZero() wrapper) and updates Linux kernel module glue code to prefer the public wc_ wrappers over internal ForceZero() / ConstantCompare().
Changes:
- Add public
wc_ConstantCompare()declaration towolfssl/wolfcrypt/memory.h. - Implement
wc_ConstantCompare()inwolfcrypt/src/memory.cas a thin wrapper aroundConstantCompare(). - Update several
linuxkm/*_glue.ccall sites to usewc_ForceZero()andwc_ConstantCompare().
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfssl/wolfcrypt/memory.h | Exposes new public wc_ConstantCompare() API (guarded by WOLFSSL_NO_CONST_CMP). |
| wolfcrypt/src/memory.c | Implements wc_ConstantCompare() wrapper calling ConstantCompare(). |
| linuxkm/lkcapi_sha_glue.c | Switches sensitive-buffer clearing to wc_ForceZero(). |
| linuxkm/lkcapi_rsa_glue.c | Switches buffer clearing to wc_ForceZero() and signature comparisons to wc_ConstantCompare(). |
| linuxkm/lkcapi_ecdh_glue.c | Switches shared-secret clearing to wc_ForceZero(). |
| linuxkm/lkcapi_dh_glue.c | Switches key/shared-secret clearing to wc_ForceZero(). |
| linuxkm/lkcapi_aes_glue.c | Switches temp buffer clearing to wc_ForceZero(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Contributor
Author
|
No Malloc Tests failure will be fixed here: |
douzzer
requested changes
Jul 9, 2026
douzzer
left a comment
Contributor
There was a problem hiding this comment.
We want the fast inline version, ForceZero, in the linuxkm glue layer -- it's faster and avoids some a little stack burden.
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
Add a public
wc_ConstantComparewrapper, similar to the existingwc_ForceZerowrapper. Other project integrations regularly reuse wc_ForceZero, but then reimplement their own ConstantCompare if they don't includemisc.c.The
wc_ConstantCompareis guarded by#ifndef WOLFSSL_NO_CONST_CMP.Update linuxkm to use
wc_ForceZeroandwc_ConstantComparewhere it wasn't. linuxkm and bsdkm were already usingwc_ForceZeroin a few spots.Testing
Tested with bsdkm, linuxkm, and
all-c89-clang-tidy.