Re: [PATCH v3 2/3] crypto: lib - move __crypto_xor into utils

Eric Biggers
2022-07-26T01:00:25Z

On Tue, Jul 26, 2022 at 12:09:33AM +0200, Jason A. Donenfeld wrote:
> On Mon, Jul 25, 2022 at 11:36:35AM -0700, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> >
> > CRYPTO_LIB_CHACHA depends on CRYPTO for __crypto_xor, defined in
> > crypto/algapi.c. This is a layering violation because the dependencies
> > should only go in the other direction (crypto/ => lib/crypto/). Also
> > the correct dependency would be CRYPTO_ALGAPI, not CRYPTO. Fix this by
> > moving __crypto_xor into the utils module in lib/crypto/.
> >
> > Note that CRYPTO_LIB_CHACHA_GENERIC selected XOR_BLOCKS, which is
> > unrelated and unnecessary. It was perhaps thought that XOR_BLOCKS was
> > needed for __crypto_xor, but that's not the case.
> >
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
>
> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
>
> With one small question:
>
> > --- /dev/null
> > +++ b/lib/crypto/utils.c
> > @@ -0,0 +1,88 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Crypto library utility functions
> > + *
> > + * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
>
> Didn't Ard basically write the crypto_xor function in its current form?
> I seem to remember some pretty hardcore refactoring he did a while back.
>
> Jason

I think that's fair to say, based on git blame. I just copied the copyright
statement from the top of crypto/algapi.c.

- Eric