F-11916 - Use a constant-time compare for the primary key cache lookup

pull/604/head
Aidan Garske 2026-09-10 11:34:25 -07:00
parent 651a35f2a5
commit ed95d45f64
1 changed files with 2 additions and 2 deletions

View File

@ -3565,8 +3565,8 @@ static TPM_RC FwCmd_CreatePrimary(FWTPM_CTX* ctx, TPM2_Packet* cmd,
for (cacheIdx = 0; cacheIdx < FWTPM_MAX_PRIMARY_CACHE; cacheIdx++) {
if (ctx->primaryCache[cacheIdx].used &&
ctx->primaryCache[cacheIdx].hierarchy == primaryHandle &&
XMEMCMP(ctx->primaryCache[cacheIdx].templateHash, templateHash,
WC_SHA256_DIGEST_SIZE) == 0) {
TPM2_ConstantCompare(ctx->primaryCache[cacheIdx].templateHash,
templateHash, WC_SHA256_DIGEST_SIZE) == 0) {
cached = &ctx->primaryCache[cacheIdx];
break;
}