Revert "std.crypto.aes: use software implementation in comptime context (#13792)" (#13798)

This reverts commit d4adf44200.

Unfortunately, this is not the right place to check if AES functions
are being used at comptime or not.
This commit is contained in:
Frank Denis 2022-12-07 04:49:20 +01:00 committed by GitHub
parent e7d28344fa
commit 14416b522e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,19 +2,10 @@ const std = @import("../std.zig");
const builtin = @import("builtin");
const testing = std.testing;
fn isComptime() bool {
var a: u8 = 0;
return @typeInfo(@TypeOf(.{a})).Struct.fields[0].is_comptime;
}
const has_aesni = std.Target.x86.featureSetHas(builtin.cpu.features, .aes);
const has_avx = std.Target.x86.featureSetHas(builtin.cpu.features, .avx);
const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes);
const impl = if (isComptime())
impl: {
break :impl @import("aes/soft.zig");
} else if (builtin.cpu.arch == .x86_64 and has_aesni and has_avx)
impl: {
const impl = if (builtin.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
break :impl @import("aes/aesni.zig");
} else if (builtin.cpu.arch == .aarch64 and has_armaes)
impl: {