SecurityPkg: SecureBootVariableLib: Added newly supported interfaces

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3911

This change updated the interfaces provided by SecureBootVariableLib.

The new additions provided interfaces to enroll single authenticated
variable from input, a helper function to query secure boot status,
enroll all secure boot variables from UefiSecureBoot.h defined data
structures, a as well as a routine that deletes all secure boot related
variables.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Min Xu <min.m.xu@intel.com>

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Acked-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit is contained in:
kuqin
2022-04-15 13:03:22 -07:00
committed by mergify[bot]
parent 6de7c084db
commit 6eb4079475
3 changed files with 437 additions and 0 deletions

View File

@@ -43,6 +43,19 @@ GetSetupMode (
OUT UINT8 *SetupMode
);
/**
Helper function to quickly determine whether SecureBoot is enabled.
@retval TRUE SecureBoot is verifiably enabled.
@retval FALSE SecureBoot is either disabled or an error prevented checking.
**/
BOOLEAN
EFIAPI
IsSecureBootEnabled (
VOID
);
/**
Create a EFI Signature List with data supplied from input argument.
The input certificates from KeyInfo parameter should be DER-encoded
@@ -161,4 +174,60 @@ DeletePlatformKey (
VOID
);
/**
This function will delete the secure boot keys, thus
disabling secure boot.
@return EFI_SUCCESS or underlying failure code.
**/
EFI_STATUS
EFIAPI
DeleteSecureBootVariables (
VOID
);
/**
A helper function to take in a variable payload, wrap it in the
proper authenticated variable structure, and install it in the
EFI variable space.
@param[in] VariableName The name of the key/database.
@param[in] VendorGuid The namespace (ie. vendor GUID) of the variable
@param[in] DataSize Size parameter for target secure boot variable.
@param[in] Data Pointer to signature list formatted secure boot variable content.
@retval EFI_SUCCESS The enrollment for authenticated variable was successful.
@retval EFI_OUT_OF_RESOURCES There are not enough memory resources to create time based payload.
@retval EFI_INVALID_PARAMETER The parameter is invalid.
@retval Others Unexpected error happens.
**/
EFI_STATUS
EFIAPI
EnrollFromInput (
IN CHAR16 *VariableName,
IN EFI_GUID *VendorGuid,
IN UINTN DataSize,
IN VOID *Data
);
/**
Similar to DeleteSecureBootVariables, this function is used to unilaterally
force the state of related SB variables (db, dbx, dbt, KEK, PK, etc.) to be
the built-in, hardcoded default vars.
@param[in] SecureBootPayload Payload information for secure boot related keys.
@retval EFI_SUCCESS SecureBoot keys are now set to defaults.
@retval EFI_ABORTED SecureBoot keys are not empty. Please delete keys first
or follow standard methods of altering keys (ie. use the signing system).
@retval EFI_SECURITY_VIOLATION Failed to create the PK.
@retval Others Something failed in one of the subfunctions.
**/
EFI_STATUS
EFIAPI
SetSecureBootVariablesToDefault (
IN CONST SECURE_BOOT_PAYLOAD_INFO *SecureBootPayload
);
#endif