| ... | ... | @@ -137,6 +137,18 @@ test "BlockVec invMixColumns" { |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | test "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 | |
| 140 | 152 | test "expand 256-bit key" { |
| 141 | 153 | const key = [_]u8{ |
| 142 | 154 | 0x60, 0x3d, 0xeb, 0x10, |