From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, "Jason A . Donenfeld " <Jason@zx2c4.com>
Subject: [PATCH v3 1/3] crypto: lib - create utils module and move __crypto_memneq into it
Date: Mon, 25 Jul 2022 11:36:34 -0700 [thread overview]
Message-ID: <20220725183636.97326-2-ebiggers@kernel.org> (raw)
In-Reply-To: <20220725183636.97326-1-ebiggers@kernel.org>
From: Eric Biggers <ebiggers@google.com>
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>
---
crypto/Kconfig | 2 +-
lib/Kconfig | 3 ---
lib/Makefile | 1 -
lib/crypto/Kconfig | 5 ++++-
lib/crypto/Makefile | 3 +++
lib/{ => crypto}/memneq.c | 5 ++++-
6 files changed, 12 insertions(+), 7 deletions(-)
rename lib/{ => crypto}/memneq.c (99%)
diff --git a/crypto/Kconfig b/crypto/Kconfig
index e72bf3fc298cc5..7a10441998209d 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -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.
diff --git a/lib/Kconfig b/lib/Kconfig
index eaaad4d85bf24b..6a843639814fbf 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -120,9 +120,6 @@ config INDIRECT_IOMEM_FALLBACK
source "lib/crypto/Kconfig"
-config LIB_MEMNEQ
- bool
-
config CRC_CCITT
tristate "CRC-CCITT functions"
help
diff --git a/lib/Makefile b/lib/Makefile
index 67482f5ec0e899..0557be76c2565f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -251,7 +251,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
diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig
index 9ff549f63540fa..b09d9d6546cbc3 100644
--- a/lib/crypto/Kconfig
+++ b/lib/crypto/Kconfig
@@ -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
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
index 919cbb2c220d61..b956b3bae26aaf 100644
--- a/lib/crypto/Makefile
+++ b/lib/crypto/Makefile
@@ -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
diff --git a/lib/memneq.c b/lib/crypto/memneq.c
similarity index 99%
rename from lib/memneq.c
rename to lib/crypto/memneq.c
index fb11608b1ec1dd..f2098318428478 100644
--- a/lib/memneq.c
+++ b/lib/crypto/memneq.c
@@ -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");
--
2.37.0
next prev parent reply other threads:[~2022-07-25 18:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-25 18:36 [PATCH v3 0/3] crypto: lib - create utils module Eric Biggers
2022-07-25 18:36 ` Eric Biggers [this message]
2022-07-25 22:10 ` [PATCH v3 1/3] crypto: lib - create utils module and move __crypto_memneq into it Jason A. Donenfeld
2022-07-25 18:36 ` [PATCH v3 2/3] crypto: lib - move __crypto_xor into utils Eric Biggers
2022-07-25 22:09 ` Jason A. Donenfeld
2022-07-26 1:00 ` Eric Biggers
2022-07-26 13:46 ` Ard Biesheuvel
2022-08-26 4:44 ` Eric Biggers
2022-08-26 4:46 ` Herbert Xu
2022-08-26 4:48 ` Eric Biggers
2022-08-26 4:52 ` Herbert Xu
2022-08-26 5:07 ` Eric Biggers
2022-07-25 18:36 ` [PATCH v3 3/3] crypto: lib - remove __HAVE_ARCH_CRYPTO_MEMNEQ Eric Biggers
2022-07-25 22:07 ` Jason A. Donenfeld
2022-07-26 0:51 ` Eric Biggers
2022-08-19 10:59 ` [PATCH v3 0/3] crypto: lib - create utils module Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220725183636.97326-2-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.