summaryrefslogtreecommitdiffstats
path: root/src/detection/tpm/tpm_bsd.c
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
committersumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
commit76424950e373d3b04ac3dd13019151bfba3e8423 (patch)
tree4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/tpm/tpm_bsd.c
Add the files
Diffstat (limited to 'src/detection/tpm/tpm_bsd.c')
-rw-r--r--src/detection/tpm/tpm_bsd.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/detection/tpm/tpm_bsd.c b/src/detection/tpm/tpm_bsd.c
new file mode 100644
index 0000000..4b73413
--- /dev/null
+++ b/src/detection/tpm/tpm_bsd.c
@@ -0,0 +1,22 @@
+#include "tpm.h"
+#include "common/sysctl.h"
+#include "common/kmod.h"
+
+const char* ffDetectTPM(FFTPMResult* result) {
+ if (ffSysctlGetString("dev.tpmcrb.0.%desc", &result->description) != NULL) {
+ if (!ffKmodLoaded("tpm")) {
+ return "`tpm` kernel module is not loaded";
+ }
+ return "TPM device is not found";
+ }
+
+ 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 NULL;
+}