SecureBootVariableLib.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /** @file
  2. Provides a helper functions for creating variable authenticated
  3. payloads, signature lists related to secure boot keys.
  4. Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
  5. (C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>
  6. Copyright (c) 2021, ARM Ltd. All rights reserved.<BR>
  7. Copyright (c) 2021, Semihalf All rights reserved.<BR>
  8. SPDX-License-Identifier: BSD-2-Clause-Patent
  9. **/
  10. #ifndef SECURE_BOOT_VARIABLE_LIB_H_
  11. #define SECURE_BOOT_VARIABLE_LIB_H_
  12. /**
  13. Set the platform secure boot mode into "Custom" or "Standard" mode.
  14. @param[in] SecureBootMode New secure boot mode: STANDARD_SECURE_BOOT_MODE or
  15. CUSTOM_SECURE_BOOT_MODE.
  16. @return EFI_SUCCESS The platform has switched to the special mode successfully.
  17. @return other Fail to operate the secure boot mode.
  18. --*/
  19. EFI_STATUS
  20. SetSecureBootMode (
  21. IN UINT8 SecureBootMode
  22. );
  23. /**
  24. Fetches the value of SetupMode variable.
  25. @param[out] SetupMode Pointer to UINT8 for SetupMode output
  26. @retval other Error codes from GetVariable.
  27. --*/
  28. EFI_STATUS
  29. EFIAPI
  30. GetSetupMode (
  31. OUT UINT8 *SetupMode
  32. );
  33. /**
  34. Create a EFI Signature List with data fetched from section specified as a argument.
  35. Found keys are verified using RsaGetPublicKeyFromX509().
  36. @param[in] KeyFileGuid A pointer to to the FFS filename GUID
  37. @param[out] SigListsSize A pointer to size of signature list
  38. @param[out] SigListsOut a pointer to a callee-allocated buffer with signature lists
  39. @retval EFI_SUCCESS Create time based payload successfully.
  40. @retval EFI_NOT_FOUND Section with key has not been found.
  41. @retval EFI_INVALID_PARAMETER Embedded key has a wrong format.
  42. @retval Others Unexpected error happens.
  43. --*/
  44. EFI_STATUS
  45. SecureBootFetchData (
  46. IN EFI_GUID *KeyFileGuid,
  47. OUT UINTN *SigListsSize,
  48. OUT EFI_SIGNATURE_LIST **SigListOut
  49. );
  50. /**
  51. Create a time based data payload by concatenating the EFI_VARIABLE_AUTHENTICATION_2
  52. descriptor with the input data. NO authentication is required in this function.
  53. @param[in, out] DataSize On input, the size of Data buffer in bytes.
  54. On output, the size of data returned in Data
  55. buffer in bytes.
  56. @param[in, out] Data On input, Pointer to data buffer to be wrapped or
  57. pointer to NULL to wrap an empty payload.
  58. On output, Pointer to the new payload date buffer allocated from pool,
  59. it's caller's responsibility to free the memory when finish using it.
  60. @retval EFI_SUCCESS Create time based payload successfully.
  61. @retval EFI_OUT_OF_RESOURCES There are not enough memory resources to create time based payload.
  62. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  63. @retval Others Unexpected error happens.
  64. --*/
  65. EFI_STATUS
  66. CreateTimeBasedPayload (
  67. IN OUT UINTN *DataSize,
  68. IN OUT UINT8 **Data
  69. );
  70. /**
  71. Clears the content of the 'db' variable.
  72. @retval EFI_OUT_OF_RESOURCES If memory allocation for EFI_VARIABLE_AUTHENTICATION_2 fails
  73. while VendorGuid is NULL.
  74. @retval other Errors from GetVariable2(), GetTime() and SetVariable()
  75. --*/
  76. EFI_STATUS
  77. EFIAPI
  78. DeleteDb (
  79. VOID
  80. );
  81. /**
  82. Clears the content of the 'dbx' variable.
  83. @retval EFI_OUT_OF_RESOURCES If memory allocation for EFI_VARIABLE_AUTHENTICATION_2 fails
  84. while VendorGuid is NULL.
  85. @retval other Errors from GetVariable2(), GetTime() and SetVariable()
  86. --*/
  87. EFI_STATUS
  88. EFIAPI
  89. DeleteDbx (
  90. VOID
  91. );
  92. /**
  93. Clears the content of the 'dbt' variable.
  94. @retval EFI_OUT_OF_RESOURCES If memory allocation for EFI_VARIABLE_AUTHENTICATION_2 fails
  95. while VendorGuid is NULL.
  96. @retval other Errors from GetVariable2(), GetTime() and SetVariable()
  97. --*/
  98. EFI_STATUS
  99. EFIAPI
  100. DeleteDbt (
  101. VOID
  102. );
  103. /**
  104. Clears the content of the 'KEK' variable.
  105. @retval EFI_OUT_OF_RESOURCES If memory allocation for EFI_VARIABLE_AUTHENTICATION_2 fails
  106. while VendorGuid is NULL.
  107. @retval other Errors from GetVariable2(), GetTime() and SetVariable()
  108. --*/
  109. EFI_STATUS
  110. EFIAPI
  111. DeleteKEK (
  112. VOID
  113. );
  114. /**
  115. Clears the content of the 'PK' variable.
  116. @retval EFI_OUT_OF_RESOURCES If memory allocation for EFI_VARIABLE_AUTHENTICATION_2 fails
  117. while VendorGuid is NULL.
  118. @retval other Errors from GetVariable2(), GetTime() and SetVariable()
  119. --*/
  120. EFI_STATUS
  121. EFIAPI
  122. DeletePlatformKey (
  123. VOID
  124. );
  125. #endif