commit 7a755c4d2d13229537c55c291ff3f322ad6aba85 (tree)
parent b70c1ad89f96c49d9812655b53c05b690ea42be2
Author: Frank Denis <github@pureftpd.org>
Date: Mon, 20 Apr 2026 12:45:05 +0200
Add AES tests for or/xor/and blocks
Diffstat:
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/lib/std/crypto/aes.zig b/lib/std/crypto/aes.zig
@@ -137,6 +137,18 @@ test "BlockVec invMixColumns" {
}
}
+test "BlockVec bitwise operations" {
+ const a_bytes: [32]u8 = @splat(0xaa);
+ const b_bytes: [32]u8 = @splat(0xbb);
+ const a = BlockVec(2).fromBytes(&a_bytes);
+ const b = BlockVec(2).fromBytes(&b_bytes);
+
+ try testing.expectEqual(@as([32]u8, @splat(0x11)), a.xorBytes(&b_bytes));
+ try testing.expectEqual(@as([32]u8, @splat(0x11)), a.xorBlocks(b).toBytes());
+ try testing.expectEqual(@as([32]u8, @splat(0xbb)), a.orBlocks(b).toBytes());
+ try testing.expectEqual(@as([32]u8, @splat(0xaa)), a.andBlocks(b).toBytes());
+}
+
test "expand 256-bit key" {
const key = [_]u8{
0x60, 0x3d, 0xeb, 0x10,