TianoCore EDK2 master
Loading...
Searching...
No Matches
Tpm12Pcr.c
Go to the documentation of this file.
1
9#include <PiPei.h>
11#include <Library/BaseLib.h>
12#include <Library/DebugLib.h>
15
16#pragma pack(1)
17
18typedef struct {
20 TPM_PCRINDEX PcrIndex;
21 TPM_DIGEST TpmDigest;
23
24typedef struct {
26 TPM_DIGEST TpmDigest;
28
29#pragma pack()
30
45EFIAPI
47 IN TPM_DIGEST *DigestToExtend,
48 IN TPM_PCRINDEX PcrIndex,
49 OUT TPM_DIGEST *NewPcrValue
50 )
51{
52 EFI_STATUS Status;
53 TPM_CMD_EXTEND Command;
54 TPM_RSP_EXTEND Response;
55 UINT32 Length;
56
57 //
58 // send Tpm command TPM_ORD_Extend
59 //
60 Command.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
61 Command.Hdr.paramSize = SwapBytes32 (sizeof (Command));
62 Command.Hdr.ordinal = SwapBytes32 (TPM_ORD_Extend);
63 Command.PcrIndex = SwapBytes32 (PcrIndex);
64 CopyMem (&Command.TpmDigest, DigestToExtend, sizeof (Command.TpmDigest));
65 Length = sizeof (Response);
66 Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);
67 if (EFI_ERROR (Status)) {
68 return Status;
69 }
70
71 if (SwapBytes32 (Response.Hdr.returnCode) != TPM_SUCCESS) {
72 DEBUG ((DEBUG_ERROR, "Tpm12Extend: Response Code error! 0x%08x\r\n", SwapBytes32 (Response.Hdr.returnCode)));
73 return EFI_DEVICE_ERROR;
74 }
75
76 if (NewPcrValue != NULL) {
77 CopyMem (NewPcrValue, &Response.TpmDigest, sizeof (*NewPcrValue));
78 }
79
80 return Status;
81}
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
Definition: SwapBytes16.c:25
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
Definition: SwapBytes32.c:25
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
UINT32 TPM_PCRINDEX
Definition: Tpm12.h:133
EFI_STATUS EFIAPI Tpm12SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
Definition: Tpm12Tis.c:453
EFI_STATUS EFIAPI Tpm12Extend(IN TPM_DIGEST *DigestToExtend, IN TPM_PCRINDEX PcrIndex, OUT TPM_DIGEST *NewPcrValue)
Definition: Tpm12Pcr.c:46
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29