authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2024-07-23 01:04:32+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-07-22 23:04:32+00:00
logd2c9a51d1e9aa9de1341bfb52caf8b15daffe79c
treeaf06d88cba46dd1fd6180ea3cc1f9aa09f9f520f
parenteac7fd4da5992299a1f2fb59c5aa237c0c6c6761
signaturebadge-check Signed by PGP key B5690EEEBB952194

Fix function definition: ChaCha20With64BitNonce counter is u64 (#20734)

Fixes #20732

1 files changed, 5 insertions(+), 5 deletions(-)

lib/std/crypto/chacha20.zig+5-5
......@@ -590,21 +590,21 @@ fn ChaChaWith64BitNonce(comptime rounds_nb: usize) type {
590590
591591 const k = keyToWords(key);
592592 var c: [4]u32 = undefined;
593 c[0] = @as(u32, @truncate(counter));
594 c[1] = @as(u32, @truncate(counter >> 32));
593 c[0] = @truncate(counter);
594 c[1] = @truncate(counter >> 32);
595595 c[2] = mem.readInt(u32, nonce[0..4], .little);
596596 c[3] = mem.readInt(u32, nonce[4..8], .little);
597597 ChaChaImpl(rounds_nb).chacha20Xor(out, in, k, c, true);
598598 }
599599
600600 /// Write the output of the ChaCha20 stream cipher into `out`.
601 pub fn stream(out: []u8, counter: u32, key: [key_length]u8, nonce: [nonce_length]u8) void {
601 pub fn stream(out: []u8, counter: u64, key: [key_length]u8, nonce: [nonce_length]u8) void {
602602 assert(out.len <= 64 * (@as(u71, 1 << 64) - counter));
603603
604604 const k = keyToWords(key);
605605 var c: [4]u32 = undefined;
606 c[0] = @as(u32, @truncate(counter));
607 c[1] = @as(u32, @truncate(counter >> 32));
606 c[0] = @truncate(counter);
607 c[1] = @truncate(counter >> 32);
608608 c[2] = mem.readInt(u32, nonce[0..4], .little);
609609 c[3] = mem.readInt(u32, nonce[4..8], .little);
610610 ChaChaImpl(rounds_nb).chacha20Stream(out, k, c, true);