| ... | ... | @@ -590,21 +590,21 @@ fn ChaChaWith64BitNonce(comptime rounds_nb: usize) type { |
| 590 | 590 | |
| 591 | 591 | const k = keyToWords(key); |
| 592 | 592 | 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); |
| 595 | 595 | c[2] = mem.readInt(u32, nonce[0..4], .little); |
| 596 | 596 | c[3] = mem.readInt(u32, nonce[4..8], .little); |
| 597 | 597 | ChaChaImpl(rounds_nb).chacha20Xor(out, in, k, c, true); |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | /// 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 { |
| 602 | 602 | assert(out.len <= 64 * (@as(u71, 1 << 64) - counter)); |
| 603 | 603 | |
| 604 | 604 | const k = keyToWords(key); |
| 605 | 605 | 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); |
| 608 | 608 | c[2] = mem.readInt(u32, nonce[0..4], .little); |
| 609 | 609 | c[3] = mem.readInt(u32, nonce[4..8], .little); |
| 610 | 610 | ChaChaImpl(rounds_nb).chacha20Stream(out, k, c, true); |