diff options
| author | sumuel <samuel@yakubos.org> | 2026-08-17 20:44:55 +0000 |
|---|---|---|
| committer | sumuel <samuel@yakubos.org> | 2026-08-17 20:44:55 +0000 |
| commit | 76424950e373d3b04ac3dd13019151bfba3e8423 (patch) | |
| tree | 4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/tpm/tpm_linux.c | |
Add the files
Diffstat (limited to 'src/detection/tpm/tpm_linux.c')
| -rw-r--r-- | src/detection/tpm/tpm_linux.c | 24 |
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; +} |