From 031aa985f17f3d7f796669c69fe89d671f214a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 31 Mar 2025 23:40:01 +0800 Subject: [PATCH] TPM (macOS): add support --- CMakeLists.txt | 2 +- src/detection/tpm/tpm_apple.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/detection/tpm/tpm_apple.c diff --git a/CMakeLists.txt b/CMakeLists.txt index e189babbb..db5c697be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -947,7 +947,7 @@ elseif(APPLE) src/detection/terminalshell/terminalshell_linux.c src/detection/terminalsize/terminalsize_linux.c src/detection/theme/theme_nosupport.c - src/detection/tpm/tpm_nosupport.c + src/detection/tpm/tpm_apple.c src/detection/uptime/uptime_bsd.c src/detection/users/users_linux.c src/detection/wallpaper/wallpaper_apple.m diff --git a/src/detection/tpm/tpm_apple.c b/src/detection/tpm/tpm_apple.c new file mode 100644 index 000000000..8e22d5dc9 --- /dev/null +++ b/src/detection/tpm/tpm_apple.c @@ -0,0 +1,31 @@ +#include "tpm.h" + +#ifndef __aarch64__ + #include "util/apple/cf_helpers.h" + #include +#endif + +const char* ffDetectTPM(FFTPMResult* result) +{ + #ifdef __aarch64__ + + ffStrbufSetStatic(&result->version, "2.0"); + ffStrbufSetStatic(&result->description, "Apple Silicon Security"); + return NULL; + + #else + + FF_IOOBJECT_AUTO_RELEASE io_service_t t2Service = IOServiceGetMatchingService( + kIOMainPortDefault, + IOServiceMatching("AppleT2")); + + if (t2Service) { + ffStrbufSetStatic(&result->version, "2.0"); + ffStrbufSetStatic(&result->description, "Apple T2 Security Chip"); + return NULL; + } + + #endif + + return "No Apple Security hardware detected"; +}