public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	herbert@gondor.apana.org.au, gaochao <gaochao49@huawei.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH crypto v2] crypto: blake2s - remove shash module
Date: Fri, 27 May 2022 20:59:29 -0700	[thread overview]
Message-ID: <YpGeIT1KHv9QwF4X@sol.localdomain> (raw)
In-Reply-To: <20220527081106.63227-1-Jason@zx2c4.com>

On Fri, May 27, 2022 at 10:11:06AM +0200, Jason A. Donenfeld wrote:
> BLAKE2s has no use as an shash, with no users of it.

"no use" => "no known current use".

> diff --git a/lib/crypto/blake2s-selftest.c b/lib/crypto/blake2s-selftest.c
> index 409e4b728770..38996ee73a64 100644
> --- a/lib/crypto/blake2s-selftest.c
> +++ b/lib/crypto/blake2s-selftest.c
> @@ -4,6 +4,8 @@
>   */
>  
>  #include <crypto/internal/blake2s.h>
> +#include <linux/kernel.h>
> +#include <linux/random.h>
>  #include <linux/string.h>
>  
>  /*
> @@ -548,7 +550,8 @@ bool __init blake2s_selftest(void)
>  	u8 key[BLAKE2S_KEY_SIZE];
>  	u8 buf[ARRAY_SIZE(blake2s_testvecs)];
>  	u8 hash[BLAKE2S_HASH_SIZE];
> -	struct blake2s_state state;
> +	u8 blocks[BLAKE2S_BLOCK_SIZE * 4];
> +	struct blake2s_state state, state1, state2;
>  	bool success = true;
>  	int i, l;
>  
> @@ -587,5 +590,32 @@ bool __init blake2s_selftest(void)
>  		}
>  	}
>  
> +	for (i = 0; i < 2048; ++i) {
> +		get_random_bytes(blocks, sizeof(blocks));
> +		get_random_bytes(&state, sizeof(state));
> +
> +		memcpy(&state1, &state, sizeof(state1));
> +		memcpy(&state2, &state, sizeof(state2));
> +		blake2s_compress(&state1, blocks, 4, sizeof(blocks));
> +		blake2s_compress_generic(&state2, blocks, 4, sizeof(blocks));
> +		if (memcmp(&state1, &state2, sizeof(state1))) {
> +			pr_err("blake2s random compress self-test %d: FAIL\n",
> +			       i + 1);
> +			success = false;
> +		}
> +
> +		for (l = 1; l < 8; ++l) {
> +			memcpy(&state1, &state, sizeof(state1));
> +			memcpy(&state2, &state, sizeof(state2));
> +			blake2s_compress(&state1, blocks + l, 3, sizeof(blocks) - BLAKE2S_BLOCK_SIZE);
> +			blake2s_compress_generic(&state2, blocks + l, 3, sizeof(blocks) - BLAKE2S_BLOCK_SIZE);
> +			if (memcmp(&state1, &state2, sizeof(state1))) {
> +				pr_err("blake2s random compress align %d self-test %d: FAIL\n",
> +				       l, i + 1);
> +				success = false;
> +			}
> +		}
> +	}

This doesn't compile on arm, since blake2s_compress_generic() isn't defined.

Also, the wrong value is being passed for the 'inc' argument.

2048 iterations is also a lot.  Doing a lot of iterations here doesn't
meaningfully increase the test coverage.

And please run checkpatch; those are some very long lines :-(

- Eric

  parent reply	other threads:[~2022-05-28  3:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26  9:20 [PATCH crypto] crypto: blake2s - remove shash module Jason A. Donenfeld
2022-05-26 18:01 ` Eric Biggers
2022-05-27  8:05   ` Jason A. Donenfeld
2022-05-27  8:11     ` [PATCH crypto v2] " Jason A. Donenfeld
2022-05-27 12:36       ` David Laight
2022-05-27 13:20         ` Jason A. Donenfeld
2022-05-28  3:59       ` Eric Biggers [this message]
2022-05-28  9:57         ` Jason A. Donenfeld
2022-05-28 10:07           ` [PATCH crypto v3] " Jason A. Donenfeld
2022-05-28 17:19           ` [PATCH crypto v2] " Eric Biggers
2022-05-28 19:33             ` Jason A. Donenfeld
2022-05-28 19:44               ` [PATCH crypto v4] " Jason A. Donenfeld
2022-06-10  9:16                 ` Herbert Xu
2022-05-30  7:37             ` [PATCH crypto v2] " David Laight
2022-05-30  7:54               ` Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YpGeIT1KHv9QwF4X@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=ardb@kernel.org \
    --cc=gaochao49@huawei.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox