]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: lib - create utils module and move __crypto_memneq into it
authorEric Biggers <ebiggers@google.com>
Mon, 25 Jul 2022 18:36:34 +0000 (11:36 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 19 Aug 2022 10:39:33 +0000 (18:39 +0800)
As requested at
https://lore.kernel.org/r/YtEgzHuuMts0YBCz@gondor.apana.org.au, move
__crypto_memneq into lib/crypto/ and put it under a new tristate.  The
tristate is CRYPTO_LIB_UTILS, and it builds a module libcryptoutils.  As
more crypto library utilities are being added, this creates a single
place for them to go without cluttering up the main lib directory.

The module's main file will be lib/crypto/utils.c.  However, leave
memneq.c as its own file because of its nonstandard license.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/Kconfig
lib/Kconfig
lib/Makefile
lib/crypto/Kconfig
lib/crypto/Makefile
lib/crypto/memneq.c [moved from lib/memneq.c with 99% similarity]

index bb427a835e44a6e57f015e01bd605b923ae6c647..b1ccf873779d429131625bb4ce4941f3aad563b0 100644 (file)
@@ -15,7 +15,7 @@ source "crypto/async_tx/Kconfig"
 #
 menuconfig CRYPTO
        tristate "Cryptographic API"
-       select LIB_MEMNEQ
+       select CRYPTO_LIB_UTILS
        help
          This option provides the core Cryptographic API.
 
index dc1ab2ed1dc6e7d19b9aa492081da04d6a40fee2..6f113ade49ca5469814d52d4afe3207192d21b09 100644 (file)
@@ -127,9 +127,6 @@ config TRACE_MMIO_ACCESS
 
 source "lib/crypto/Kconfig"
 
-config LIB_MEMNEQ
-       bool
-
 config CRC_CCITT
        tristate "CRC-CCITT functions"
        help
index c952121419282fa83397341cce31edcca8b1b258..0eebd502e09d79d0e8157d6e1e5771a80e823d48 100644 (file)
@@ -253,7 +253,6 @@ obj-$(CONFIG_DIMLIB) += dim/
 obj-$(CONFIG_SIGNATURE) += digsig.o
 
 lib-$(CONFIG_CLZ_TAB) += clz_tab.o
-lib-$(CONFIG_LIB_MEMNEQ) += memneq.o
 
 obj-$(CONFIG_GENERIC_STRNCPY_FROM_USER) += strncpy_from_user.o
 obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o
index 9ff549f63540fa3a586382f89d8fcf3886c0940b..b09d9d6546cbc35839824dd9c991b2faed45ad6e 100644 (file)
@@ -2,6 +2,9 @@
 
 menu "Crypto library routines"
 
+config CRYPTO_LIB_UTILS
+       tristate
+
 config CRYPTO_LIB_AES
        tristate
 
@@ -71,7 +74,7 @@ config CRYPTO_LIB_CURVE25519
        tristate "Curve25519 scalar multiplication library"
        depends on CRYPTO_ARCH_HAVE_LIB_CURVE25519 || !CRYPTO_ARCH_HAVE_LIB_CURVE25519
        select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n
-       select LIB_MEMNEQ
+       select CRYPTO_LIB_UTILS
        help
          Enable the Curve25519 library interface. This interface may be
          fulfilled by either the generic implementation or an arch-specific
index 919cbb2c220d617b8dd11deac579c2829e2d5c0c..b956b3bae26aaf6577cc46b66a43c0da96ad7800 100644 (file)
@@ -1,5 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 
+obj-$(CONFIG_CRYPTO_LIB_UTILS)                 += libcryptoutils.o
+libcryptoutils-y                               := memneq.o
+
 # chacha is used by the /dev/random driver which is always builtin
 obj-y                                          += chacha.o
 obj-$(CONFIG_CRYPTO_LIB_CHACHA_GENERIC)                += libchacha.o
similarity index 99%
rename from lib/memneq.c
rename to lib/crypto/memneq.c
index fb11608b1ec1ddaa58f3b6516698261c5395d44e..f20983184284789374fb55b0508c9cc9bade5e8c 100644 (file)
@@ -59,8 +59,9 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <crypto/algapi.h>
 #include <asm/unaligned.h>
+#include <crypto/algapi.h>
+#include <linux/module.h>
 
 #ifndef __HAVE_ARCH_CRYPTO_MEMNEQ
 
@@ -174,3 +175,5 @@ noinline unsigned long __crypto_memneq(const void *a, const void *b,
 EXPORT_SYMBOL(__crypto_memneq);
 
 #endif /* __HAVE_ARCH_CRYPTO_MEMNEQ */
+
+MODULE_LICENSE("GPL");