]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c
SecurityPkg: Apply uncrustify changes
[mirror_edk2.git] / SecurityPkg / Library / PeiTpmMeasurementLib / PeiTpmMeasurementLib.c
CommitLineData
98625337
JY
1/** @file\r
2 This library is used by other modules to measure data to TPM.\r
3\r
4Copyright (c) 2020, Intel Corporation. All rights reserved. <BR>\r
5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#include <PiPei.h>\r
10\r
11#include <Library/BaseMemoryLib.h>\r
12#include <Library/PeiServicesLib.h>\r
13#include <Library/PeiServicesTablePointerLib.h>\r
14#include <Library/DebugLib.h>\r
15#include <Library/HobLib.h>\r
16#include <Library/TpmMeasurementLib.h>\r
17\r
18#include <Ppi/Tcg.h>\r
19#include <IndustryStandard/UefiTcgPlatform.h>\r
20\r
21/**\r
22 Tpm measure and log data, and extend the measurement result into a specific PCR.\r
23\r
24 @param[in] PcrIndex PCR Index.\r
25 @param[in] EventType Event type.\r
26 @param[in] EventLog Measurement event log.\r
27 @param[in] LogLen Event log length in bytes.\r
28 @param[in] HashData The start of the data buffer to be hashed, extended.\r
29 @param[in] HashDataLen The length, in bytes, of the buffer referenced by HashData\r
30\r
31 @retval EFI_SUCCESS Operation completed successfully.\r
32 @retval EFI_UNSUPPORTED TPM device not available.\r
33 @retval EFI_OUT_OF_RESOURCES Out of memory.\r
34 @retval EFI_DEVICE_ERROR The operation was unsuccessful.\r
35**/\r
36EFI_STATUS\r
37EFIAPI\r
38TpmMeasureAndLogData (\r
c411b485
MK
39 IN UINT32 PcrIndex,\r
40 IN UINT32 EventType,\r
41 IN VOID *EventLog,\r
42 IN UINT32 LogLen,\r
43 IN VOID *HashData,\r
44 IN UINT64 HashDataLen\r
98625337
JY
45 )\r
46{\r
c411b485
MK
47 EFI_STATUS Status;\r
48 EDKII_TCG_PPI *TcgPpi;\r
49 TCG_PCR_EVENT_HDR TcgEventHdr;\r
98625337
JY
50\r
51 Status = PeiServicesLocatePpi (\r
52 &gEdkiiTcgPpiGuid,\r
53 0,\r
54 NULL,\r
c411b485 55 (VOID **)&TcgPpi\r
98625337 56 );\r
c411b485 57 if (EFI_ERROR (Status)) {\r
98625337
JY
58 return Status;\r
59 }\r
60\r
61 TcgEventHdr.PCRIndex = PcrIndex;\r
62 TcgEventHdr.EventType = EventType;\r
63 TcgEventHdr.EventSize = LogLen;\r
64\r
65 Status = TcgPpi->HashLogExtendEvent (\r
66 TcgPpi,\r
67 0,\r
68 HashData,\r
69 (UINTN)HashDataLen,\r
70 &TcgEventHdr,\r
71 EventLog\r
72 );\r
73 return Status;\r
74}\r