authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2026-04-20 12:45:05+02:00
committergravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2026-05-28 16:27:45+02:00
log7a755c4d2d13229537c55c291ff3f322ad6aba85
tree2dfe796cb131bedc51e01fb210d0416efa273128
parentb70c1ad89f96c49d9812655b53c05b690ea42be2

Add AES tests for or/xor/and blocks


1 files changed, 12 insertions(+), 0 deletions(-)

lib/std/crypto/aes.zig+12
...@@ -137,6 +137,18 @@ test "BlockVec invMixColumns" {...@@ -137,6 +137,18 @@ test "BlockVec invMixColumns" {
137 }137 }
138}138}
139139
140test "BlockVec bitwise operations" {
141 const a_bytes: [32]u8 = @splat(0xaa);
142 const b_bytes: [32]u8 = @splat(0xbb);
143 const a = BlockVec(2).fromBytes(&a_bytes);
144 const b = BlockVec(2).fromBytes(&b_bytes);
145
146 try testing.expectEqual(@as([32]u8, @splat(0x11)), a.xorBytes(&b_bytes));
147 try testing.expectEqual(@as([32]u8, @splat(0x11)), a.xorBlocks(b).toBytes());
148 try testing.expectEqual(@as([32]u8, @splat(0xbb)), a.orBlocks(b).toBytes());
149 try testing.expectEqual(@as([32]u8, @splat(0xaa)), a.andBlocks(b).toBytes());
150}
151
140test "expand 256-bit key" {152test "expand 256-bit key" {
141 const key = [_]u8{153 const key = [_]u8{
142 0x60, 0x3d, 0xeb, 0x10,154 0x60, 0x3d, 0xeb, 0x10,