[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZtStjU_3K9yIJsmp@zx2c4.com>
Date: Sun, 1 Sep 2024 20:08:13 +0200
From: "Jason A. Donenfeld" <Jason@...c4.com>
To: Christophe Leroy <christophe.leroy@...roup.eu>
Cc: Shuah Khan <shuah@...nel.org>, linux-kernel@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH] selftests: vDSO: Also test counter in vdso_test_chacha
On Sun, Sep 01, 2024 at 07:40:33PM +0200, Christophe Leroy wrote:
> -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.
> + 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.
Powered by blists - more mailing lists