zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit b70c1ad89f96c49d9812655b53c05b690ea42be2 (tree)
parent 3f1dead2fc5922b588fbfb108f421ca957d6934a
Author: Frank Denis <github@pureftpd.org>
Date:   Mon, 20 Apr 2026 12:39:25 +0200

std.crypto.aes: fix BlockVec xorBytes and orBlocks signatures

Both methods had wrong parameter or return types that would cause
compilation failures.

Diffstat:
Mlib/std/crypto/aes/aesni.zig | 2+-
Mlib/std/crypto/aes/armcrypto.zig | 8++++----
Mlib/std/crypto/aes/soft.zig | 8++++----
3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/std/crypto/aes/aesni.zig b/lib/std/crypto/aes/aesni.zig @@ -312,7 +312,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type { } /// Apply the bitwise OR operation to the content of two block vectors. - pub fn orBlocks(block_vec1: Self, block_vec2: Block) Self { + pub fn orBlocks(block_vec1: Self, block_vec2: Self) Self { var out: Self = undefined; inline for (0..native_words) |i| { out.repr[i] = block_vec1.repr[i] | block_vec2.repr[i]; diff --git a/lib/std/crypto/aes/armcrypto.zig b/lib/std/crypto/aes/armcrypto.zig @@ -216,10 +216,10 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type { } /// XOR the block vector with a byte sequence. - pub fn xorBytes(block_vec: Self, bytes: *const [blocks_count * 16]u8) [32]u8 { - var out: Self = undefined; + pub fn xorBytes(block_vec: Self, bytes: *const [blocks_count * 16]u8) [blocks_count * 16]u8 { + var out: [blocks_count * 16]u8 = undefined; inline for (0..native_words) |i| { - out.repr[i] = block_vec.repr[i].xorBytes(bytes[i * native_word_size ..][0..native_word_size]); + out[i * native_word_size ..][0..native_word_size].* = block_vec.repr[i].xorBytes(bytes[i * native_word_size ..][0..native_word_size]); } return out; } @@ -279,7 +279,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type { } /// Apply the bitwise OR operation to the content of two block vectors. - pub fn orBlocks(block_vec1: Self, block_vec2: Block) Self { + pub fn orBlocks(block_vec1: Self, block_vec2: Self) Self { var out: Self = undefined; inline for (0..native_words) |i| { out.repr[i] = block_vec1.repr[i].orBlocks(block_vec2.repr[i]); diff --git a/lib/std/crypto/aes/soft.zig b/lib/std/crypto/aes/soft.zig @@ -391,10 +391,10 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type { } /// XOR the block vector with a byte sequence. - pub fn xorBytes(block_vec: Self, bytes: *const [blocks_count * 16]u8) [32]u8 { - var out: Self = undefined; + pub fn xorBytes(block_vec: Self, bytes: *const [blocks_count * 16]u8) [blocks_count * 16]u8 { + var out: [blocks_count * 16]u8 = undefined; for (0..native_words) |i| { - out.repr[i] = block_vec.repr[i].xorBytes(bytes[i * native_word_size ..][0..native_word_size]); + out[i * native_word_size ..][0..native_word_size].* = block_vec.repr[i].xorBytes(bytes[i * native_word_size ..][0..native_word_size]); } return out; } @@ -454,7 +454,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type { } /// Apply the bitwise OR operation to the content of two block vectors. - pub fn orBlocks(block_vec1: Self, block_vec2: Block) Self { + pub fn orBlocks(block_vec1: Self, block_vec2: Self) Self { var out: Self = undefined; for (0..native_words) |i| { out.repr[i] = block_vec1.repr[i].orBlocks(block_vec2.repr[i]);