FvReportPei.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /** @file
  2. Definitions for OBB FVs verification.
  3. Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __FV_REPORT_PEI_H__
  7. #define __FV_REPORT_PEI_H__
  8. #include <PiPei.h>
  9. #include <IndustryStandard/Tpm20.h>
  10. #include <Ppi/FirmwareVolumeInfoStoredHashFv.h>
  11. #include <Library/PeiServicesLib.h>
  12. #include <Library/PcdLib.h>
  13. #include <Library/HobLib.h>
  14. #include <Library/DebugLib.h>
  15. #include <Library/BaseMemoryLib.h>
  16. #include <Library/MemoryAllocationLib.h>
  17. #include <Library/BaseCryptLib.h>
  18. #include <Library/ReportStatusCodeLib.h>
  19. #define HASH_INFO_PTR(PreHashedFvPpi) \
  20. (HASH_INFO *)((UINT8 *)(PreHashedFvPpi) + sizeof (EDKII_PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_PPI))
  21. #define HASH_VALUE_PTR(HashInfo) \
  22. (VOID *)((UINT8 *)(HashInfo) + sizeof (HASH_INFO))
  23. /**
  24. Computes the message digest of a input data buffer.
  25. This function performs message digest of a given data buffer, and places
  26. the digest value into the specified memory.
  27. If this interface is not supported, then return FALSE.
  28. @param[in] Data Pointer to the buffer containing the data to be hashed.
  29. @param[in] DataSize Size of Data buffer in bytes.
  30. @param[out] HashValue Pointer to a buffer that receives digest value.
  31. @retval TRUE The digest computation succeeded.
  32. @retval FALSE The digest computation failed.
  33. **/
  34. typedef
  35. BOOLEAN
  36. (EFIAPI *HASH_ALL_METHOD)(
  37. IN CONST VOID *Data,
  38. IN UINTN DataSize,
  39. OUT UINT8 *HashValue
  40. );
  41. /**
  42. Initializes user-supplied memory as hash context for subsequent use.
  43. @param[out] HashContext Pointer to hash context being initialized.
  44. @retval TRUE Hash context initialization succeeded.
  45. @retval FALSE Hash context initialization failed.
  46. @retval FALSE This interface is not supported.
  47. **/
  48. typedef
  49. BOOLEAN
  50. (EFIAPI *HASH_INIT_METHOD)(
  51. OUT VOID *HashContext
  52. );
  53. /**
  54. Digests the input data and updates hash context.
  55. @param[in, out] HashContext Pointer to the hash context.
  56. @param[in] Data Pointer to the buffer containing the data to be hashed.
  57. @param[in] DataSize Size of Data buffer in bytes.
  58. @retval TRUE Hash data digest succeeded.
  59. @retval FALSE Hash data digest failed.
  60. @retval FALSE This interface is not supported.
  61. **/
  62. typedef
  63. BOOLEAN
  64. (EFIAPI *HASH_UPDATE_METHOD)(
  65. IN OUT VOID *HashContext,
  66. IN CONST VOID *Data,
  67. IN UINTN DataSize
  68. );
  69. /**
  70. Completes computation of the hash digest value.
  71. @param[in, out] HashContext Pointer to the hash context.
  72. @param[out] HashValue Pointer to a buffer that receives the hash digest
  73. value.
  74. @retval TRUE Hash digest computation succeeded.
  75. @retval FALSE Hash digest computation failed.
  76. @retval FALSE This interface is not supported.
  77. **/
  78. typedef
  79. BOOLEAN
  80. (EFIAPI *HASH_FINAL_METHOD)(
  81. IN OUT VOID *HashContext,
  82. OUT UINT8 *HashValue
  83. );
  84. typedef struct {
  85. UINT16 HashAlgId;
  86. UINTN HashSize;
  87. HASH_INIT_METHOD HashInit;
  88. HASH_UPDATE_METHOD HashUpdate;
  89. HASH_FINAL_METHOD HashFinal;
  90. HASH_ALL_METHOD HashAll;
  91. } HASH_ALG_INFO;
  92. #endif //__FV_REPORT_PEI_H__