From 0438c54c9b28d8310dd7812310cb890ae7a9adba Mon Sep 17 00:00:00 2001 From: Marco Oliverio Date: Thu, 18 Jun 2026 10:45:57 +0200 Subject: [PATCH] tpm: rename masterPassword param to authOverride --- docs/TPM.md | 2 +- include/tpm.h | 11 +++++++---- src/tpm.c | 18 +++++++++--------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/docs/TPM.md b/docs/TPM.md index 739562dd..c25b2795 100644 --- a/docs/TPM.md +++ b/docs/TPM.md @@ -33,7 +33,7 @@ keys. There are two ways to supply the required `authValue`: provisioned). Per-device values are computed off-device at provisioning (`SHA-256(CPSN || master)`, low 16 bytes) and baked in via `WOLFBOOT_TPM_MFG_AIK_AUTH` / `WOLFBOOT_TPM_MFG_EH_AUTH`. When `WOLFBOOT_TPM_MFG_AUTH_DERIVE` - is not enabled, the `masterPassword` argument to `wolfBoot_tpm2_get_aik()` is + is not enabled, the `authOverride` argument to `wolfBoot_tpm2_get_aik()` is treated as an optional override for the final AIK `authValue` (not a master secret). - **Derive mode (`WOLFBOOT_TPM_MFG_AUTH_DERIVE`).** The `authValue` is computed diff --git a/include/tpm.h b/include/tpm.h index 3a609dd8..7802f734 100644 --- a/include/tpm.h +++ b/include/tpm.h @@ -64,11 +64,11 @@ int CSME_NSE_API wolfBoot_tpm2_read_cert(uint32_t handle, uint8_t* cert, uint32_ /* MFG identity auth provisioning. * Precomputed mode (default): the final per-device authValue is set directly, * no master secret on the device. In this mode, wolfBoot_tpm2_get_aik() treats - * the masterPassword argument as an optional *authValue* override. + * the authOverride argument as an optional *authValue* override. * Derive mode (WOLFBOOT_TPM_MFG_AUTH_DERIVE): authValue = low 16 bytes of * SHA-256(TPM serial || master); the master is shared across the reel. - * For wolfBoot_tpm2_get_aik() the master password is provided via the - * masterPassword argument (NULL = sample). */ + * For wolfBoot_tpm2_get_aik() the master secret is provided via the + * authOverride argument (NULL = sample). */ #ifdef WOLFBOOT_TPM_MFG_AUTH_DERIVE /* EH master for derive mode (sample - override in production) */ #ifndef WOLFBOOT_TPM_MFG_EH_MASTER @@ -91,8 +91,11 @@ int CSME_NSE_API wolfBoot_tpm2_read_cert(uint32_t handle, uint8_t* cert, uint32_ #endif #endif +/* authOverride meaning depends on WOLFBOOT_TPM_MFG_AUTH_DERIVE: + * derive mode -> master secret hashed into the authValue (NULL = sample) + * precomputed mode -> optional literal authValue override (NULL = built-in) */ int CSME_NSE_API wolfBoot_tpm2_get_aik(WOLFTPM2_KEY* aik, - uint8_t* masterPassword, uint16_t masterPasswordSz); + uint8_t* authOverride, uint16_t authOverrideSz); int CSME_NSE_API wolfBoot_tpm2_get_timestamp(WOLFTPM2_KEY* aik, GetTime_Out* getTime); int CSME_NSE_API wolfBoot_tpm2_quote(WOLFTPM2_KEY* aik, byte* pcrArray, word32 pcrArraySz, Quote_Out* quoteResult); diff --git a/src/tpm.c b/src/tpm.c index 61863371..efb783f8 100644 --- a/src/tpm.c +++ b/src/tpm.c @@ -1360,7 +1360,7 @@ static int wolfBoot_tpm2_set_handle_auth(WOLFTPM2_HANDLE* handle, #endif int CSME_NSE_API wolfBoot_tpm2_get_aik(WOLFTPM2_KEY* aik, - uint8_t* masterPassword, uint16_t masterPasswordSz) + uint8_t* authOverride, uint16_t authOverrideSz) { int rc; if (aik == NULL) { @@ -1369,8 +1369,8 @@ int CSME_NSE_API wolfBoot_tpm2_get_aik(WOLFTPM2_KEY* aik, if (WOLFBOOT_TPM_NS_RW(aik, sizeof(*aik)) == NULL) { return BAD_FUNC_ARG; } - if (masterPassword != NULL && - WOLFBOOT_TPM_NS_R(masterPassword, masterPasswordSz) == NULL) { + if (authOverride != NULL && + WOLFBOOT_TPM_NS_R(authOverride, authOverrideSz) == NULL) { return BAD_FUNC_ARG; } @@ -1380,17 +1380,17 @@ int CSME_NSE_API wolfBoot_tpm2_get_aik(WOLFTPM2_KEY* aik, #ifdef WOLFBOOT_TPM_MFG_AUTH_DERIVE /* Derives the authValue on-device from a master secret shared across the * reel; the precomputed default is preferred. Supply NULL for - * masterPassword to use the sample default. */ + * authOverride to use the sample default. */ rc = wolfTPM2_SetIdentityAuth(&wolftpm_dev, &aik->handle, - masterPassword, masterPasswordSz); + authOverride, authOverrideSz); #else /* Precomputed (default): set the final per-device authValue directly (no * master secret on device). Caller may override the default via - * masterPassword. */ + * authOverride. */ static const uint8_t aikAuth[] = WOLFBOOT_TPM_MFG_AIK_AUTH; - const uint8_t* auth = (masterPassword != NULL) ? masterPassword : aikAuth; - uint16_t authSz = (masterPassword != NULL) ? - masterPasswordSz : (uint16_t)sizeof(aikAuth); + const uint8_t* auth = (authOverride != NULL) ? authOverride : aikAuth; + uint16_t authSz = (authOverride != NULL) ? + authOverrideSz : (uint16_t)sizeof(aikAuth); rc = wolfBoot_tpm2_set_handle_auth(&aik->handle, auth, authSz); #endif }