mbox series

[0/2] crypto: Enable fuzz testing for generic crc32/crc32c

Message ID 20241015141514.3000757-4-ardb+git@google.com (mailing list archive)
Headers show
Series crypto: Enable fuzz testing for generic crc32/crc32c | expand

Message

Ard Biesheuvel Oct. 15, 2024, 2:15 p.m. UTC
From: Ard Biesheuvel <ardb@kernel.org>

crc32-generic and crc32c-generic are built around the architecture
library code for CRC-32, and the lack of distinct drivers for this arch
code means they are lacking test coverage.

Fix this by providing another, truly generic driver built on top of the
generic C code when fuzz testing is enabled.

Ard Biesheuvel (2):
  crypto/crc32: Provide crc32-base alias to enable fuzz testing
  crypto/crc32c: Provide crc32c-base alias to enable fuzz testing

 crypto/crc32_generic.c  | 73 ++++++++++++++------
 crypto/crc32c_generic.c | 72 +++++++++++++------
 crypto/testmgr.c        |  2 +
 3 files changed, 103 insertions(+), 44 deletions(-)

Comments

Eric Biggers Oct. 16, 2024, 2:20 a.m. UTC | #1
On Tue, Oct 15, 2024 at 04:15:15PM +0200, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
> 
> crc32-generic and crc32c-generic are built around the architecture
> library code for CRC-32, and the lack of distinct drivers for this arch
> code means they are lacking test coverage.
> 
> Fix this by providing another, truly generic driver built on top of the
> generic C code when fuzz testing is enabled.

Wouldn't it make more sense to make crc32-generic actually be the generic
implementation, and add crc32-arm64 and crc32-riscv?  Likewise for crc32c.  That
is the usual way that the algorithms get wired up.

Even if we take a shortcut and don't do that, the naming could at least be more
consistent, e.g. rename the existing crc32-generic to crc32-lib and add
crc32-generic alongside that.

- Eric
Herbert Xu Oct. 16, 2024, 4:15 a.m. UTC | #2
On Tue, Oct 15, 2024 at 07:20:51PM -0700, Eric Biggers wrote:
>
> Wouldn't it make more sense to make crc32-generic actually be the generic
> implementation, and add crc32-arm64 and crc32-riscv?  Likewise for crc32c.  That
> is the usual way that the algorithms get wired up.

Agreed.  The library interface can expose the optimal algorithm,
but the Crypto API should not expose the library interface and
should instead hook directly to the C implementation.

Thanks,