F-9768: rot: scrub NV auth and session state at exit

The TPM NV auth copy and the HMAC session state lived on the
stack until process teardown. Zeroize both at the common exit
label after the TPM device is unloaded, on success and error
paths alike.
pull/892/head
Daniele Lacamera 2026-09-15 15:21:54 +02:00
parent 483facf339
commit b97d94deeb
1 changed files with 5 additions and 0 deletions

View File

@ -204,6 +204,11 @@ exit:
wolfTPM2_UnloadHandle(&dev, &tpmSession.handle);
wolfTPM2_Cleanup(&dev);
/* Scrub the NV auth copy and the session state from the stack on
* every exit path. */
wc_ForceZero(&nv, sizeof(nv));
wc_ForceZero(&tpmSession, sizeof(tpmSession));
return rc;
}