Skip to content

Commit b02341d

Browse files
authored
Merge pull request #6614 from jedisct1/aes-arm
std/crypto/aes: add AES hardware acceleration on aarch64
2 parents 1bc2b68 + 60d1e67 commit b02341d

File tree

3 files changed

+499
-2
lines changed

3 files changed

+499
-2
lines changed

lib/std/crypto/aes.zig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ const builtin = std.builtin;
1010

1111
const has_aesni = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
1212
const has_avx = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
13-
const impl = if (std.Target.current.cpu.arch == .x86_64 and has_aesni and has_avx) @import("aes/aesni.zig") else @import("aes/soft.zig");
13+
const has_armaes = comptime std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
14+
const impl = if (std.Target.current.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
15+
break :impl @import("aes/aesni.zig");
16+
} else if (std.Target.current.cpu.arch == .aarch64 and has_armaes)
17+
impl: {
18+
break :impl @import("aes/armcrypto.zig");
19+
} else impl: {
20+
break :impl @import("aes/soft.zig");
21+
};
1422

1523
pub const Block = impl.Block;
1624
pub const AESEncryptCtx = impl.AESEncryptCtx;

lib/std/crypto/aes/aesni.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44
// The MIT license requires this copyright notice to be included in all copies
55
// and substantial portions of the software.
6-
// Based on Go stdlib implementation
76

87
const std = @import("../../std.zig");
98
const mem = std.mem;

0 commit comments

Comments
 (0)