From 8295f66320728efe85bd49cde8fd78201e563a0f Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 26 Sep 2024 10:39:03 +0800 Subject: [PATCH] TPM (FreeBSD): add support --- CMakeLists.txt | 2 +- src/detection/tpm/tpm_bsd.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/detection/tpm/tpm_bsd.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 46c656957..c959e5ab3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -641,7 +641,7 @@ elseif(FreeBSD) src/detection/terminalshell/terminalshell_linux.c src/detection/terminalsize/terminalsize_linux.c src/detection/theme/theme_linux.c - src/detection/tpm/tpm_nosupport.c + src/detection/tpm/tpm_bsd.c src/detection/uptime/uptime_bsd.c src/detection/users/users_linux.c src/detection/wallpaper/wallpaper_linux.c diff --git a/src/detection/tpm/tpm_bsd.c b/src/detection/tpm/tpm_bsd.c new file mode 100644 index 000000000..ffaf0009b --- /dev/null +++ b/src/detection/tpm/tpm_bsd.c @@ -0,0 +1,17 @@ +#include "tpm.h" +#include "common/sysctl.h" + +const char* ffDetectTPM(FFTPMResult* result) +{ + if (ffSysctlGetString("dev.tpmcrb.0.%desc", &result->description) != NULL) + return "TPM device is not found or TPM kernel module is not loaded"; + + if (ffStrbufContainS(&result->description, "2.0")) + ffStrbufSetStatic(&result->version, "2.0"); + else if (ffStrbufContainS(&result->description, "1.2")) + ffStrbufSetStatic(&result->version, "1.2"); + else + ffStrbufSetStatic(&result->version, "unknown"); + + return "Not supported on this platform"; +}