29#include <Protocol/VariablePolicy.h>
30#include <Library/VariablePolicyLib.h>
32#define SHA_DIGEST_SIZE_MAX SHA512_DIGEST_SIZE
92 IN OUT VOID *HashContext,
122 IN OUT VOID *HashContext,
140CONST UINT8 mRsaE[] = { 0x01, 0x00, 0x01 };
142UINT8 mSha256OidValue[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01 };
143UINT8 mSha384OidValue[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02 };
144UINT8 mSha512OidValue[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03 };
192 IN CHAR16 *VariableName,
201 ZeroMem (&AuthVariableInfo,
sizeof (AuthVariableInfo));
202 Status = mAuthVarLibContextIn->FindVariable (
207 *Data = AuthVariableInfo.Data;
208 *DataSize = AuthVariableInfo.DataSize;
229 IN CHAR16 *VariableName,
238 ZeroMem (&AuthVariableInfo,
sizeof (AuthVariableInfo));
239 AuthVariableInfo.VariableName = VariableName;
240 AuthVariableInfo.VendorGuid = VendorGuid;
241 AuthVariableInfo.Data = Data;
242 AuthVariableInfo.DataSize = DataSize;
243 AuthVariableInfo.Attributes = Attributes;
245 return mAuthVarLibContextIn->UpdateVariable (
268 IN CHAR16 *VariableName,
272 IN UINT32 Attributes,
291 if (!EFI_ERROR (FindStatus) && ((Attributes & EFI_VARIABLE_APPEND_WRITE) != 0)) {
292 if ((
CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) &&
310 ZeroMem (&AuthVariableInfo,
sizeof (AuthVariableInfo));
311 AuthVariableInfo.VariableName = VariableName;
312 AuthVariableInfo.VendorGuid = VendorGuid;
313 AuthVariableInfo.Data = Data;
314 AuthVariableInfo.DataSize = DataSize;
315 AuthVariableInfo.Attributes = Attributes;
316 AuthVariableInfo.TimeStamp = TimeStamp;
317 return mAuthVarLibContextIn->UpdateVariable (
334 IN CHAR16 *VariableName,
339 if (IsVariablePolicyEnabled ()) {
367 if (!EFI_ERROR (Status) && (*(UINT8 *)Data == CUSTOM_SECURE_BOOT_MODE)) {
391 UINT8 SecureBootMode;
392 UINT8 SecureBootEnable;
393 UINTN VariableDataSize;
397 &gEfiGlobalVariableGuid,
401 if (EFI_ERROR (Status)) {
409 mPlatformMode = (UINT8)Mode;
410 CopyMem (Data, &mPlatformMode,
sizeof (UINT8));
412 if (mAuthVarLibContextIn->AtRuntime ()) {
428 &gEfiGlobalVariableGuid,
437 if (EFI_ERROR (Status)) {
438 SecureBootMode = SECURE_BOOT_MODE_DISABLE;
440 if (mPlatformMode == USER_MODE) {
441 SecureBootMode = SECURE_BOOT_MODE_ENABLE;
442 }
else if (mPlatformMode == SETUP_MODE) {
443 SecureBootMode = SECURE_BOOT_MODE_DISABLE;
445 return EFI_NOT_FOUND;
451 &gEfiGlobalVariableGuid,
454 EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS
456 if (EFI_ERROR (Status)) {
465 &gEfiSecureBootEnableDisableGuid,
470 if (SecureBootMode == SECURE_BOOT_MODE_ENABLE) {
474 SecureBootEnable = SECURE_BOOT_ENABLE;
475 VariableDataSize =
sizeof (SecureBootEnable);
481 if (EFI_ERROR (Status)) {
485 SecureBootEnable = SECURE_BOOT_DISABLE;
486 VariableDataSize = 0;
491 &gEfiSecureBootEnableDisableGuid,
513 IN CHAR16 *VariableName,
532 ASSERT (VariableName !=
NULL && VendorGuid !=
NULL && Data !=
NULL);
537 (
CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) &&
548 SigDataSize = DataSize;
556 for (Index = 0; Index < (
sizeof (mSupportSigItem) /
sizeof (
EFI_SIGNATURE_ITEM)); Index++ ) {
562 if ((mSupportSigItem[Index].SigDataSize != ((UINT32) ~0)) &&
565 return EFI_INVALID_PARAMETER;
568 if ((mSupportSigItem[Index].SigHeaderSize != ((UINT32) ~0)) &&
571 return EFI_INVALID_PARAMETER;
582 return EFI_INVALID_PARAMETER;
591 if (RsaContext ==
NULL) {
592 return EFI_INVALID_PARAMETER;
599 return EFI_INVALID_PARAMETER;
606 return EFI_INVALID_PARAMETER;
615 if (((
UINTN)SigList - (
UINTN)Data) != DataSize) {
616 return EFI_INVALID_PARAMETER;
619 if (IsPk && (SigCount > 1)) {
620 return EFI_INVALID_PARAMETER;
640 if (mVendorKeyState == VENDOR_KEYS_MODIFIED) {
644 mVendorKeyState = VENDOR_KEYS_MODIFIED;
648 &gEfiVendorKeysNvGuid,
653 if (EFI_ERROR (Status)) {
659 &gEfiGlobalVariableGuid,
662 EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS
692 IN CHAR16 *VariableName,
696 IN UINT32 Attributes OPTIONAL,
712 return EFI_INVALID_PARAMETER;
720 || ( (mPlatformMode == SETUP_MODE)
723 Payload = (UINT8 *)Data + AUTHINFO2_SIZE (Data);
724 PayloadSize = DataSize - AUTHINFO2_SIZE (Data);
725 if (PayloadSize == 0) {
730 if (EFI_ERROR (Status)) {
742 if (EFI_ERROR (Status)) {
746 if ( (mPlatformMode != SETUP_MODE)
751 }
else if (mPlatformMode == USER_MODE) {
779 if (!EFI_ERROR (Status) && IsPk) {
780 if ((mPlatformMode == SETUP_MODE) && !Del) {
785 }
else if ((mPlatformMode == USER_MODE) && Del) {
821 IN CHAR16 *VariableName,
825 IN UINT32 Attributes OPTIONAL
839 return EFI_INVALID_PARAMETER;
860 Payload = (UINT8 *)Data + AUTHINFO2_SIZE (Data);
861 PayloadSize = DataSize - AUTHINFO2_SIZE (Data);
864 if (EFI_ERROR (Status)) {
876 if (EFI_ERROR (Status)) {
880 if (mPlatformMode != SETUP_MODE) {
902 IN UINT32 OrgAttributes,
919 if ((Attributes == OrgAttributes) &&
923 PayloadSize = DataSize - AUTHINFO2_SIZE (Data);
924 if (PayloadSize == 0) {
929 if (PayloadSize == 0) {
966 IN CHAR16 *VariableName,
978 ZeroMem (&OrgVariableInfo,
sizeof (OrgVariableInfo));
979 Status = mAuthVarLibContextIn->FindVariable (
1008 return EFI_SECURITY_VIOLATION;
1016 return EFI_UNSUPPORTED;
1032 if ((OrgVariableInfo.Data !=
NULL) &&
1038 return EFI_WRITE_PROTECTED;
1061 IN OUT VOID *NewData,
1076 UINTN SignatureListSize;
1082 if (*NewDataSize == 0) {
1086 TempDataSize = *NewDataSize;
1087 Status = mAuthVarLibContextIn->GetScratchBuffer (&TempDataSize, (VOID **)&TempData);
1088 if (EFI_ERROR (Status)) {
1089 return EFI_OUT_OF_RESOURCES;
1095 while ((*NewDataSize > 0) && (*NewDataSize >= NewCertList->
SignatureListSize)) {
1100 for (Index = 0; Index < NewCertCount; Index++) {
1111 for (Index2 = 0; Index2 < CertCount; Index2++) {
1136 if (CopiedCount == 0) {
1155 if (CopiedCount != 0) {
1165 TempDataSize = (Tail - (UINT8 *)TempData);
1167 CopyMem (NewData, TempData, TempDataSize);
1168 *NewDataSize = TempDataSize;
1190 if (FirstTime->Year != SecondTime->Year) {
1191 return (BOOLEAN)(FirstTime->Year < SecondTime->Year);
1192 }
else if (FirstTime->Month != SecondTime->Month) {
1193 return (BOOLEAN)(FirstTime->Month < SecondTime->Month);
1194 }
else if (FirstTime->Day != SecondTime->Day) {
1195 return (BOOLEAN)(FirstTime->Day < SecondTime->Day);
1196 }
else if (FirstTime->Hour != SecondTime->Hour) {
1197 return (BOOLEAN)(FirstTime->Hour < SecondTime->Hour);
1198 }
else if (FirstTime->Minute != SecondTime->Minute) {
1199 return (BOOLEAN)(FirstTime->Minute < SecondTime->Minute);
1202 return (BOOLEAN)(FirstTime->Second <= SecondTime->Second);
1223 IN UINT8 *SignerCert,
1225 IN UINT8 *TopLevelCert,
1227 OUT UINT8 *ShaDigest
1232 CHAR8 CertCommonName[128];
1233 UINTN CertCommonNameSize;
1234 BOOLEAN CryptoStatus;
1237 if (HashAlgId >= (
sizeof (mHashInfo) /
sizeof (
EFI_HASH_INFO))) {
1238 DEBUG ((DEBUG_INFO,
"%a Unsupported Hash Algorithm %d\n", __func__, HashAlgId));
1242 CertCommonNameSize =
sizeof (CertCommonName);
1247 Status =
X509GetCommonName (SignerCert, SignerCertSize, CertCommonName, &CertCommonNameSize);
1248 if (EFI_ERROR (Status)) {
1249 DEBUG ((DEBUG_INFO,
"%a Get SignerCert CommonName failed with status %x\n", __func__, Status));
1256 if (!
X509GetTBSCert (TopLevelCert, TopLevelCertSize, &TbsCert, &TbsCertSize)) {
1257 DEBUG ((DEBUG_INFO,
"%a Get Top-level Cert tbsCertificate failed!\n", __func__));
1264 ZeroMem (ShaDigest, mHashInfo[HashAlgId].HashSize);
1265 CryptoStatus = mHashInfo[HashAlgId].Init (*(mHashInfo[HashAlgId].HashShaCtx));
1266 if (!CryptoStatus) {
1273 CryptoStatus = mHashInfo[HashAlgId].Update (
1274 *(mHashInfo[HashAlgId].HashShaCtx),
1278 if (!CryptoStatus) {
1282 CryptoStatus = mHashInfo[HashAlgId].Update (*(mHashInfo[HashAlgId].HashShaCtx), TbsCert, TbsCertSize);
1283 if (!CryptoStatus) {
1287 CryptoStatus = mHashInfo[HashAlgId].Final (*(mHashInfo[HashAlgId].HashShaCtx), ShaDigest);
1288 if (!CryptoStatus) {
1325 IN CHAR16 *VariableName,
1329 OUT UINT32 *CertOffset OPTIONAL,
1330 OUT UINT32 *CertDataSize OPTIONAL,
1331 OUT UINT32 *CertNodeOffset OPTIONAL,
1332 OUT UINT32 *CertNodeSize OPTIONAL
1340 UINT32 CertDbListSize;
1342 if ((VariableName ==
NULL) || (VendorGuid ==
NULL) || (Data ==
NULL)) {
1343 return EFI_INVALID_PARAMETER;
1349 if (DataSize <
sizeof (UINT32)) {
1350 return EFI_INVALID_PARAMETER;
1355 if (CertDbListSize != (UINT32)DataSize) {
1356 return EFI_INVALID_PARAMETER;
1359 Offset =
sizeof (UINT32);
1364 while (Offset < (UINT32)DataSize) {
1374 if (NodeSize !=
sizeof (
EFI_GUID) +
sizeof (UINT32) * 3 + CertSize +
1375 sizeof (CHAR16) * NameSize)
1377 return EFI_INVALID_PARAMETER;
1380 Offset = Offset +
sizeof (
EFI_GUID) +
sizeof (UINT32) * 3;
1384 if ((NameSize ==
StrLen (VariableName)) &&
1385 (
CompareMem (Data + Offset, VariableName, NameSize *
sizeof (CHAR16)) == 0))
1387 Offset = Offset + NameSize *
sizeof (CHAR16);
1389 if (CertOffset !=
NULL) {
1390 *CertOffset = Offset;
1393 if (CertDataSize !=
NULL) {
1394 *CertDataSize = CertSize;
1397 if (CertNodeOffset !=
NULL) {
1398 *CertNodeOffset = (UINT32)((UINT8 *)Ptr - Data);
1401 if (CertNodeSize !=
NULL) {
1402 *CertNodeSize = NodeSize;
1407 Offset = Offset + NameSize *
sizeof (CHAR16) + CertSize;
1411 Offset = Offset + NodeSize;
1415 return EFI_NOT_FOUND;
1436 IN CHAR16 *VariableName,
1438 IN UINT32 Attributes,
1439 OUT UINT8 **CertData,
1440 OUT UINT32 *CertDataSize
1449 if ((VariableName ==
NULL) || (VendorGuid ==
NULL) || (CertData ==
NULL) || (CertDataSize ==
NULL)) {
1450 return EFI_INVALID_PARAMETER;
1462 DbName = EFI_CERT_DB_VOLATILE_NAME;
1474 if (EFI_ERROR (Status)) {
1478 if ((DataSize == 0) || (Data ==
NULL)) {
1480 return EFI_NOT_FOUND;
1494 if (EFI_ERROR (Status)) {
1498 *CertData = Data + CertOffset;
1519 IN CHAR16 *VariableName,
1521 IN UINT32 Attributes
1528 UINT32 CertNodeOffset;
1529 UINT32 CertNodeSize;
1531 UINT32 NewCertDbSize;
1534 if ((VariableName ==
NULL) || (VendorGuid ==
NULL)) {
1535 return EFI_INVALID_PARAMETER;
1548 DbName = EFI_CERT_DB_VOLATILE_NAME;
1559 if (EFI_ERROR (Status)) {
1563 if ((DataSize == 0) || (Data ==
NULL)) {
1565 return EFI_NOT_FOUND;
1568 if (DataSize ==
sizeof (UINT32)) {
1589 if (EFI_ERROR (Status)) {
1593 if (DataSize < (CertNodeOffset + CertNodeSize)) {
1594 return EFI_NOT_FOUND;
1600 NewCertDbSize = (UINT32)DataSize - CertNodeSize;
1606 CopyMem (NewCertDb, Data, CertNodeOffset);
1610 CopyMem (NewCertDb, &NewCertDbSize,
sizeof (UINT32));
1614 if (DataSize > (CertNodeOffset + CertNodeSize)) {
1616 NewCertDb + CertNodeOffset,
1617 Data + CertNodeOffset + CertNodeSize,
1618 DataSize - CertNodeOffset - CertNodeSize
1661 IN CHAR16 *VariableName,
1663 IN UINT32 Attributes,
1664 IN UINT8 *SignerCert,
1666 IN UINT8 *TopLevelCert,
1675 UINT32 NewCertDbSize;
1676 UINT32 CertNodeSize;
1678 UINT32 CertDataSize;
1681 UINT8 ShaDigest[SHA_DIGEST_SIZE_MAX];
1683 if ((VariableName ==
NULL) || (VendorGuid ==
NULL) || (SignerCert ==
NULL) || (TopLevelCert ==
NULL)) {
1684 return EFI_INVALID_PARAMETER;
1687 if (HashAlgId >= (
sizeof (mHashInfo) /
sizeof (
EFI_HASH_INFO))) {
1688 return EFI_INVALID_PARAMETER;
1701 DbName = EFI_CERT_DB_VOLATILE_NAME;
1714 if (EFI_ERROR (Status)) {
1718 if ((DataSize == 0) || (Data ==
NULL)) {
1720 return EFI_NOT_FOUND;
1738 if (!EFI_ERROR (Status)) {
1740 return EFI_ACCESS_DENIED;
1746 NameSize = (UINT32)
StrLen (VariableName);
1747 CertDataSize = mHashInfo[HashAlgId].HashSize;
1748 CertNodeSize =
sizeof (
AUTH_CERT_DB_DATA) + (UINT32)CertDataSize + NameSize *
sizeof (CHAR16);
1749 NewCertDbSize = (UINT32)DataSize + CertNodeSize;
1750 if (NewCertDbSize > mMaxCertDbSize) {
1751 return EFI_OUT_OF_RESOURCES;
1763 if (EFI_ERROR (Status)) {
1772 CopyMem (NewCertDb, Data, DataSize);
1776 CopyMem (NewCertDb, &NewCertDbSize,
sizeof (UINT32));
1781 CopyGuid (&Ptr->VendorGuid, VendorGuid);
1782 CopyMem (&Ptr->CertNodeSize, &CertNodeSize, sizeof (UINT32));
1783 CopyMem (&Ptr->NameSize, &NameSize, sizeof (UINT32));
1784 CopyMem (&Ptr->CertDataSize, &CertDataSize, sizeof (UINT32));
1789 NameSize *
sizeof (CHAR16)
1833 CHAR16 *VariableName;
1835 BOOLEAN CertCleaned;
1847 CertCleaned =
FALSE;
1858 if (EFI_ERROR (Status)) {
1862 if ((DataSize == 0) || (Data ==
NULL)) {
1864 return EFI_NOT_FOUND;
1867 Offset =
sizeof (UINT32);
1869 while (Offset < (UINT32)DataSize) {
1878 if (VariableName ==
NULL) {
1879 return EFI_OUT_OF_RESOURCES;
1891 ZeroMem (&AuthVariableInfo,
sizeof (AuthVariableInfo));
1892 Status = mAuthVarLibContextIn->FindVariable (
1908 DEBUG ((DEBUG_INFO,
"Recovery!! Cert for Auth Variable %s Guid %g is removed for consistency\n", VariableName, &AuthVarGuid));
1914 Offset = Offset + NodeSize;
1916 }
while (CertCleaned);
1932 IN UINT32 SigDataSize
1937 for (i = 0; i < (
sizeof (mHashInfo) /
sizeof (
EFI_HASH_INFO)); i++) {
1938 if ( ( (SigDataSize >= (13 + mHashInfo[i].OidLength))
1939 && ( ((*(SigData + 1) & TWO_BYTE_ENCODE) == TWO_BYTE_ENCODE)
1940 && (
CompareMem (SigData + 13, mHashInfo[i].OidValue, mHashInfo[i].OidLength) == 0)))
1941 || ( ((SigDataSize >= (32 + mHashInfo[i].OidLength)))
1942 && ( ((*(SigData + 20) & TWO_BYTE_ENCODE) == TWO_BYTE_ENCODE)
1943 && (
CompareMem (SigData + 32, mHashInfo[i].OidValue, mHashInfo[i].OidLength) == 0))))
1983 IN CHAR16 *VariableName,
1987 IN UINT32 Attributes,
1988 IN AUTHVAR_TYPE AuthVarType,
1990 OUT UINT8 **VarPayloadPtr,
2000 BOOLEAN VerifyStatus;
2011 UINT8 *TopLevelCert;
2012 UINTN TopLevelCertSize;
2014 UINTN TrustedCertSize;
2016 UINTN CertStackSize;
2017 UINT8 *CertsInCertDb;
2018 UINT32 CertsSizeinDb;
2019 UINT8 ShaDigest[SHA_DIGEST_SIZE_MAX];
2028 VerifyStatus =
FALSE;
2033 TopLevelCert =
NULL;
2034 CertsInCertDb =
NULL;
2052 (CertData->
TimeStamp.Nanosecond != 0) ||
2057 return EFI_SECURITY_VIOLATION;
2060 if ((OrgTimeStamp !=
NULL) && ((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0)) {
2065 return EFI_SECURITY_VIOLATION;
2079 return EFI_SECURITY_VIOLATION;
2137 if (HashAlgId >= (
sizeof (mHashInfo) /
sizeof (
EFI_HASH_INFO))) {
2138 return EFI_SECURITY_VIOLATION;
2145 PayloadPtr = SigData + SigDataSize;
2146 PayloadSize = DataSize - OFFSET_OF_AUTHINFO2_CERT_DATA - (
UINTN)SigDataSize;
2149 if ((PayloadSize == 0) && ((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0) && !IsVariablePolicyEnabled ()) {
2150 VerifyStatus =
TRUE;
2160 NewDataSize = PayloadSize +
sizeof (
EFI_TIME) +
sizeof (UINT32) +
2170 Status = mAuthVarLibContextIn->GetScratchBuffer (&NewDataSize, (VOID **)&NewData);
2171 if (EFI_ERROR (Status)) {
2172 return EFI_OUT_OF_RESOURCES;
2176 Length =
StrLen (VariableName) *
sizeof (CHAR16);
2177 CopyMem (Buffer, VariableName, Length);
2181 CopyMem (Buffer, VendorGuid, Length);
2184 Length =
sizeof (UINT32);
2185 CopyMem (Buffer, &Attr, Length);
2192 CopyMem (Buffer, PayloadPtr, PayloadSize);
2194 if (AuthVarType == AuthVarTypePk) {
2207 if (!VerifyStatus) {
2217 &gEfiGlobalVariableGuid,
2221 if (EFI_ERROR (Status)) {
2222 VerifyStatus =
FALSE;
2231 VerifyStatus =
FALSE;
2246 }
else if (AuthVarType == AuthVarTypeKek) {
2252 &gEfiGlobalVariableGuid,
2256 if (EFI_ERROR (Status)) {
2263 KekDataSize = (UINT32)DataSize;
2269 for (Index = 0; Index < CertCount; Index++) {
2298 }
else if (AuthVarType == AuthVarTypePriv) {
2311 if (!VerifyStatus) {
2320 if (OrgTimeStamp !=
NULL) {
2321 VerifyStatus =
FALSE;
2323 Status =
GetCertsFromDb (VariableName, VendorGuid, Attributes, &CertsInCertDb, &CertsSizeinDb);
2324 if (EFI_ERROR (Status)) {
2328 if ((HashAlgId < (
sizeof (mHashInfo) /
sizeof (
EFI_HASH_INFO))) && (CertsSizeinDb == mHashInfo[HashAlgId].HashSize)) {
2335 CertDataPtr->CertDataBuffer,
2341 if (EFI_ERROR (Status) || (
CompareMem (ShaDigest, CertsInCertDb, CertsSizeinDb) != 0)) {
2348 if ((CertStackSize != CertsSizeinDb) ||
2349 (
CompareMem (SignerCerts, CertsInCertDb, CertsSizeinDb) != 0))
2364 if (!VerifyStatus) {
2368 if ((OrgTimeStamp ==
NULL) && (PayloadSize != 0)) {
2378 CertDataPtr->CertDataBuffer,
2383 if (EFI_ERROR (Status)) {
2384 VerifyStatus =
FALSE;
2388 }
else if (AuthVarType == AuthVarTypePayload) {
2405 return EFI_SECURITY_VIOLATION;
2410 if ((AuthVarType == AuthVarTypePk) || (AuthVarType == AuthVarTypePriv)) {
2411 if (TopLevelCert !=
NULL) {
2415 if (SignerCerts !=
NULL) {
2420 if (!VerifyStatus) {
2421 return EFI_SECURITY_VIOLATION;
2425 if (EFI_ERROR (Status)) {
2429 *VarPayloadPtr = PayloadPtr;
2430 *VarPayloadSize = PayloadSize;
2463 IN CHAR16 *VariableName,
2467 IN UINT32 Attributes,
2468 IN AUTHVAR_TYPE AuthVarType,
2480 ZeroMem (&OrgVariableInfo,
sizeof (OrgVariableInfo));
2481 FindStatus = mAuthVarLibContextIn->FindVariable (
2494 (!EFI_ERROR (FindStatus)) ? OrgVariableInfo.TimeStamp :
NULL,
2498 if (EFI_ERROR (Status)) {
2502 if ( !EFI_ERROR (FindStatus)
2503 && (PayloadSize == 0)
2504 && ((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0))
2528 if (IsDel && (AuthVarType == AuthVarTypePriv) && !EFI_ERROR (Status)) {
2532 if (VarDel !=
NULL) {
2533 if (IsDel && !EFI_ERROR (Status)) {
EFI_STATUS AuthServiceInternalUpdateVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes)
EFI_STATUS CheckSignatureListFormat(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize)
EFI_STATUS VerifyTimeBasedPayloadAndUpdate(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes, IN AUTHVAR_TYPE AuthVarType, OUT BOOLEAN *VarDel)
EFI_STATUS UpdatePlatformMode(IN UINT32 Mode)
EFI_STATUS ProcessVarWithKek(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes OPTIONAL)
UINTN(EFIAPI * EFI_HASH_GET_CONTEXT_SIZE)(VOID)
EFI_STATUS VendorKeyIsModified(VOID)
EFI_STATUS GetCertsFromDb(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, OUT UINT8 **CertData, OUT UINT32 *CertDataSize)
BOOLEAN IsDeleteAuthVariable(IN UINT32 OrgAttributes, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes)
BOOLEAN(EFIAPI * EFI_HASH_UPDATE)(IN OUT VOID *HashContext, IN CONST VOID *Data, IN UINTN DataSize)
BOOLEAN InCustomMode(VOID)
EFI_STATUS AuthServiceInternalUpdateVariableWithTimeStamp(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes, IN EFI_TIME *TimeStamp)
BOOLEAN AuthServiceInternalCompareTimeStamp(IN EFI_TIME *FirstTime, IN EFI_TIME *SecondTime)
BOOLEAN(EFIAPI * EFI_HASH_INIT)(OUT VOID *HashContext)
EFI_STATUS AuthServiceInternalFindVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT VOID **Data, OUT UINTN *DataSize)
UINT8 FindHashAlgorithmIndex(IN UINT8 *SigData, IN UINT32 SigDataSize)
EFI_STATUS FindCertsFromDb(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT8 *Data, IN UINTN DataSize, OUT UINT32 *CertOffset OPTIONAL, OUT UINT32 *CertDataSize OPTIONAL, OUT UINT32 *CertNodeOffset OPTIONAL, OUT UINT32 *CertNodeSize OPTIONAL)
EFI_STATUS ProcessVarWithPk(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes OPTIONAL, IN BOOLEAN IsPk)
EFI_STATUS InsertCertsToDb(IN UINT8 HashAlgId, IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINT8 *SignerCert, IN UINTN SignerCertSize, IN UINT8 *TopLevelCert, IN UINTN TopLevelCertSize)
BOOLEAN NeedPhysicallyPresent(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid)
EFI_STATUS VerifyTimeBasedPayload(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes, IN AUTHVAR_TYPE AuthVarType, IN EFI_TIME *OrgTimeStamp, OUT UINT8 **VarPayloadPtr, OUT UINTN *VarPayloadSize)
EFI_STATUS ProcessVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes)
EFI_STATUS CalculatePrivAuthVarSignChainSHADigest(IN UINT8 HashAlgId, IN UINT8 *SignerCert, IN UINTN SignerCertSize, IN UINT8 *TopLevelCert, IN UINTN TopLevelCertSize, OUT UINT8 *ShaDigest)
EFI_STATUS CleanCertsFromDb(VOID)
EFI_STATUS FilterSignatureList(IN VOID *Data, IN UINTN DataSize, IN OUT VOID *NewData, IN OUT UINTN *NewDataSize)
BOOLEAN(EFIAPI * EFI_HASH_FINAL)(IN OUT VOID *HashContext, OUT UINT8 *HashValue)
EFI_STATUS DeleteCertsFromDb(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes)
UINTN EFIAPI Sha256GetContextSize(VOID)
UINTN EFIAPI Sha384GetContextSize(VOID)
BOOLEAN EFIAPI Sha512Final(IN OUT VOID *Sha512Context, OUT UINT8 *HashValue)
VOID *EFIAPI RsaNew(VOID)
UINTN EFIAPI Sha512GetContextSize(VOID)
BOOLEAN EFIAPI Sha512Init(OUT VOID *Sha512Context)
#define SHA512_DIGEST_SIZE
BOOLEAN EFIAPI Sha256Init(OUT VOID *Sha256Context)
BOOLEAN EFIAPI RsaGetPublicKeyFromX509(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT VOID **RsaContext)
BOOLEAN EFIAPI Pkcs7GetSigners(IN CONST UINT8 *P7Data, IN UINTN P7Length, OUT UINT8 **CertStack, OUT UINTN *StackLength, OUT UINT8 **TrustedCert, OUT UINTN *CertLength)
BOOLEAN EFIAPI Sha256Final(IN OUT VOID *Sha256Context, OUT UINT8 *HashValue)
#define SHA256_DIGEST_SIZE
BOOLEAN EFIAPI Sha384Update(IN OUT VOID *Sha384Context, IN CONST VOID *Data, IN UINTN DataSize)
BOOLEAN EFIAPI Pkcs7Verify(IN CONST UINT8 *P7Data, IN UINTN P7Length, IN CONST UINT8 *TrustedCert, IN UINTN CertLength, IN CONST UINT8 *InData, IN UINTN DataLength)
BOOLEAN EFIAPI Sha256Update(IN OUT VOID *Sha256Context, IN CONST VOID *Data, IN UINTN DataSize)
VOID EFIAPI RsaFree(IN VOID *RsaContext)
VOID EFIAPI Pkcs7FreeSigners(IN UINT8 *Certs)
BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
BOOLEAN EFIAPI Sha384Init(OUT VOID *Sha384Context)
BOOLEAN EFIAPI X509GetTBSCert(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 **TBSCert, OUT UINTN *TBSCertSize)
BOOLEAN EFIAPI Sha512Update(IN OUT VOID *Sha512Context, IN CONST VOID *Data, IN UINTN DataSize)
RETURN_STATUS EFIAPI X509GetCommonName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
#define SHA384_DIGEST_SIZE
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
UINT32 EFIAPI ReadUnaligned32(IN CONST UINT32 *Buffer)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define EFI_SETUP_MODE_NAME
#define EFI_KEY_EXCHANGE_KEY_NAME
#define EFI_PLATFORM_KEY_NAME
#define EFI_VENDOR_KEYS_VARIABLE_NAME
#define EFI_SECURE_BOOT_MODE_NAME
#define EFI_CERT_X509_SHA512_GUID
#define EFI_CERT_SHA512_GUID
#define EFI_CERT_SHA224_GUID
#define EFI_CERT_RSA2048_SHA1_GUID
#define EFI_CERT_SHA384_GUID
#define EFI_CERT_RSA2048_GUID
#define EFI_IMAGE_SECURITY_DATABASE2
#define EFI_CERT_SHA256_GUID
#define EFI_CERT_RSA2048_SHA256_GUID
#define EFI_IMAGE_SECURITY_DATABASE1
#define EFI_IMAGE_SECURITY_DATABASE
#define EFI_CERT_X509_SHA256_GUID
#define EFI_CERT_X509_GUID
#define EFI_CERT_SHA1_GUID
#define EFI_CERT_X509_SHA384_GUID
#define OFFSET_OF(TYPE, Field)
#define DEBUG(Expression)
#define FeaturePcdGet(TokenName)
VOID EFIAPI Exit(IN EFI_STATUS Status)
#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
#define EFI_VARIABLE_NON_VOLATILE
#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
UINT32 SignatureHeaderSize
WIN_CERTIFICATE_UEFI_GUID AuthInfo