summaryrefslogtreecommitdiffstats
path: root/src/detection/tpm/tpm_bsd.c
diff options
context:
space:
mode:
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;
+}