Skip to content

Commit

Permalink
cpufeatures: add support for DIT detection on Apple silicon (#1100)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tarcieri authored Aug 24, 2024
1 parent 5d46aba commit 1ad4078
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cpufeatures/src/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down

0 comments on commit 1ad4078

Please sign in to comment.