authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2026-10-19 15:45:07+02:00
committergravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2026-10-19 15:45:07+02:00
log64caa0e324d522915769dd5cc8a11374f919f01f
tree154c0aa59511df6a7da00eb1b622d303909a832d
parente85c5928ac4ee993edefe42984411a90d0fbbf52
parentddf480d78e067bd13f28c13fd47cc0bb22da7a17

Merge pull request 'crypto.aes: correctly set has_hardware_support' (#37083) from jedisct1/zig:aeshardwaresupport into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37083

1 files changed, 6 insertions(+), 6 deletions(-)

lib/std/crypto/aes.zig+6-6
......@@ -5,10 +5,12 @@ const testing = std.testing;
55const has_aesni = builtin.cpu.has(.x86, .aes);
66const has_avx = builtin.cpu.has(.x86, .avx);
77const has_armaes = builtin.cpu.has(.aarch64, .aes);
8// C backend doesn't currently support passing vectors to inline asm.
9const impl = if (builtin.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
8const use_aesni = builtin.cpu.arch == .x86_64 and has_aesni and has_avx;
9// C backend doesn't currently support passing vectors to inline asm (#37125)
10const use_armaes = builtin.cpu.arch == .aarch64 and (builtin.zig_backend != .stage2_c or !builtin.os.tag.isDarwin()) and has_armaes;
11const impl = if (use_aesni) impl: {
1012 break :impl @import("aes/aesni.zig");
11} else if (builtin.cpu.arch == .aarch64 and (builtin.zig_backend != .stage2_c or !builtin.os.tag.isDarwin()) and has_armaes) impl: {
13} else if (use_armaes) impl: {
1214 break :impl @import("aes/armcrypto.zig");
1315} else impl: {
1416 break :impl @import("aes/soft.zig");
......@@ -16,9 +18,7 @@ const impl = if (builtin.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
1618
1719/// `true` if AES is backed by hardware (AES-NI on x86_64, ARM Crypto Extensions on AArch64).
1820/// Software implementations are much slower, and should be avoided if possible.
19pub const has_hardware_support =
20 (builtin.cpu.arch == .x86_64 and has_aesni and has_avx) or
21 (builtin.cpu.arch == .aarch64 and has_armaes);
21pub const has_hardware_support = use_aesni or use_armaes;
2222
2323pub const Block = impl.Block;
2424pub const BlockVec = impl.BlockVec;