Skip to content

Conversation

@jackctj117
Copy link

@jackctj117 jackctj117 commented Jan 8, 2026

Prereq PR: wolfSSL/wolfssl#9632
This pull request introduces a new callback-based approach for TPM-based certificate and CSR signing, which is recommended for FIPS compliance and simplifies the signing process. The changes add a dedicated internal signing callback and supporting context structure, update the main CSR signing function to select between the new and legacy approaches based on the device ID, and provide thorough documentation for both methods.

Callback-based TPM signing enhancements:

  • Added wolfTPM2_SignCertCb, an internal callback that implements the wc_SignCertCb interface, enabling direct TPM-based signing for both RSA and ECC keys without relying on wolfCrypt crypto callbacks. This supports FIPS compliance and simplifies the code path.
  • Introduced CSR_MakeAndSign_Cb, a new internal function that generates and signs CSRs or self-signed certificates using the callback-based approach, leveraging the new signing callback for direct TPM operations.
  • Defined the TpmSignCbCtx structure in wolftpm/tpm2_wrap.h to hold TPM device and key references for use with the signing callback.

Main CSR signing function update:

  • Updated wolfTPM2_CSR_MakeAndSign_ex to select the callback-based signing approach when devId is INVALID_DEVID, and fall back to the legacy crypto callback method for backward compatibility. This includes logic to determine key type and set signature type appropriately. [1] [2]

Documentation improvements:

  • Added detailed comments in csr.c describing both the new callback-based and legacy crypto callback approaches for TPM certificate signing, including usage recommendations and instructions.

Testing
Setup:
TPM simulator: swtpm running on port 2321
Built wolfSSL with: --enable-certgen --enable-certreq --enable-certext --enable-cryptocb
Built wolfTPM with: --enable-swtpm --enable-certgen --enable-debug
Tests Run:
Generated RSA and ECC test keys in TPM
Created CSRs using ./examples/csr/csr
Validated CSRs with openssl req -text -noout
Results:
wc_SignCert_cb compiled into wolfSSL
wolfTPM2_SignCertCb and CSR_MakeAndSign_Cb compiled into wolfTPM
Generated valid RSA (1228 bytes) and ECC (696 bytes) CSRs
CSRs verified successfully with OpenSSL

@jackctj117 jackctj117 self-assigned this Jan 8, 2026
@jackctj117 jackctj117 marked this pull request as draft January 8, 2026 22:23
@jackctj117 jackctj117 marked this pull request as ready for review January 9, 2026 23:30
@jackctj117 jackctj117 requested a review from wolfSSL-Bot January 9, 2026 23:30
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.

1 participant