From 76424950e373d3b04ac3dd13019151bfba3e8423 Mon Sep 17 00:00:00 2001 From: sumuel Date: Mon, 17 Aug 2026 20:44:55 +0000 Subject: Add the files --- src/detection/tpm/tpm_linux.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/detection/tpm/tpm_linux.c (limited to 'src/detection/tpm/tpm_linux.c') diff --git a/src/detection/tpm/tpm_linux.c b/src/detection/tpm/tpm_linux.c new file mode 100644 index 0000000..040da38 --- /dev/null +++ b/src/detection/tpm/tpm_linux.c @@ -0,0 +1,24 @@ +#include "tpm.h" +#include "common/io.h" + +const char* ffDetectTPM(FFTPMResult* result) { + if (!ffPathExists("/sys/class/tpm/tpm0/", FF_PATHTYPE_DIRECTORY)) { + if (!ffPathExists("/sys/class/tpm/", FF_PATHTYPE_DIRECTORY)) { + return "TPM is not supported by kernel"; + } + return "TPM device is not found"; + } + + if (ffReadFileBuffer("/sys/class/tpm/tpm0/tpm_version_major", &result->version)) { + ffStrbufTrimRightSpace(&result->version); + if (ffStrbufEqualS(&result->version, "2")) { + ffStrbufSetStatic(&result->version, "2.0"); + } + } + + if (ffReadFileBuffer("/sys/class/tpm/tpm0/device/description", &result->description)) { + ffStrbufTrimRightSpace(&result->description); + } + + return NULL; +} -- cgit v1.2.3