2009-11-10 26 views
1

Le code suivant provient de l'émulateur TPM de Mario Strasser. La spécification dit,Cet émulateur TPM suit-il les spécifications TPM pour étendre le registre PCR?

PCR := SHA1(PCR || data) 

lit « concaténer l'ancienne valeur de la PCR avec les données, de hachage de la chaîne concaténée et stocker le hachage dans la PCR ». Ce n'est pas PCR := PCR BITWISE-OR SHA1(data) ni 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; 
} 

Répondre

1

AFAIK, oui. Voir mon commentaire en Perform OR on two hash outputs of sha1sum

+0

honnêtement, je ne sais pas ce que signifie l'état interne de hachage. Donc, fondamentalement, ce que je voulais faire dans http://stackoverflow.com/questions/1706999/perform-or-on-two-hash-outputs-of-sha1sum était incorrect. Merci d'avoir pointé – idazuwaika