Add new WOLFTPM2_ECC_DEFAULT_CURVE#519
Open
dgarske wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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_CURVEbuild-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 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 on lines
+7037
to
+7040
| TPM_ALG_ID TPM2_GetCurveHashAlg(TPM_ECC_CURVE curveID) | ||
| { | ||
| int curveSz = TPM2_GetCurveSize(curveID); | ||
|
|
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.
Fixes ZD 21780