Install secure boot
| 413 | |
| 414 | // Install secure boot |
| 415 | EFI_STATUS InstallSecureBoot(VOID) |
| 416 | { |
| 417 | EFI_STATUS Status; |
| 418 | EFI_SECURITY_ARCH_PROTOCOL *Security = NULL; |
| 419 | EFI_SECURITY2_ARCH_PROTOCOL *Security2 = NULL; |
| 420 | // Check if already installed |
| 421 | if (gSecurityFileAuthentication) { |
| 422 | return EFI_SUCCESS; |
| 423 | } |
| 424 | PrintSecureBootInfo(); |
| 425 | // Nothing to do if secure boot is disabled or in setup mode |
| 426 | if (!gSettings.SecureBoot || gSettings.SecureBootSetupMode) { |
| 427 | return EFI_SUCCESS; |
| 428 | } |
| 429 | // Locate security protocols |
| 430 | gBS->LocateProtocol(&gEfiSecurity2ArchProtocolGuid, NULL, (VOID **)&Security2); |
| 431 | Status = gBS->LocateProtocol(&gEfiSecurityArchProtocolGuid, NULL, (VOID **)&Security); |
| 432 | if (EFI_ERROR(Status)) { |
| 433 | return Status; |
| 434 | } |
| 435 | if (Security == NULL) { |
| 436 | return EFI_NOT_FOUND; |
| 437 | } |
| 438 | // Install policy hooks |
| 439 | gSecurityFileAuthentication = Security->FileAuthenticationState; |
| 440 | Security->FileAuthenticationState = InternalFileAuthentication; |
| 441 | if (Security2) { |
| 442 | gSecurity2FileAuthentication = Security2->FileAuthentication; |
| 443 | Security2->FileAuthentication = Internal2FileAuthentication; |
| 444 | } |
| 445 | return EFI_SUCCESS; |
| 446 | } |
| 447 | |
| 448 | // Uninstall secure boot |
| 449 | VOID UninstallSecureBoot(VOID) |
no test coverage detected