title: Does this TPM emulator follow TPM spec for extending PCR register?
body: <p>The following code is from TPM emulator from Mario Strasser. The spec says, </p>
  
  <pre><code>PCR := SHA1(PCR || data) 
  </code></pre>
  
  <p>reads "concatenate the old value of PCR with the data, hash the concatenated string and store the hash in PCR". It's not <code>PCR := PCR BITWISE-OR SHA1(data)</code> nor <code>PCR := SHA1(PCR BITWISE-OR data)</code></p>
  
  <pre><code>TPM_RESULT TPM_Extend(TPM_PCRINDEX pcrNum, TPM_DIGEST *inDigest, 
                        TPM_PCRVALUE *outDigest)
  {
    tpm_sha1_ctx_t ctx;
  
    info("TPM_Extend()");
    if (pcrNum &gt;= TPM_NUM_PCR) return TPM_BADINDEX;
    if (!(PCR_ATTRIB[pcrNum].pcrExtendLocal &amp; (1 &lt;&lt; LOCALITY))) return TPM_BAD_LOCALITY;
    /* compute new PCR value as SHA-1(old PCR value || inDigest) */
    tpm_sha1_init(&amp;ctx);
    tpm_sha1_update(&amp;ctx, PCR_VALUE[pcrNum].digest, sizeof(PCR_VALUE[pcrNum].digest));
    tpm_sha1_update(&amp;ctx, inDigest-&gt;digest, sizeof(inDigest-&gt;digest));
    tpm_sha1_final(&amp;ctx, PCR_VALUE[pcrNum].digest);  
    /* set output digest */
    if (tpmData.permanent.flags.disable) {
      memset(outDigest-&gt;digest, 0, sizeof(*outDigest-&gt;digest));
    } else {
      memcpy(outDigest, &amp;PCR_VALUE[pcrNum], sizeof(TPM_PCRVALUE));
    }
    return TPM_SUCCESS;
  }
  </code></pre>