34VOID *mHashSha256Ctx =
NULL;
35VOID *mHashSha384Ctx =
NULL;
36VOID *mHashSha512Ctx =
NULL;
40 &gEfiSecureBootEnableDisableGuid,
43 VAR_CHECK_VARIABLE_PROPERTY_REVISION,
51 &gEfiCustomModeEnableGuid,
54 VAR_CHECK_VARIABLE_PROPERTY_REVISION,
62 &gEfiVendorKeysNvGuid,
65 VAR_CHECK_VARIABLE_PROPERTY_REVISION,
66 VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY,
67 VARIABLE_ATTRIBUTE_NV_BS_RT_AT,
76 VAR_CHECK_VARIABLE_PROPERTY_REVISION,
77 VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY,
78 VARIABLE_ATTRIBUTE_NV_BS_RT_AT,
85 EFI_CERT_DB_VOLATILE_NAME,
87 VAR_CHECK_VARIABLE_PROPERTY_REVISION,
88 VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY,
89 VARIABLE_ATTRIBUTE_BS_RT_AT,
96VOID **mAuthVarAddressPointer[11];
125 UINT8 SecureBootMode;
126 UINT8 SecureBootEnable;
130 if ((AuthVarLibContextIn ==
NULL) || (AuthVarLibContextOut ==
NULL)) {
131 return EFI_INVALID_PARAMETER;
134 mAuthVarLibContextIn = AuthVarLibContextIn;
140 if (mHashSha256Ctx ==
NULL) {
141 return EFI_OUT_OF_RESOURCES;
145 if (mHashSha384Ctx ==
NULL) {
146 return EFI_OUT_OF_RESOURCES;
150 if (mHashSha512Ctx ==
NULL) {
151 return EFI_OUT_OF_RESOURCES;
158 mMaxCertDbSize = (UINT32)(mAuthVarLibContextIn->MaxAuthVariableSize - sizeof (EFI_CERT_DB_VOLATILE_NAME));
161 return EFI_OUT_OF_RESOURCES;
165 if (EFI_ERROR (Status)) {
174 if (EFI_ERROR (Status)) {
175 mPlatformMode = SETUP_MODE;
177 mPlatformMode = USER_MODE;
182 &gEfiGlobalVariableGuid,
185 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS
187 if (EFI_ERROR (Status)) {
196 &gEfiGlobalVariableGuid,
198 sizeof (mSignatureSupport),
199 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS
201 if (EFI_ERROR (Status)) {
210 SecureBootEnable = SECURE_BOOT_DISABLE;
212 if (!EFI_ERROR (Status)) {
213 if (mPlatformMode == USER_MODE) {
214 SecureBootEnable = *(UINT8 *)Data;
216 }
else if (mPlatformMode == USER_MODE) {
220 SecureBootEnable = SECURE_BOOT_ENABLE;
223 &gEfiSecureBootEnableDisableGuid,
228 if (EFI_ERROR (Status)) {
236 if ((SecureBootEnable == SECURE_BOOT_ENABLE) && (mPlatformMode == USER_MODE)) {
237 SecureBootMode = SECURE_BOOT_MODE_ENABLE;
239 SecureBootMode = SECURE_BOOT_MODE_DISABLE;
244 &gEfiGlobalVariableGuid,
247 EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS
249 if (EFI_ERROR (Status)) {
260 CustomMode = STANDARD_SECURE_BOOT_MODE;
263 &gEfiCustomModeEnableGuid,
268 if (EFI_ERROR (Status)) {
285 if (EFI_ERROR (Status)) {
287 ListSize =
sizeof (UINT32);
295 if (EFI_ERROR (Status)) {
303 if (EFI_ERROR (Status)) {
304 DEBUG ((DEBUG_ERROR,
"Clean up CertDB fail! Status %x\n", Status));
313 ListSize =
sizeof (UINT32);
315 EFI_CERT_DB_VOLATILE_NAME,
321 if (EFI_ERROR (Status)) {
329 if (!EFI_ERROR (Status)) {
330 mVendorKeyState = *(UINT8 *)Data;
335 mVendorKeyState = VENDOR_KEYS_VALID;
338 &gEfiVendorKeysNvGuid,
343 if (EFI_ERROR (Status)) {
353 &gEfiGlobalVariableGuid,
356 EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS
358 if (EFI_ERROR (Status)) {
364 AuthVarLibContextOut->StructVersion = AUTH_VAR_LIB_CONTEXT_OUT_STRUCT_VERSION;
366 AuthVarLibContextOut->AuthVarEntry = mAuthVarEntry;
367 AuthVarLibContextOut->AuthVarEntryCount =
ARRAY_SIZE (mAuthVarEntry);
369 mAuthVarAddressPointer[1] = (VOID **)&mHashSha256Ctx;
370 mAuthVarAddressPointer[2] = (VOID **)&mHashSha384Ctx;
371 mAuthVarAddressPointer[3] = (VOID **)&mHashSha512Ctx;
372 mAuthVarAddressPointer[4] = (VOID **)&mAuthVarLibContextIn;
373 mAuthVarAddressPointer[5] = (VOID **)&(mAuthVarLibContextIn->FindVariable),
374 mAuthVarAddressPointer[6] = (VOID **)&(mAuthVarLibContextIn->FindNextVariable),
375 mAuthVarAddressPointer[7] = (VOID **)&(mAuthVarLibContextIn->UpdateVariable),
376 mAuthVarAddressPointer[8] = (VOID **)&(mAuthVarLibContextIn->GetScratchBuffer),
377 mAuthVarAddressPointer[9] = (VOID **)&(mAuthVarLibContextIn->CheckRemainingSpaceForConsistency),
378 mAuthVarAddressPointer[10] = (VOID **)&(mAuthVarLibContextIn->AtRuntime),
379 AuthVarLibContextOut->AddressPointer = mAuthVarAddressPointer;
380 AuthVarLibContextOut->AddressPointerCount =
ARRAY_SIZE (mAuthVarAddressPointer);
408 IN CHAR16 *VariableName,
421 }
else if (
CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) &&
428 if (EFI_ERROR (Status)) {
429 Status =
ProcessVarWithKek (VariableName, VendorGuid, Data, DataSize, Attributes);
432 Status =
ProcessVariable (VariableName, VendorGuid, Data, DataSize, Attributes);
EFI_STATUS AuthServiceInternalUpdateVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes)
EFI_STATUS ProcessVarWithKek(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes OPTIONAL)
EFI_STATUS AuthServiceInternalFindVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT VOID **Data, OUT UINTN *DataSize)
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 ProcessVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes)
EFI_STATUS CleanCertsFromDb(VOID)
EFI_STATUS EFIAPI AuthVariableLibInitialize(IN AUTH_VAR_LIB_CONTEXT_IN *AuthVarLibContextIn, OUT AUTH_VAR_LIB_CONTEXT_OUT *AuthVarLibContextOut)
EFI_STATUS EFIAPI AuthVariableLibProcessVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN VOID *Data, IN UINTN DataSize, IN UINT32 Attributes)
UINTN EFIAPI Sha256GetContextSize(VOID)
UINTN EFIAPI Sha384GetContextSize(VOID)
UINTN EFIAPI Sha512GetContextSize(VOID)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI AllocateRuntimePool(IN UINTN AllocationSize)
#define EFI_SETUP_MODE_NAME
#define EFI_KEY_EXCHANGE_KEY_NAME
#define EFI_SIGNATURE_SUPPORT_NAME
#define EFI_PLATFORM_KEY_NAME
#define EFI_VENDOR_KEYS_VARIABLE_NAME
#define EFI_SECURE_BOOT_MODE_NAME
#define EFI_CERT_SHA512_GUID
#define EFI_CERT_SHA384_GUID
#define EFI_CERT_RSA2048_GUID
#define EFI_IMAGE_SECURITY_DATABASE2
#define EFI_CERT_SHA256_GUID
#define EFI_IMAGE_SECURITY_DATABASE1
#define EFI_IMAGE_SECURITY_DATABASE
#define EFI_CERT_X509_GUID
#define EFI_CERT_SHA1_GUID
#define ARRAY_SIZE(Array)
#define DEBUG(Expression)
#define EFI_VARIABLE_NON_VOLATILE
#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS