Skip to content

Commit

Permalink
crypto: lib - create utils module and move __crypto_memneq into it
Browse files Browse the repository at this point in the history
As requested at
https://lore.kernel.org/r/[email protected], 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 <[email protected]>
Reviewed-by: Jason A. Donenfeld <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
ebiggers authored and herbertx committed Aug 19, 2022
1 parent 908f242 commit 7033b93
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crypto/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 0 additions & 3 deletions lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ config TRACE_MMIO_ACCESS

source "lib/crypto/Kconfig"

config LIB_MEMNEQ
bool

config CRC_CCITT
tristate "CRC-CCITT functions"
help
Expand Down
1 change: 0 additions & 1 deletion lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion lib/crypto/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

menu "Crypto library routines"

config CRYPTO_LIB_UTILS
tristate

config CRYPTO_LIB_AES
tristate

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/crypto/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion lib/memneq.c → lib/crypto/memneq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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");

0 comments on commit 7033b93

Please sign in to comment.