Home | History | Annotate | Download | only in tpm2

Lines Matching refs:pcr

12 //      The initial value of PCR attributes. The value of these fields should be consistent with PC Client
13 // specification In this implementation, we assume the total number of implemented PCR is 24.
17 // PCR 0 - 15, static RTM
22 {0, 0x0F, 0x1F}, // PCR 16, Debug
23 {0, 0x10, 0x1C}, // PCR 17, Locality 4
24 {0, 0x10, 0x1C}, // PCR 18, Locality 3
25 {0, 0x10, 0x0C}, // PCR 19, Locality 2
26 {0, 0x1C, 0x0E}, // PCR 20, Locality 1
27 {0, 0x1C, 0x04}, // PCR 21, Dynamic OS
28 {0, 0x1C, 0x04}, // PCR 22, Dynamic OS
29 {0, 0x0F, 0x1F}, // PCR 23, App specific
30 {0, 0x0F, 0x1F} // PCR 24, testing policy
38 // This function indicates if a PCR belongs to a group that requires an authValue in order to modify the
39 // PCR. If it does, groupIndex is set to value of the group index. This feature of PCR is decided by the
44 // TRUE: PCR belongs an auth group
45 // FALSE: PCR does not belong an auth group
49 TPMI_DH_PCR handle, // IN: handle of PCR
50 UINT32 *groupIndex // OUT: group index if PCR belongs a
51 // group that allows authValue. If PCR
58 // Table 4 "PCR Attributes" of the "TCG PC Client Platform TPM Profile (TPT)
66 // This function indicates if a PCR belongs to a group that requires a policy authorization in order to modify
67 // the PCR. If it does, groupIndex is set to value of the group index. This feature of PCR is decided by the
77 // TRUE: PCR belongs a policy group
78 // FALSE: PCR does not belong a policy group
82 TPMI_DH_PCR handle, // IN: handle of PCR
83 UINT32 *groupIndex // OUT: group index if PCR belongs a group that
84 // allows policy. If PCR does not belong to
90 // "PCR Attributes" of the "TCG PC Client Platform TPM Profile (TPT)
98 // This function indicates if a PCR belongs to the TCB group.
102 // TRUE: PCR belongs to TCB group
103 // FALSE: PCR does not belong to TCB group
107 TPMI_DH_PCR handle // IN: handle of PCR
111 // Platform specification decides if a PCR belongs to a TCB group. In this
112 // implementation, we assume PCR[16, 21-23] belong to TCB group as defined
124 // This function indicates if a policy is available for a PCR.
131 // TRUE the PCR should be authorized by policy
132 // FALSE the PCR does not allow policy
136 TPMI_DH_PCR handle // IN: PCR handle
146 // This function is used to access the authValue of a PCR. If PCR does not belong to an authValue group,
151 TPMI_DH_PCR handle, // IN: PCR handle
152 TPM2B_AUTH *auth // OUT: authValue of PCR
170 // This function is used to access the authorization policy of a PCR. It sets policy to the authorization policy
171 // and returns the hash algorithm for policy If the PCR does not allow a policy, TPM_ALG_NULL is returned.
175 TPMI_DH_PCR handle, // IN: PCR handle
176 TPM2B_DIGEST *policy // OUT: policy of PCR
213 // We need to give an initial configuration on allocated PCR before
236 // This function returns the address of an array of state saved PCR based on the hash algorithm.
241 // not NULL pointer to the 0th byte of the 0th PCR
246 UINT32 pcrIndex // IN: PCR index in PCR_SAVE
285 // This function indicates if a PCR number for the particular hash algorithm is allocated.
289 // FALSE PCR is not allocated
290 // TRUE PCR is allocated
294 UINT32 pcr, // IN: The number of the PCR
295 TPMI_ALG_HASH hashAlg // IN: The PCR algorithm
300 if(pcr < IMPLEMENTATION_PCR)
306 if(((gp.pcrAllocated.pcrSelections[i].pcrSelect[pcr/8])
307 & (1 << (pcr % 8))) != 0)
322 // This function returns the address of an array of PCR based on the hash algorithm.
327 // not NULL pointer to the 0th byte of the 0th PCR
332 UINT32 pcrNumber // IN: PCR number
335 static BYTE *pcr = NULL;
342 pcr = s_pcrs[pcrNumber].sha1Pcr;
347 pcr = s_pcrs[pcrNumber].sha256Pcr;
352 pcr = s_pcrs[pcrNumber].sha384Pcr;
357 pcr = s_pcrs[pcrNumber].sha512Pcr;
362 pcr = s_pcrs[pcrNumber].sm3_256Pcr;
369 return pcr;
376 // This function indicates if an indicated PCR number is selected by the bit map in selection.
380 // FALSE PCR is not selected
381 // TRUE PCR is selected
385 UINT32 pcr, // IN: The number of the PCR
390 if( pcr < IMPLEMENTATION_PCR
391 && ((selection->pcrSelect[pcr/8]) & (1 << (pcr % 8))) != 0)
399 // This function modifies a PCR selection array based on the implemented PCR.
403 TPMS_PCR_SELECTION *selection // IN: input PCR selection
408 // If size of select is less than PCR_SELECT_MAX, zero the unspecified PCR
440 const TPMI_DH_PCR pcrHandle, // IN: the index of the PCR to be
443 const TPM2B_DIGEST *digest // IN: the digest to modify the PCR
449 // Rest the PCR to zeros
451 // if the TPM has not started, then set the PCR to 0...04 and then extend
464 // This function initializes the PCR subsystem at TPM2_Startup().
472 UINT32 pcr, j;
477 // PCR generation counter is cleared at TPM_RESET and TPM_RESTART
480 // Initialize/Restore PCR values
481 for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)
483 // On resume, need to know if this PCR had its state saved or not
485 (type == SU_RESUME && s_initAttributes[pcr].stateSave == SET) ? 1 : 0;
486 // If this is the H-CRTM PCR and we are not doing a resume and we
487 // had an H-CRTM event, then we don't change this PCR
488 if(pcr == HCRTM_PCR && type != SU_RESUME && g_DrtmPreStartup == TRUE)
494 BYTE *pcrData = GetPcrPointer(hash, pcr);
501 // Restore saved PCR value
509 // PCR was not restored by state save
511 PCR is 4, then
514 if((s_initAttributes[pcr].resetLocality & 0x10) != 0)
519 if(pcr == HCRTM_PCR)
540 // This function is used to save the PCR values that will be restored on TPM Resume.
547 UINT32 pcr, j;
552 // Copy PCR values to the structure that should be saved to NV
553 for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)
555 UINT32 stateSaved = (s_initAttributes[pcr].stateSave == SET) ? 1 : 0;
561 pcrData = GetPcrPointer(gp.pcrAllocated.pcrSelections[j].hash, pcr);
568 // Restore saved PCR value
585 // This function indicates if the selected PCR is a PCR that is state saved on TPM2_Shutdown(STATE). The
586 // return value is based on PCR attributes.
590 // TRUE PCR is state saved
591 // FALSE PCR is not state saved
595 TPMI_DH_PCR handle // IN: PCR handle to be extended
598 UINT32 pcr = handle - PCR_FIRST;
599 if(s_initAttributes[pcr].stateSave == SET)
609 // This function indicates if a PCR may be reset by the current command locality. The return value is based
610 // on PCR attributes, and not the PCR allocation.
619 TPMI_DH_PCR handle // IN: PCR handle to be extended
624 UINT32 pcr = handle - PCR_FIRST;
633 if((localityBits & s_initAttributes[pcr].resetLocality) == 0)
642 // This function checks a PCR handle to see if the attributes for the PCR are set so that any change to the
643 // PCR causes an increment of the pcrCounter. If it does, then the function increments the counter.
647 TPM_HANDLE pcrHandle // IN: the handle of the PCR that changed.
651 // increment is a change to a PCR in the TCB group.
659 // This function indicates a PCR may be extended at the current command locality. The return value is
660 // based on PCR attributes, and not the PCR allocation.
672 TPMI_DH_PCR handle // IN: PCR handle to be extended
677 UINT32 pcr = handle - PCR_FIRST;
681 if((localityBits & s_initAttributes[pcr].extendLocality) == 0)
690 // This function is used to extend a PCR in a specific bank.
694 TPMI_DH_PCR handle, // IN: PCR handle to be extended
695 TPMI_ALG_HASH hash, // IN: hash algorithm of PCR
700 UINT32 pcr = handle - PCR_FIRST;
704 pcrData = GetPcrPointer(hash, pcr);
705 // Extend PCR if it is allocated
713 // If PCR does not belong to TCB group, increment PCR counter
724 // This function computes the digest of the selected PCR.
725 // As a side-effect, selection is modified so that only the implemented PCR will have their bits still set.
730 TPML_PCR_SELECTION *selection, // IN/OUT: PCR selection (filtered on
739 UINT32 pcr;
744 // Iterate through the list of PCR selection structures
749 FilterPcr(select); // Clear out the bits for unimplemented PCR
753 for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)
755 if(IsPcrSelected(pcr, select)) // Is this PCR selected
758 pcrData = GetPcrPointer(selection->pcrSelections[i].hash, pcr);
772 // This function is used to read a list of selected PCR. If the requested PCR number exceeds the maximum
773 // number that can be output, the selection is adjusted to reflect the actual output PCR.
777 TPML_PCR_SELECTION *selection, // IN/OUT: PCR selection (filtered on
780 UINT32 *pcrCounter // OUT: the current value of PCR generation
786 UINT32 pcr;
789 // Iterate through the list of PCR selection structures
794 FilterPcr(select); // Clear out the bits for unimplemented PCR
796 for (pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)
798 if(IsPcrSelected(pcr, select)) // Is this PCR selected
804 while( pcr < IMPLEMENTATION_PCR
806 && (pcr / 8) < select->sizeofSelect)
809 select->pcrSelect[pcr/8] &= (BYTE) ~(1 << (pcr % 8));
810 pcr++;
819 pcrData = GetPcrPointer(selection->pcrSelections[i].hash, pcr);
830 if(digest->count > 7 && pcr < IMPLEMENTATION_PCR)
850 // This function is used by _TPM_Hash_End() to set a PCR to the computed hash of the H-CRTM event.
854 TPMI_DH_PCR handle, // IN: PCR handle to be extended
855 TPMI_ALG_HASH hash, // IN: hash algorithm of PCR
859 UINT32 pcr = handle - PCR_FIRST;
861 // Copy value to the PCR if it is allocated
862 pcrData = GetPcrPointer(hash, pcr);
873 // This function is used to change the PCR allocation.
884 UINT32 *maxPCR, // OUT: Maximum number of PCR
891 // Initialize the flags to indicate if HCRTM PCR and DRTM PCR are allocated.
894 // Create the expected new PCR allocation based on the existing allocation
896 // 1. if a PCR bank does not appear in the new allocation, the existing
897 // allocation of this PCR bank will be preserved.
898 // 2. if a PCR bank appears multiple times in the new allocation, only the
907 // The assumption is the initial PCR allocation (from manufacture)
921 // Max PCR in a bank is MIN(implemented PCR, PCR with attributes defined)
932 // Make sure that we end up with at least one DRTM PCR
935 #else // if DRTM PCR is not required, indicate that the allocation is OK
939 // and one HCRTM PCR (since this is usually PCR 0...)
959 // allocate PCR. Different implementation may return a sizeAvailable less
963 // PCR
973 // This function is used to set the designated PCR in all banks to an initial value. The initial value is signed
974 // and will be sign extended into the entire PCR.
978 TPM_HANDLE handle, // IN: the handle of the PCR to set
983 UINT32 pcr = handle - PCR_FIRST;
987 // Iterate supported PCR bank algorithms to reset
995 pcrData = GetPcrPointer(gp.pcrAllocated.pcrSelections[i].hash, pcr);
996 // If the PCR is allocated
1015 // This function is used to reset a dynamic PCR to 0. This function is used in DRTM sequence.
1022 UINT32 pcr, i;
1023 // Initialize PCR values
1024 for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)
1031 pcrData = GetPcrPointer(gp.pcrAllocated.pcrSelections[i].hash, pcr);
1036 // Reset PCR
1037 // Any PCR can be reset by locality 4 should be reset to 0
1038 if((s_initAttributes[pcr].resetLocality & 0x10) != 0)
1049 // This function is used to get the current allocation of PCR banks.
1059 TPML_PCR_SELECTION *pcrSelection // OUT: PCR allocation list
1081 UINT32 pcr, // IN: PCR number
1085 bitmap[pcr / 8] |= (1 << (pcr % 8));
1092 // This function returns the selected PCR property.
1105 UINT32 pcr;
1108 // Always set the bitmap to be the size of all PCR
1113 for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)
1118 if(s_initAttributes[pcr].stateSave == SET)
1119 PCRSetSelectBit(pcr, select->pcrSelect);
1122 if((s_initAttributes[pcr].extendLocality & 0x01) != 0)
1123 PCRSetSelectBit(pcr, select->pcrSelect);
1126 if((s_initAttributes[pcr].resetLocality & 0x01) != 0)
1127 PCRSetSelectBit(pcr, select->pcrSelect);
1130 if((s_initAttributes[pcr].extendLocality & 0x02) != 0)
1131 PCRSetSelectBit(pcr, select->pcrSelect);
1134 if((s_initAttributes[pcr].resetLocality & 0x02) != 0)
1135 PCRSetSelectBit(pcr, select->pcrSelect);
1138 if((s_initAttributes[pcr].extendLocality & 0x04) != 0)
1139 PCRSetSelectBit(pcr, select->pcrSelect);
1143 if((s_initAttributes[pcr].resetLocality & 0x04) != 0)
1144 PCRSetSelectBit(pcr, select->pcrSelect);
1147 if((s_initAttributes[pcr].extendLocality & 0x08) != 0)
1148 PCRSetSelectBit(pcr, select->pcrSelect);
1151 if((s_initAttributes[pcr].resetLocality & 0x08) != 0)
1152 PCRSetSelectBit(pcr, select->pcrSelect);
1155 if((s_initAttributes[pcr].extendLocality & 0x10) != 0)
1156 PCRSetSelectBit(pcr, select->pcrSelect);
1159 if((s_initAttributes[pcr].resetLocality & 0x10) != 0)
1160 PCRSetSelectBit(pcr, select->pcrSelect);
1163 // DRTM reset PCRs are the PCR reset by locality 4
1164 if((s_initAttributes[pcr].resetLocality & 0x10) != 0)
1165 PCRSetSelectBit(pcr, select->pcrSelect);
1169 if(PCRBelongsPolicyGroup(pcr + PCR_FIRST, &groupIndex))
1170 PCRSetSelectBit(pcr, select->pcrSelect);
1175 if(PCRBelongsAuthGroup(pcr + PCR_FIRST, &groupIndex))
1176 PCRSetSelectBit(pcr, select->pcrSelect);
1181 if(PCRBelongsTCBGroup(pcr + PCR_FIRST))
1182 PCRSetSelectBit(pcr, select->pcrSelect);
1186 // If property is not supported, stop scanning PCR attributes
1198 // This function returns a list of PCR properties starting at property.
1210 TPM_PT_PCR property, // IN: the starting PCR property
1212 TPML_TAGGED_PCR_PROPERTY *select // OUT: PCR select
1224 // Iterate PCR properties. TPM_PT_PCR_LAST is the index of the last property
1249 // This function is used to get a list of handles of PCR, started from handle. If handle exceeds the maximum
1250 // PCR handle range, an empty list will be returned and the return value will be NO.
1271 // Iterate PCR handle range
1276 // If we have not filled up the return list, add this PCR
1283 // If the return list is full but we still have PCR handle