Skip to content

memory.c: add wc_ConstantCompare wrapper. - #10867

Merged
douzzer merged 1 commit into
wolfSSL:masterfrom
philljj:wc_const_comp
Jul 14, 2026
Merged

memory.c: add wc_ConstantCompare wrapper.#10867
douzzer merged 1 commit into
wolfSSL:masterfrom
philljj:wc_const_comp

Conversation

@philljj

@philljjphilljj commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

Add a public wc_ConstantCompare wrapper, similar to the existing wc_ForceZero wrapper. Other project integrations regularly reuse wc_ForceZero, but then reimplement their own ConstantCompare if they don't include misc.c.

The wc_ConstantCompare is guarded by #ifndef WOLFSSL_NO_CONST_CMP.

Testing

Tested with bsdkm, linuxkm, and all-c89-clang-tidy.

@philljjphilljj self-assigned this Jul 8, 2026
CopilotAI review requested due to automatic review settings July 8, 2026 21:45

CopilotAI 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

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 to wolfssl/wolfcrypt/memory.h.
  • Implement wc_ConstantCompare() in wolfcrypt/src/memory.c as a thin wrapper around ConstantCompare().
  • Update several linuxkm/*_glue.c call sites to use wc_ForceZero() and wc_ConstantCompare().

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
wolfssl/wolfcrypt/memory.hExposes new public wc_ConstantCompare() API (guarded by WOLFSSL_NO_CONST_CMP).
wolfcrypt/src/memory.cImplements wc_ConstantCompare() wrapper calling ConstantCompare().
linuxkm/lkcapi_sha_glue.cSwitches sensitive-buffer clearing to wc_ForceZero().
linuxkm/lkcapi_rsa_glue.cSwitches buffer clearing to wc_ForceZero() and signature comparisons to wc_ConstantCompare().
linuxkm/lkcapi_ecdh_glue.cSwitches shared-secret clearing to wc_ForceZero().
linuxkm/lkcapi_dh_glue.cSwitches key/shared-secret clearing to wc_ForceZero().
linuxkm/lkcapi_aes_glue.cSwitches temp buffer clearing to wc_ForceZero().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadlinuxkm/lkcapi_sha_glue.c Outdated
Comment threadlinuxkm/lkcapi_dh_glue.c Outdated
Comment threadlinuxkm/lkcapi_ecdh_glue.c Outdated
Comment threadlinuxkm/lkcapi_aes_glue.c Outdated
Comment threadlinuxkm/lkcapi_rsa_glue.c Outdated
Comment threadlinuxkm/lkcapi_rsa_glue.c Outdated
@philljj

Copy link
Copy Markdown
ContributorAuthor

No Malloc Tests failure will be fixed here:

@douzzerdouzzer 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.

We want the fast inline version, ForceZero, in the linuxkm glue layer -- it's faster and avoids some a little stack burden.

@philljj

philljj commented Jul 10, 2026

Copy link
Copy Markdown
ContributorAuthor

Retest this please

("fatal: early EOF". Network disruption or something.)

@philljj
philljj requested a review from douzzerJuly 10, 2026 22:58

@FrauschiFrauschi 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

@philljjphilljj assigned wolfSSL-Bot and unassigned philljjJul 13, 2026
@douzzer
douzzer merged commit e87f7e8 into wolfSSL:masterJul 14, 2026
339 checks passed
@philljj
philljj deleted the wc_const_comp branch July 16, 2026 17:06
Sign up for freeto 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.

5 participants

@philljj@Frauschi@douzzer@wolfSSL-Bot