以下代码来自Mario Strasser的TPM emulator。说明书上说,

PCR := SHA1(PCR || data)

读取“将PCR的旧值与数据连接,对连接的字符串进行哈希并将哈希存储在PCR中”。不是PCR := PCR BITWISE-OR SHA1(data)也不是PCR := SHA1(PCR BITWISE-OR data)
TPM_RESULT TPM_Extend(TPM_PCRINDEX pcrNum, TPM_DIGEST *inDigest,
                      TPM_PCRVALUE *outDigest)
{
  tpm_sha1_ctx_t ctx;

  info("TPM_Extend()");
  if (pcrNum >= TPM_NUM_PCR) return TPM_BADINDEX;
  if (!(PCR_ATTRIB[pcrNum].pcrExtendLocal & (1 << LOCALITY))) return TPM_BAD_LOCALITY;
  /* compute new PCR value as SHA-1(old PCR value || inDigest) */
  tpm_sha1_init(&ctx);
  tpm_sha1_update(&ctx, PCR_VALUE[pcrNum].digest, sizeof(PCR_VALUE[pcrNum].digest));
  tpm_sha1_update(&ctx, inDigest->digest, sizeof(inDigest->digest));
  tpm_sha1_final(&ctx, PCR_VALUE[pcrNum].digest);
  /* set output digest */
  if (tpmData.permanent.flags.disable) {
    memset(outDigest->digest, 0, sizeof(*outDigest->digest));
  } else {
    memcpy(outDigest, &PCR_VALUE[pcrNum], sizeof(TPM_PCRVALUE));
  }
  return TPM_SUCCESS;
}

最佳答案

阿法克,是的。在Perform OR on two hash outputs of sha1sum中查看我的评论

关于c - 该TPM仿真器是否遵循TPM规范来扩展PCR寄存器?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1707369/

10-09 13:18