TPM (Windows): use system headers

This commit is contained in:
李通洲
2024-10-17 09:20:17 +08:00
parent bf1cd3388d
commit 9188715efd
+3 -32
View File
@@ -1,37 +1,8 @@
#include "tpm.h"
#include "common/library.h"
// #include <tbs.h>
typedef UINT32 TBS_RESULT;
#define TBS_SUCCESS 0u
#define TBS_E_TPM_NOT_FOUND ((TBS_RESULT) 0x8028400Fu)
#define TPM_VERSION_UNKNOWN 0
#define TPM_VERSION_12 1
#define TPM_VERSION_20 2
#define TPM_IFTYPE_UNKNOWN 0
#define TPM_IFTYPE_1 1 // for 1.2 - use I/O-port or MMIO
#define TPM_IFTYPE_TRUSTZONE 2 // 2.0: Trustzone
#define TPM_IFTYPE_HW 3 // 2.0: HW TPM
#define TPM_IFTYPE_EMULATOR 4 // 2.0: SW-emulator
#define TPM_IFTYPE_SPB 5 // 2.0: SPB attached
typedef struct _TPM_DEVICE_INFO
{
UINT32 structVersion; // = 1 for now
UINT32 tpmVersion; // 1.2 / 2.0
UINT32 tpmInterfaceType; // HW, simulator, ...
UINT32 tpmImpRevision; // code-drop revision,
// implenmentation-specific
} TPM_DEVICE_INFO, *PTPM_DEVICE_INFO;
typedef const TPM_DEVICE_INFO *PCTPM_DEVICE_INFO;
TBS_RESULT WINAPI
Tbsi_GetDeviceInfo(
_In_ UINT32 Size,
_Out_writes_bytes_(Size) PVOID Info);
#include <tbs.h>
#include <winerror.h>
const char* ffDetectTPM(FFTPMResult* result)
{
@@ -41,7 +12,7 @@ const char* ffDetectTPM(FFTPMResult* result)
TPM_DEVICE_INFO deviceInfo = {};
TBS_RESULT code = ffTbsi_GetDeviceInfo(sizeof(deviceInfo), &deviceInfo);
if (code != TBS_SUCCESS)
return code == TBS_E_TPM_NOT_FOUND ? "TPM device is not found" : "Tbsi_GetDeviceInfo() failed";
return code == (TBS_RESULT) TBS_E_TPM_NOT_FOUND ? "TPM device is not found" : "Tbsi_GetDeviceInfo() failed";
switch (deviceInfo.tpmVersion)
{