]> www.infradead.org Git - users/jedix/linux-maple.git/commit
crypto: poly1305 - centralize the shash wrappers for arch code
authorEric Biggers <ebiggers@google.com>
Sun, 13 Apr 2025 04:54:14 +0000 (21:54 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 16 Apr 2025 07:36:24 +0000 (15:36 +0800)
commitecaa4be1280a4faf72dc4b6b4f6d867332d5762e
tree391778d51d75db5691d9fcf5625c0cb0f9146ffb
parent378a337ab40f88d63ba71d68ff578ead7f5ac8f1
crypto: poly1305 - centralize the shash wrappers for arch code

Following the example of the crc32, crc32c, and chacha code, make the
crypto subsystem register both generic and architecture-optimized
poly1305 shash algorithms, both implemented on top of the appropriate
library functions.  This eliminates the need for every architecture to
implement the same shash glue code.

Note that the poly1305 shash requires that the key be prepended to the
data, which differs from the library functions where the key is simply a
parameter to poly1305_init().  Previously this was handled at a fairly
low level, polluting the library code with shash-specific code.
Reorganize things so that the shash code handles this quirk itself.

Also, to register the architecture-optimized shashes only when
architecture-optimized code is actually being used, add a function
poly1305_is_arch_optimized() and make each arch implement it.  Change
each architecture's Poly1305 module_init function to arch_initcall so
that the CPU feature detection is guaranteed to run before
poly1305_is_arch_optimized() gets called by crypto/poly1305.c.  (In
cases where poly1305_is_arch_optimized() just returns true
unconditionally, using arch_initcall is not strictly needed, but it's
still good to be consistent across architectures.)

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/arm/crypto/poly1305-glue.c
arch/arm64/crypto/poly1305-glue.c
arch/mips/crypto/poly1305-glue.c
arch/powerpc/crypto/poly1305-p10-glue.c
arch/x86/crypto/poly1305_glue.c
crypto/Makefile
crypto/poly1305.c [new file with mode: 0644]
crypto/poly1305_generic.c [deleted file]
include/crypto/poly1305.h