Skip to content

Add support for no malloc with wc_CheckCertSigPubKey #8725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 9, 2025

Conversation

AlexLanzano
Copy link
Contributor

@AlexLanzano AlexLanzano commented May 1, 2025

Description

  • Add support for WOLFSSL_NO_MALLOC in wc_CheckCertSigPubKey. Fixes ZD 19593
  • Refactor DSA ASN.1 decode in ConfirmSignature.
  • Cleanup indent in types.h.
  • Move struct CertSignCtx to types.h.
  • Move WC_ENABLE_ASYM_KEY_IMPORT and WC_ENABLE_ASYM_KEY_EXPORT to settings.h.

Testing

Checklist

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

@SparkiDev
Copy link
Contributor

retest this please
Hudson error and fips failure

@dgarske
Copy link
Contributor

dgarske commented May 5, 2025

Retest this please

@dgarske dgarske changed the title WIP: No malloc support for wc_CheckCertSigPubKey Add support for no malloc with wc_CheckCertSigPubKey May 6, 2025
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Customer is happy with this work, but is small typo in asn.c:18418.

@dgarske dgarske force-pushed the no-malloc-support branch from a135d51 to ff3f480 Compare May 6, 2025 18:28
@dgarske dgarske force-pushed the no-malloc-support branch from f52aba4 to c4d6122 Compare May 6, 2025 21:05
@dgarske dgarske self-assigned this May 6, 2025
@dgarske dgarske force-pushed the no-malloc-support branch 2 times, most recently from 9616df7 to a1f4717 Compare May 6, 2025 21:41
AlexLanzano and others added 3 commits May 7, 2025 12:04
…on-blocking. Refactor DSA ASN.1 decode in ConfirmSignature. Cleanup indent in types.h. Move `struct CertSignCtx` to types.h. Move `WC_ENABLE_ASYM_KEY_IMPORT` and `WC_ENABLE_ASYM_KEY_EXPORT` to settings.h.
@dgarske dgarske force-pushed the no-malloc-support branch from 9f43d67 to 72bff7d Compare May 7, 2025 19:06
@dgarske dgarske assigned SparkiDev and unassigned dgarske and AlexLanzano May 7, 2025
@dgarske dgarske requested a review from SparkiDev May 7, 2025 22:27
@dgarske dgarske requested a review from Copilot May 7, 2025 23:54
Copy link
Contributor

@Copilot Copilot AI left a comment

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 adds support for the WOLFSSL_NO_MALLOC configuration in the certificate signature checking code and refactors the DSA ASN.1 decoding logic. It also cleans up indentation, reformats macros in types.h, reorganizes memory allocation wrappers across multiple files, and moves the CertSignCtx struct from asn.h to types.h.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
wolfssl/wolfcrypt/types.h Reformatted error messages and macro definitions for better multi-line readability.
wolfssl/wolfcrypt/settings.h Added conditional definitions for WC_ENABLE_ASYM_KEY_EXPORT and WC_ENABLE_ASYM_KEY_IMPORT.
wolfssl/wolfcrypt/asn_public.h Removed duplicate definitions for asymmetrical key export/import macros.
wolfssl/wolfcrypt/asn.h Added WOLFSSL_NO_MALLOC guards around allocation/free calls and removed CertSignCtx definitions.
wolfcrypt/test/test.c Suppressed an unused variable warning via an explicit (void) cast.
wolfcrypt/src/sha256.c Adjusted conditional compilation directives to account for WOLFSSL_NO_MALLOC.
wolfcrypt/src/hash.c Updated allocation conditional logic similarly to ensure proper memory management.
wolfcrypt/src/asn.c Wrapped memory allocation and free calls with WOLFSSL_NO_MALLOC checks and refactored DSA decode.
Comments suppressed due to low confidence (2)

wolfcrypt/src/asn.c:17921

  • The allocation calls in ConfirmSignature are repeatedly wrapped with #ifndef WOLFSSL_NO_MALLOC. Consider defining a helper macro or inline function to reduce duplication and improve clarity.
sigCtx->digest = (byte*)XMALLOC(WC_MAX_DIGEST_SIZE, sigCtx->heap, DYNAMIC_TYPE_DIGEST);

wolfcrypt/src/asn.c:17507

  • There are multiple conditional wrappers around memory free calls (and corresponding allocations) due to WOLFSSL_NO_MALLOC. A brief inline comment explaining the rationale for these wrappers would improve future maintainability.
XFREE(sigCtx->sigCpy, sigCtx->heap, DYNAMIC_TYPE_SIGNATURE);

@JacobBarthelmeh JacobBarthelmeh merged commit 8e0aefd into wolfSSL:master May 9, 2025
193 checks passed
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.

5 participants