From 7a755c4d2d13229537c55c291ff3f322ad6aba85 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 20 Apr 2026 12:45:05 +0200 Subject: [PATCH] Add AES tests for or/xor/and blocks --- lib/std/crypto/aes.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/std/crypto/aes.zig b/lib/std/crypto/aes.zig index 99f61eda6c240fda41ea241191e03dbd66c91360..acf3a72e1fd2616a6074f896c3cf53da02364c48 100644 --- 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, -- 2.54.0