From fd2fbabca9a9f990f77ce9b8cdec5b03491cc908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20=C5=A0pinka?= Date: Mon, 27 Jan 2025 03:15:48 +0100 Subject: [PATCH] Make ChaCha20 tests a bit more didactic. --- src/primitive/streamcipher/chacha20.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/primitive/streamcipher/chacha20.zig b/src/primitive/streamcipher/chacha20.zig index c075ad9..4903637 100644 --- a/src/primitive/streamcipher/chacha20.zig +++ b/src/primitive/streamcipher/chacha20.zig @@ -287,11 +287,11 @@ test "ChaCha Quarter Round" { // https://www.rfc-editor.org/rfc/rfc7539#section-2.3.2 test "ChaCha20 Block Function" { - const key = [_]u8{ + const key = [CHACHA20_KEY_SIZE]u8{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, }; - const nonce = [_]u8{ + const nonce = [ChaCha20_RFC7539_Parameters.NONCE_SIZE]u8{ 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x00, }; @@ -344,3 +344,7 @@ test "ChaCha20 Cipher" { try chacha20_encrypt_inplace(&chacha, &buffer); try testing.expectEqualSlices(u8, reference[0..], buffer[0..]); } + +test "ChaCha20 counter increment edge cases" { + // TODO: test +}