Re: [PATCH 2/5] crypto: blake2b - define shash_alg structs using macros

Eric Biggers
2020-12-17T18:37:03Z

On Thu, Dec 17, 2020 at 06:15:17PM +0100, David Sterba wrote:
> On Tue, Dec 15, 2020 at 03:47:05PM -0800, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> >
> > The shash_alg structs for the four variants of BLAKE2b are identical
> > except for the algorithm name, driver name, and digest size. So, avoid
> > code duplication by using a macro to define these structs.
> >
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
>
> Reviewed-by: David Sterba <dsterba@suse.com>
>
> > +static struct shash_alg blake2b_algs[] = {
> > + BLAKE2B_ALG("blake2b-160", "blake2b-160-generic",
> > + BLAKE2B_160_HASH_SIZE),
>
> Spelling out the algo names as string is better as it is greppable and
> matches the module name, compared to using the #stringify macro
> operator.
>

Yes, I considered trying to make it so that BLAKE2B_ALG(n) would generate the
names and constant for blake2b-$n, but it seemed better to keep it greppable.

- Eric