36#define SEV_HASH_TABLE_GUID \
37 (GUID) { 0x9438d606, 0x4f22, 0x4cc9, { 0xb4, 0x79, 0xa7, 0x93, 0xd4, 0x11, 0xfd, 0x21 } }
38#define SEV_KERNEL_HASH_GUID \
39 (GUID) { 0x4de79437, 0xabd2, 0x427f, { 0xb8, 0x35, 0xd5, 0xb1, 0x72, 0xd2, 0x04, 0x5b } }
40#define SEV_INITRD_HASH_GUID \
41 (GUID) { 0x44baf731, 0x3a2f, 0x4bd7, { 0x9a, 0xf1, 0x41, 0xe2, 0x91, 0x69, 0x78, 0x1d } }
42#define SEV_CMDLINE_HASH_GUID \
43 (GUID) { 0x97d02dd8, 0xbd20, 0x4c94, { 0xaa, 0x78, 0xe7, 0x71, 0x4d, 0x36, 0xab, 0x2a } }
58STATIC UINT16 mHashesTableSize;
66 if (
StrCmp (BlobName, L
"kernel") == 0) {
67 return &mSevKernelHashGuid;
68 }
else if (
StrCmp (BlobName, L
"initrd") == 0) {
69 return &mSevInitrdHashGuid;
70 }
else if (
StrCmp (BlobName, L
"cmdline") == 0) {
71 return &mSevCmdlineHashGuid;
109 if (EFI_ERROR (FetchStatus)) {
112 "%a: Fetching blob failed.\n",
119 if ((mHashesTable ==
NULL) || (mHashesTableSize == 0)) {
122 "%a: Verifier called but no hashes table discoverd in MEMFD\n",
125 return EFI_ACCESS_DENIED;
128 Guid = FindBlobEntryGuid (BlobName);
132 "%a: Unknown blob name \"%s\"\n",
144 for (Entry = mHashesTable, Remaining = mHashesTableSize;
145 Remaining >=
sizeof *Entry && Remaining >= Entry->Len;
146 Remaining -= Entry->Len,
147 Entry = (
HASH_TABLE *)((UINT8 *)Entry + Entry->Len))
157 DEBUG ((DEBUG_INFO,
"%a: Found GUID %g in table\n", __func__, Guid));
159 EntrySize = Entry->Len -
sizeof Entry->Guid -
sizeof Entry->Len;
163 "%a: Hash has the wrong size %d != %d\n",
168 return EFI_ACCESS_DENIED;
177 if (
CompareMem (Entry->Data, Hash, EntrySize) == 0) {
181 "%a: Hash comparison succeeded for \"%s\"\n",
186 Status = EFI_ACCESS_DENIED;
189 "%a: Hash comparison failed for \"%s\"\n",
206 "%a: Hash GUID %g not found in table\n",
232 mHashesTableSize = 0;
237 if ((Ptr ==
NULL) || (Size <
sizeof *Ptr) ||
239 (Ptr->Len <
sizeof *Ptr) || (Ptr->Len > Size))
246 "%a: Found injected hashes table in secure location\n",
251 mHashesTableSize = Ptr->Len -
sizeof Ptr->Guid -
sizeof Ptr->Len;
255 "%a: mHashesTable=0x%p, Size=%u\n",
#define SHA256_DIGEST_SIZE
BOOLEAN EFIAPI Sha256HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
VOID EFIAPI CpuDeadLoop(VOID)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
#define SEV_HASH_TABLE_GUID
EFI_STATUS EFIAPI VerifyBlob(IN CONST CHAR16 *BlobName, IN CONST VOID *Buf, IN UINT32 BufSize, IN EFI_STATUS FetchStatus)
RETURN_STATUS EFIAPI BlobVerifierLibSevHashesConstructor(VOID)
#define DEBUG(Expression)
#define FixedPcdGet32(TokenName)
#define FixedPcdGet64(TokenName)