Re: [PATCH] selftests: vDSO: Also test counter in vdso_test_chacha

From
Jason A. Donenfeld <Jason@zx2c4.com>
Date
2024-09-01 18:08:18
Also in
linux-kselftest, lkml
Reply to
Christophe Leroy, 2024-09-01
On Sun, Sep 01, 2024 at 07:40:33PM +0200, Christophe Leroy wrote:
quoted hunk ↗ jump to hunk
-static void reference_chacha20_blocks(uint8_t *dst_bytes, const uint32_t *key, size_t nblocks)
+static void reference_chacha20_blocks(uint8_t *dst_bytes, const uint32_t *key, uint32_t *counter, size_t nblocks)
 {
 	uint32_t s[16] = {
 		0x61707865U, 0x3320646eU, 0x79622d32U, 0x6b206574U,
-		key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7]
+		key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7],
+		counter[0], counter[1],
While you're doing this, also add the remaining, `0, 0` elements.
+			if (memcmp(output1, output2, sizeof(output1)) ||
+			    memcmp(counter2, counter2, sizeof(counter1)))
counter2 will always be counter2. You meant for the first argument to be
counter1.
quoted hunk ↗ jump to hunk
+	reference_chacha20_blocks(output1, key, counter1, BLOCKS);
+	__arch_chacha20_blocks_nostack(output2, key, counter2, BLOCKS);
+	if (memcmp(output1, output2, sizeof(output1)) ||
+	    memcmp(counter2, counter2, sizeof(counter1)))
+		return KSFT_FAIL;
+
+	reference_chacha20_blocks(output1, key, counter1, BLOCKS);
+	__arch_chacha20_blocks_nostack(output2, key, counter2, BLOCKS);
+	if (memcmp(output1, output2, sizeof(output1)) ||
+	    memcmp(counter2, counter2, sizeof(counter1)))
+		return KSFT_FAIL;
+
Why repeat these two stanzas? Also, same issue with counter2 used twice
in that memcmp.
Thread (4 messages) 4 messages, 2 authors, last reply 2024-09-02
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help