FvReportPei.h 3.3 KB

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