Coverage Report

Created: 2024-10-17 06:29

/src/hbfa-fl/HBFA/UefiHostFuzzTestCasePkg/TestStub/Tpm2DeviceLibStub/Tpm2DeviceLibStub.c
Line
Count
Source (jump to first uncovered line)
1
/** @file
2
  This library is TPM2 DTPM device lib.
3
  Choosing this library means platform uses and only uses DTPM device as TPM2 engine.
4
5
Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
6
SPDX-License-Identifier: BSD-2-Clause-Patent
7
8
**/
9
10
#include <Library/BaseLib.h>
11
#include <Library/BaseMemoryLib.h>
12
#include <Library/DebugLib.h>
13
#include <Library/Tpm2DeviceLib.h>
14
15
VOID    *mTpm2TestBuffer;
16
UINTN   mTpm2TestBufferSize;
17
18
/**
19
  This service enables the sending of commands to the TPM2.
20
21
  @param[in]      InputParameterBlockSize  Size of the TPM2 input parameter block.
22
  @param[in]      InputParameterBlock      Pointer to the TPM2 input parameter block.
23
  @param[in,out]  OutputParameterBlockSize Size of the TPM2 output parameter block.
24
  @param[in]      OutputParameterBlock     Pointer to the TPM2 output parameter block.
25
26
  @retval EFI_SUCCESS            The command byte stream was successfully sent to the device and a response was successfully received.
27
  @retval EFI_DEVICE_ERROR       The command was not successfully sent to the device or a response was not successfully received from the device.
28
  @retval EFI_BUFFER_TOO_SMALL   The output parameter block is too small.
29
**/
30
EFI_STATUS
31
EFIAPI
32
Tpm2SubmitCommand (
33
  IN UINT32            InputParameterBlockSize,
34
  IN UINT8             *InputParameterBlock,
35
  IN OUT UINT32        *OutputParameterBlockSize,
36
  IN UINT8             *OutputParameterBlock
37
  )
38
143
{
39
143
  if (*OutputParameterBlockSize > mTpm2TestBufferSize) {
40
82
    *OutputParameterBlockSize = (UINT32)mTpm2TestBufferSize;
41
82
  }
42
143
  CopyMem (OutputParameterBlock, mTpm2TestBuffer, *OutputParameterBlockSize);
43
143
  return EFI_SUCCESS;
44
143
}
45
46
/**
47
  This service requests use TPM2.
48
49
  @retval EFI_SUCCESS      Get the control of TPM2 chip.
50
  @retval EFI_NOT_FOUND    TPM2 not found.
51
  @retval EFI_DEVICE_ERROR Unexpected device behavior.
52
**/
53
EFI_STATUS
54
EFIAPI
55
Tpm2RequestUseTpm (
56
  VOID
57
  )
58
0
{
59
0
  return EFI_SUCCESS;
60
0
}
61
62
EFI_STATUS
63
EFIAPI
64
Tpm2ResponseInitialize (
65
  IN  VOID                   *Buffer,
66
  IN  UINTN                  BufferSize
67
  )
68
143
{
69
143
  mTpm2TestBuffer = Buffer;
70
143
  mTpm2TestBufferSize = BufferSize;
71
143
  return EFI_SUCCESS;
72
143
}