From 1ad40787ec88039f829144ef59b7bc506eaf07ed Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 24 Aug 2024 11:28:39 -0600 Subject: [PATCH] cpufeatures: add support for DIT detection on Apple silicon (#1100) Adds support for detecting Data Independent Timing (DIT) support which is available on Apple silicon (e.g. M1/M2/M3). This uses the `hw.optional.arm.FEAT_DIT` sysctl for detection. For more information, see: https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Enable-DIT-for-constant-time-cryptographic-operations --- cpufeatures/src/aarch64.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpufeatures/src/aarch64.rs b/cpufeatures/src/aarch64.rs index 4248a754..58695532 100644 --- a/cpufeatures/src/aarch64.rs +++ b/cpufeatures/src/aarch64.rs @@ -107,6 +107,12 @@ macro_rules! check { ("aes") => { true }; + ("dit") => { + // https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Enable-DIT-for-constant-time-cryptographic-operations + unsafe { + $crate::aarch64::sysctlbyname(b"hw.optional.arm.FEAT_DIT\0") + } + }; ("sha2") => { true };