17 TPMI_ALG_HASH HashAlgo;
40 IN TPMI_ALG_HASH HashAlgo
45 for (Index = 0; Index <
sizeof (mHashInfo)/
sizeof (mHashInfo[0]); Index++) {
46 if (mHashInfo[Index].HashAlgo == HashAlgo) {
47 return mHashInfo[Index].HashSize;
64 IN TPMI_ALG_HASH HashAlgo
69 for (Index = 0; Index <
sizeof (mHashInfo)/
sizeof (mHashInfo[0]); Index++) {
70 if (mHashInfo[Index].HashAlgo == HashAlgo) {
71 return mHashInfo[Index].HashMask;
90 OUT UINT8 *AuthSessionOut
95 Buffer = (UINT8 *)AuthSessionOut;
100 if (AuthSessionIn !=
NULL) {
103 Buffer +=
sizeof (UINT32);
107 Buffer +=
sizeof (UINT16);
109 CopyMem (Buffer, AuthSessionIn->nonce.buffer, AuthSessionIn->nonce.size);
110 Buffer += AuthSessionIn->nonce.size;
113 *(UINT8 *)Buffer = *(UINT8 *)&AuthSessionIn->sessionAttributes;
118 Buffer +=
sizeof (UINT16);
120 CopyMem (Buffer, AuthSessionIn->hmac.buffer, AuthSessionIn->hmac.size);
121 Buffer += AuthSessionIn->hmac.size;
125 Buffer +=
sizeof (UINT32);
129 Buffer +=
sizeof (UINT16);
132 *(UINT8 *)Buffer = 0x00;
137 Buffer +=
sizeof (UINT16);
140 return (UINT32)((
UINTN)Buffer - (
UINTN)AuthSessionOut);
155 IN UINT8 *AuthSessionIn,
162 if (AuthSessionOut ==
NULL) {
163 AuthSessionOut = &LocalAuthSessionOut;
166 Buffer = (UINT8 *)AuthSessionIn;
170 Buffer +=
sizeof (UINT16);
171 if (AuthSessionOut->nonce.size > sizeof (
TPMU_HA)) {
172 DEBUG ((DEBUG_ERROR,
"CopyAuthSessionResponse - nonce.size error %x\n", AuthSessionOut->nonce.size));
176 CopyMem (AuthSessionOut->nonce.buffer, Buffer, AuthSessionOut->nonce.size);
177 Buffer += AuthSessionOut->nonce.size;
180 *(UINT8 *) &AuthSessionOut->sessionAttributes = *(UINT8 *)Buffer;
185 Buffer +=
sizeof (UINT16);
186 if (AuthSessionOut->hmac.size > sizeof (
TPMU_HA)) {
187 DEBUG ((DEBUG_ERROR,
"CopyAuthSessionResponse - hmac.size error %x\n", AuthSessionOut->hmac.size));
191 CopyMem (AuthSessionOut->hmac.buffer, Buffer, AuthSessionOut->hmac.size);
192 Buffer += AuthSessionOut->hmac.size;
194 return (UINT32)((
UINTN)Buffer - (
UINTN)AuthSessionIn);
209 IN TPMI_ALG_HASH HashAlg,
210 IN UINT32 HashAlgorithmMask
215 if ((HashAlgorithmMask & HASH_ALG_SHA1) != 0) {
221 if ((HashAlgorithmMask & HASH_ALG_SHA256) != 0) {
227 if ((HashAlgorithmMask & HASH_ALG_SHA384) != 0) {
233 if ((HashAlgorithmMask & HASH_ALG_SHA512) != 0) {
238 case TPM_ALG_SM3_256:
239 if ((HashAlgorithmMask & HASH_ALG_SM3_256) != 0) {
263 IN UINT32 HashAlgorithmMask
268 UINT32 DigestListCount;
269 UINT32 *DigestListCountPtr;
271 DigestListCountPtr = (UINT32 *)Buffer;
273 Buffer = (UINT8 *)Buffer +
sizeof (DigestList->count);
274 for (Index = 0; Index < DigestList->count; Index++) {
276 DEBUG ((DEBUG_ERROR,
"WARNING: TPM2 Event log has HashAlg unsupported by PCR bank (0x%x)\n", DigestList->digests[Index].hashAlg));
280 CopyMem (Buffer, &DigestList->digests[Index].hashAlg, sizeof (DigestList->digests[Index].hashAlg));
281 Buffer = (UINT8 *)Buffer +
sizeof (DigestList->digests[Index].hashAlg);
283 CopyMem (Buffer, &DigestList->digests[Index].digest, DigestSize);
284 Buffer = (UINT8 *)Buffer + DigestSize;
310 TotalSize =
sizeof (DigestList->count);
311 for (Index = 0; Index < DigestList->count; Index++) {
313 TotalSize +=
sizeof (DigestList->digests[Index].hashAlg) + DigestSize;
332 IN TPMI_ALG_HASH HashAlg,
341 for (Index = 0; Index < DigestList->count; Index++) {
342 if (DigestList->digests[Index].hashAlg == HashAlg) {
345 &DigestList->digests[Index].digest,
352 return EFI_NOT_FOUND;
#define SM3_256_DIGEST_SIZE
#define SHA512_DIGEST_SIZE
#define SHA256_DIGEST_SIZE
#define SHA384_DIGEST_SIZE
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
UINT16 EFIAPI ReadUnaligned16(IN CONST UINT16 *Buffer)
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
UINT32 EFIAPI WriteUnaligned32(OUT UINT32 *Buffer, IN UINT32 Value)
UINT16 EFIAPI WriteUnaligned16(OUT UINT16 *Buffer, IN UINT16 Value)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define DEBUG(Expression)
UINT16 EFIAPI GetHashSizeFromAlgo(IN TPMI_ALG_HASH HashAlgo)
UINT32 EFIAPI GetHashMaskFromAlgo(IN TPMI_ALG_HASH HashAlgo)
BOOLEAN EFIAPI IsHashAlgSupportedInHashAlgorithmMask(IN TPMI_ALG_HASH HashAlg, IN UINT32 HashAlgorithmMask)
UINT32 EFIAPI CopyAuthSessionResponse(IN UINT8 *AuthSessionIn, OUT TPMS_AUTH_RESPONSE *AuthSessionOut OPTIONAL)
VOID *EFIAPI CopyDigestListToBuffer(IN OUT VOID *Buffer, IN TPML_DIGEST_VALUES *DigestList, IN UINT32 HashAlgorithmMask)
UINT32 EFIAPI CopyAuthSessionCommand(IN TPMS_AUTH_COMMAND *AuthSessionIn OPTIONAL, OUT UINT8 *AuthSessionOut)
UINT32 EFIAPI GetDigestListSize(IN TPML_DIGEST_VALUES *DigestList)
EFI_STATUS EFIAPI GetDigestFromDigestList(IN TPMI_ALG_HASH HashAlg, IN TPML_DIGEST_VALUES *DigestList, OUT VOID *Digest)