summaryrefslogtreecommitdiffstats
path: root/src/detection/tpm/tpm_linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/detection/tpm/tpm_linux.c')
-rw-r--r--src/detection/tpm/tpm_linux.c24
1 files changed, 24 insertions, 0 deletions
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;
+}