Skip to content

Add new WOLFTPM2_ECC_DEFAULT_CURVE#519

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:zd21780
Open

Add new WOLFTPM2_ECC_DEFAULT_CURVE#519
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:zd21780

Conversation

@dgarske
Copy link
Copy Markdown
Member

@dgarske dgarske commented Jun 3, 2026

Fixes ZD 21780

@dgarske dgarske self-assigned this Jun 3, 2026
Copilot AI review requested due to automatic review settings June 3, 2026 23:24
Copy link
Copy Markdown

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

Adds a configurable default ECC curve for wolfTPM wrapper key templates and centralizes curve→hash selection logic to keep name/scheme hashes consistent with the chosen curve (Fixes ZD 21780).

Changes:

  • Introduces TPM2_GetCurveHashAlg() to map TPM ECC curves to recommended digest algorithms based on curve size.
  • Adds WOLFTPM2_ECC_DEFAULT_CURVE build-time configuration and uses it to remap P-256 template requests to the configured default curve.
  • Replaces ad-hoc curve/hash selection in the crypto callback with the shared helper.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
wolftpm/tpm2.h Declares new TPM2_GetCurveHashAlg() public API.
wolftpm/tpm2_types.h Adds WOLFTPM2_ECC_DEFAULT_CURVE configuration macro and fallback logic.
src/tpm2.c Implements TPM2_GetCurveHashAlg() based on curve byte size.
src/tpm2_wrap.c Remaps P-256 template requests to the configured default curve and derives matching hashes.
src/tpm2_cryptocb.c Uses TPM2_GetCurveHashAlg() for ECDSA template hash selection.

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

Comment thread wolftpm/tpm2_types.h
Comment on lines +899 to +905
#ifndef WOLFTPM2_ECC_DEFAULT_CURVE
#if defined(NO_ECC256) && defined(HAVE_ECC384) && ECC_MIN_KEY_SZ <= 384
#define WOLFTPM2_ECC_DEFAULT_CURVE TPM_ECC_NIST_P384
#else
#define WOLFTPM2_ECC_DEFAULT_CURVE TPM_ECC_NIST_P256
#endif
#endif
Comment thread src/tpm2.c
Comment on lines +7037 to +7040
TPM_ALG_ID TPM2_GetCurveHashAlg(TPM_ECC_CURVE curveID)
{
int curveSz = TPM2_GetCurveSize(curveID);

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.

2 participants