]>
git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Library/Tpm12CommandLib/Tpm12Pcr.c
2 Implement TPM1.2 PCR related commands.
4 Copyright (c) 2016, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Library/Tpm12CommandLib.h>
17 #include <Library/BaseLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/BaseMemoryLib.h>
20 #include <Library/Tpm12DeviceLib.h>
25 TPM_RQU_COMMAND_HDR Hdr
;
26 TPM_PCRINDEX PcrIndex
;
31 TPM_RSP_COMMAND_HDR Hdr
;
40 @param[in] DigestToExtend The 160 bit value representing the event to be recorded.
41 @param[in] PcrIndex The PCR to be updated.
42 @param[out] NewPcrValue New PCR value after extend.
44 @retval EFI_SUCCESS Operation completed successfully.
45 @retval EFI_TIMEOUT The register can't run into the expected status in time.
46 @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
47 @retval EFI_DEVICE_ERROR Unexpected device behavior.
53 IN TPM_DIGEST
*DigestToExtend
,
54 IN TPM_PCRINDEX PcrIndex
,
55 OUT TPM_DIGEST
*NewPcrValue
59 TPM_CMD_EXTEND Command
;
60 TPM_RSP_EXTEND Response
;
64 // send Tpm command TPM_ORD_Extend
66 Command
.Hdr
.tag
= SwapBytes16 (TPM_TAG_RQU_COMMAND
);
67 Command
.Hdr
.paramSize
= SwapBytes32 (sizeof (Command
));
68 Command
.Hdr
.ordinal
= SwapBytes32 (TPM_ORD_Extend
);
69 Command
.PcrIndex
= SwapBytes32 (PcrIndex
);
70 CopyMem (&Command
.TpmDigest
, DigestToExtend
, sizeof (Command
.TpmDigest
));
71 Length
= sizeof (Response
);
72 Status
= Tpm12SubmitCommand (sizeof (Command
), (UINT8
*)&Command
, &Length
, (UINT8
*)&Response
);
73 if (EFI_ERROR (Status
)) {
77 if (SwapBytes32(Response
.Hdr
.returnCode
) != TPM_SUCCESS
) {
78 DEBUG ((EFI_D_ERROR
, "Tpm12Extend: Response Code error! 0x%08x\r\n", SwapBytes32(Response
.Hdr
.returnCode
)));
79 return EFI_DEVICE_ERROR
;
82 if (NewPcrValue
!= NULL
) {
83 CopyMem (NewPcrValue
, &Response
.TpmDigest
, sizeof (*NewPcrValue
));