public inbox for linux-modules@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 087/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_RNG crypto
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_USER_API_RNG-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile    | 2 +-
 crypto/algif_rng.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 13d0ee856885..9d96e67cdfdf 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -175,7 +175,7 @@ crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
-obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
+crypto-objs-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
 obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
 obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
 crypto-objs-$(CONFIG_CRYPTO_ECC) += ecc.o
diff --git a/crypto/algif_rng.c b/crypto/algif_rng.c
index 1a86e40c8372..1604b164d973 100644
--- a/crypto/algif_rng.c
+++ b/crypto/algif_rng.c
@@ -335,5 +335,5 @@ static void __exit rng_exit(void)
 	BUG_ON(err);
 }
 
-module_init(rng_init);
-module_exit(rng_exit);
+crypto_module_init(rng_init);
+crypto_module_exit(rng_exit);
-- 
2.47.3


^ permalink raw reply related

* [PATCH 086/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_HASH crypto
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_USER_API_HASH-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile     | 2 +-
 crypto/algif_hash.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 39b42843d321..13d0ee856885 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -173,7 +173,7 @@ crypto-objs-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testin
 crypto-objs-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
-obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
+crypto-objs-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
 obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
 obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index 4d3dfc60a16a..b5ec5cfb2ae8 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -464,7 +464,7 @@ static void __exit algif_hash_exit(void)
 	BUG_ON(err);
 }
 
-module_init(algif_hash_init);
-module_exit(algif_hash_exit);
+crypto_module_init(algif_hash_init);
+crypto_module_exit(algif_hash_exit);
 MODULE_DESCRIPTION("Userspace interface for hash algorithms");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 085/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BENCHMARK crypto
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_BENCHMARK-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/tcrypt.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index d1db3a1e3b3b..39b42843d321 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -170,7 +170,7 @@ KASAN_SANITIZE_jitterentropy.o = n
 UBSAN_SANITIZE_jitterentropy.o = n
 jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o
 crypto-objs-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testing.o
-obj-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
+crypto-objs-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
 obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 62fef100e599..1f3b6c1922cb 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -2840,8 +2840,8 @@ static int __init tcrypt_mod_init(void)
  */
 static void __exit tcrypt_mod_fini(void) { }
 
-late_initcall(tcrypt_mod_init);
-module_exit(tcrypt_mod_fini);
+crypto_late_initcall(tcrypt_mod_init);
+crypto_module_exit(tcrypt_mod_fini);
 
 module_param(alg, charp, 0);
 module_param(type, uint, 0);
-- 
2.47.3


^ permalink raw reply related

* [PATCH 084/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE crypto
From: Jay Wang @ 2026-02-12  2:47 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Unlike most patches, we do not add a DECLARE_CRYPTO_API() wrapper for the
exported function in crypto/jitterentropy.h. This is because this header is
used by both jitterentropy_rng.o and jitterentropy-testing.o, but the
compilation flags for jitterentropy_rng.o do not support declaration of a
static call key.

This is acceptable since the only user of this exported function is
jitterentropy_rng.o itself. The jitterentropy-testing.o code will naturally
either be included alongside jitterentropy_rng.o in the crypto kernel
module, or it will be disabled.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 66319c92a983..d1db3a1e3b3b 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -169,7 +169,7 @@ CFLAGS_jitterentropy.o = -O0
 KASAN_SANITIZE_jitterentropy.o = n
 UBSAN_SANITIZE_jitterentropy.o = n
 jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o
-obj-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testing.o
+crypto-objs-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testing.o
 obj-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
-- 
2.47.3


^ permalink raw reply related

* [PATCH 083/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_842 crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_842-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/842.c    | 4 ++--
 crypto/Makefile | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/842.c b/crypto/842.c
index 4007e87bed80..965f0f8dbc43 100644
--- a/crypto/842.c
+++ b/crypto/842.c
@@ -72,13 +72,13 @@ static int __init crypto842_mod_init(void)
 {
 	return crypto_register_scomp(&scomp);
 }
-module_init(crypto842_mod_init);
+crypto_module_init(crypto842_mod_init);
 
 static void __exit crypto842_mod_exit(void)
 {
 	crypto_unregister_scomp(&scomp);
 }
-module_exit(crypto842_mod_exit);
+crypto_module_exit(crypto842_mod_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("842 Software Compression Algorithm");
diff --git a/crypto/Makefile b/crypto/Makefile
index 6dc023d0851c..66319c92a983 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -161,7 +161,7 @@ crypto-objs-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
 crypto-objs-$(CONFIG_CRYPTO_LZ4) += lz4.o
 crypto-objs-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
 crypto-objs-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
-obj-$(CONFIG_CRYPTO_842) += 842.o
+crypto-objs-$(CONFIG_CRYPTO_842) += 842.o
 crypto-objs-$(CONFIG_CRYPTO_RNG2) += rng.o
 crypto-objs-$(CONFIG_CRYPTO_DRBG) += drbg.o
 crypto-objs-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
-- 
2.47.3


^ permalink raw reply related

* [PATCH 082/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_XXHASH crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_XXHASH-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile         | 2 +-
 crypto/xxhash_generic.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 665299fd5a5a..6dc023d0851c 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -160,7 +160,7 @@ crypto-objs-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
 crypto-objs-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
 crypto-objs-$(CONFIG_CRYPTO_LZ4) += lz4.o
 crypto-objs-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
-obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
+crypto-objs-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
 obj-$(CONFIG_CRYPTO_842) += 842.o
 crypto-objs-$(CONFIG_CRYPTO_RNG2) += rng.o
 crypto-objs-$(CONFIG_CRYPTO_DRBG) += drbg.o
diff --git a/crypto/xxhash_generic.c b/crypto/xxhash_generic.c
index 175bb7ae0fcd..4e41c4d213df 100644
--- a/crypto/xxhash_generic.c
+++ b/crypto/xxhash_generic.c
@@ -96,8 +96,8 @@ static void __exit xxhash_mod_fini(void)
 	crypto_unregister_shash(&alg);
 }
 
-module_init(xxhash_mod_init);
-module_exit(xxhash_mod_fini);
+crypto_module_init(xxhash_mod_init);
+crypto_module_exit(xxhash_mod_fini);
 
 MODULE_AUTHOR("Nikolay Borisov <nborisov@suse.com>");
 MODULE_DESCRIPTION("xxhash calculations wrapper for lib/xxhash.c");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 081/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LZ4 and CONFIG_CRYPTO_LZ4HC crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_LZ4- and CONFIG_CRYPTO_LZ4HC-related crypto to convert
them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 4 ++--
 crypto/lz4.c    | 4 ++--
 crypto/lz4hc.c  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 61fdf39dc1ec..665299fd5a5a 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -158,8 +158,8 @@ crc32-cryptoapi-y := crc32.o
 crypto-objs-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
 crypto-objs-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
 crypto-objs-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
-obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
-obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
+crypto-objs-$(CONFIG_CRYPTO_LZ4) += lz4.o
+crypto-objs-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
 obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
 obj-$(CONFIG_CRYPTO_842) += 842.o
 crypto-objs-$(CONFIG_CRYPTO_RNG2) += rng.o
diff --git a/crypto/lz4.c b/crypto/lz4.c
index 57b713516aef..e0aa6f465627 100644
--- a/crypto/lz4.c
+++ b/crypto/lz4.c
@@ -91,8 +91,8 @@ static void __exit lz4_mod_fini(void)
 	crypto_unregister_scomp(&scomp);
 }
 
-module_init(lz4_mod_init);
-module_exit(lz4_mod_fini);
+crypto_module_init(lz4_mod_init);
+crypto_module_exit(lz4_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("LZ4 Compression Algorithm");
diff --git a/crypto/lz4hc.c b/crypto/lz4hc.c
index bb84f8a68cb5..5365a0a8477d 100644
--- a/crypto/lz4hc.c
+++ b/crypto/lz4hc.c
@@ -89,8 +89,8 @@ static void __exit lz4hc_mod_fini(void)
 	crypto_unregister_scomp(&scomp);
 }
 
-module_init(lz4hc_mod_init);
-module_exit(lz4hc_mod_fini);
+crypto_module_init(lz4hc_mod_init);
+crypto_module_exit(lz4hc_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("LZ4HC Compression Algorithm");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 080/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KRB5ENC crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_KRB5ENC-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/fips140/fips140-api.c | 10 ++++++++++
 crypto/krb5enc.c             |  4 ++--
 include/crypto/authenc.h     |  6 ++++--
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 6d332c55fd4e..61fdf39dc1ec 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -156,7 +156,7 @@ crc32c-cryptoapi-y := crc32c.o
 crypto-objs-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
 crc32-cryptoapi-y := crc32.o
 crypto-objs-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
-obj-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
+crypto-objs-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
 crypto-objs-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
 obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
 obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index e6d2e3680792..70b57939c753 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -775,3 +775,13 @@ DEFINE_CRYPTO_API_STUB(aria_encrypt);
 DEFINE_CRYPTO_API_STUB(aria_decrypt);
 
 #endif
+/*
+ * crypto/krb5enc.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_KRB5ENC)
+
+#include <crypto/authenc.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_krb5enc_extractkeys);
+
+#endif
diff --git a/crypto/krb5enc.c b/crypto/krb5enc.c
index a1de55994d92..5688f8916fd0 100644
--- a/crypto/krb5enc.c
+++ b/crypto/krb5enc.c
@@ -496,8 +496,8 @@ static void __exit crypto_krb5enc_module_exit(void)
 	crypto_unregister_template(&crypto_krb5enc_tmpl);
 }
 
-module_init(crypto_krb5enc_module_init);
-module_exit(crypto_krb5enc_module_exit);
+crypto_module_init(crypto_krb5enc_module_init);
+crypto_module_exit(crypto_krb5enc_module_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Simple AEAD wrapper for Kerberos 5 RFC3961");
diff --git a/include/crypto/authenc.h b/include/crypto/authenc.h
index 4871b7bdcd8e..710e0976b295 100644
--- a/include/crypto/authenc.h
+++ b/include/crypto/authenc.h
@@ -30,7 +30,9 @@ struct crypto_authenc_keys {
 DECLARE_CRYPTO_API(CONFIG_CRYPTO_AUTHENC, crypto_authenc_extractkeys, int,
 	(struct crypto_authenc_keys *keys, const u8 *key, unsigned int keylen),
 	(keys, key, keylen));
-int crypto_krb5enc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key,
-			       unsigned int keylen);
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_KRB5ENC, crypto_krb5enc_extractkeys, int,
+	(struct crypto_authenc_keys *keys, const u8 *key, unsigned int keylen),
+	(keys, key, keylen));
 
 #endif	/* _CRYPTO_AUTHENC_H */
-- 
2.47.3


^ permalink raw reply related

* [PATCH 079/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CRC32C and CONFIG_CRYPTO_CRC32 crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CRC32C- and CONFIG_CRYPTO_CRC32-related crypto to convert
them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 4 ++--
 crypto/crc32.c  | 4 ++--
 crypto/crc32c.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index f8cd388ca03c..6d332c55fd4e 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -151,9 +151,9 @@ crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
 crypto-objs-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
 crypto-objs-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
-obj-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
+crypto-objs-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
 crc32c-cryptoapi-y := crc32c.o
-obj-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
+crypto-objs-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
 crc32-cryptoapi-y := crc32.o
 crypto-objs-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
 obj-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
diff --git a/crypto/crc32.c b/crypto/crc32.c
index 489cbed9422e..cfbf86ed9926 100644
--- a/crypto/crc32.c
+++ b/crypto/crc32.c
@@ -120,8 +120,8 @@ static void __exit crc32_mod_fini(void)
 	crypto_unregister_shash(&alg);
 }
 
-module_init(crc32_mod_init);
-module_exit(crc32_mod_fini);
+crypto_module_init(crc32_mod_init);
+crypto_module_exit(crc32_mod_fini);
 
 MODULE_AUTHOR("Alexander Boyko <alexander_boyko@xyratex.com>");
 MODULE_DESCRIPTION("CRC32 calculations wrapper for lib/crc32");
diff --git a/crypto/crc32c.c b/crypto/crc32c.c
index 1eff54dde2f7..d8122c4aa26e 100644
--- a/crypto/crc32c.c
+++ b/crypto/crc32c.c
@@ -157,8 +157,8 @@ static void __exit crc32c_mod_fini(void)
 	crypto_unregister_shash(&alg);
 }
 
-module_init(crc32c_mod_init);
-module_exit(crc32c_mod_fini);
+crypto_module_init(crc32c_mod_init);
+crypto_module_exit(crc32c_mod_fini);
 
 MODULE_AUTHOR("Clay Haapala <chaapala@cisco.com>");
 MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations wrapper for lib/crc32c");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 078/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MICHAEL_MIC crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_MICHAEL_MIC-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile      | 2 +-
 crypto/michael_mic.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index a989d103c191..f8cd388ca03c 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -150,7 +150,7 @@ crypto-objs-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
 crypto-objs-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
-obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
+crypto-objs-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
 obj-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
 crc32c-cryptoapi-y := crc32c.o
 obj-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
diff --git a/crypto/michael_mic.c b/crypto/michael_mic.c
index 69ad35f524d7..8acdf39a7004 100644
--- a/crypto/michael_mic.c
+++ b/crypto/michael_mic.c
@@ -167,8 +167,8 @@ static void __exit michael_mic_exit(void)
 }
 
 
-module_init(michael_mic_init);
-module_exit(michael_mic_exit);
+crypto_module_init(michael_mic_init);
+crypto_module_exit(michael_mic_exit);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("Michael MIC");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 077/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DEFLATE crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_DEFLATE-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile  | 2 +-
 crypto/deflate.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index c7dcc0e55325..a989d103c191 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -149,7 +149,7 @@ crypto-objs-$(CONFIG_CRYPTO_SEED) += seed.o
 crypto-objs-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
-obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
+crypto-objs-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
 obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
 obj-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
 crc32c-cryptoapi-y := crc32c.o
diff --git a/crypto/deflate.c b/crypto/deflate.c
index a3e1fff55661..7c8e331556cf 100644
--- a/crypto/deflate.c
+++ b/crypto/deflate.c
@@ -249,8 +249,8 @@ static void __exit deflate_mod_fini(void)
 	crypto_acomp_free_streams(&deflate_streams);
 }
 
-module_init(deflate_mod_init);
-module_exit(deflate_mod_fini);
+crypto_module_init(deflate_mod_init);
+crypto_module_exit(deflate_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Deflate Compression Algorithm for IPCOMP");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 076/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ARIA crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ARIA-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/aria_generic.c        |  4 ++--
 crypto/fips140/fips140-api.c | 12 ++++++++++++
 include/crypto/aria.h        | 16 ++++++++++++----
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 3e515caa72f5..c7dcc0e55325 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -146,7 +146,7 @@ crypto-objs-$(CONFIG_CRYPTO_TEA) += tea.o
 crypto-objs-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 crypto-objs-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 crypto-objs-$(CONFIG_CRYPTO_SEED) += seed.o
-obj-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
+crypto-objs-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
 obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
diff --git a/crypto/aria_generic.c b/crypto/aria_generic.c
index faa7900383f6..7a66ae96312a 100644
--- a/crypto/aria_generic.c
+++ b/crypto/aria_generic.c
@@ -304,8 +304,8 @@ static void __exit aria_fini(void)
 	crypto_unregister_alg(&aria_alg);
 }
 
-module_init(aria_init);
-module_exit(aria_fini);
+crypto_module_init(aria_init);
+crypto_module_exit(aria_fini);
 
 MODULE_DESCRIPTION("ARIA Cipher Algorithm");
 MODULE_LICENSE("GPL");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index e20c9601637a..e6d2e3680792 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -763,3 +763,15 @@ DEFINE_CRYPTO_API_STUB(af_alg_alloc_areq);
 DEFINE_CRYPTO_API_STUB(af_alg_get_rsgl);
 
 #endif
+/*
+ * crypto/aria_generic.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ARIA)
+
+#include <crypto/aria.h>
+
+DEFINE_CRYPTO_API_STUB(aria_set_key);
+DEFINE_CRYPTO_API_STUB(aria_encrypt);
+DEFINE_CRYPTO_API_STUB(aria_decrypt);
+
+#endif
diff --git a/include/crypto/aria.h b/include/crypto/aria.h
index 73295146be11..55108db53ca3 100644
--- a/include/crypto/aria.h
+++ b/include/crypto/aria.h
@@ -18,6 +18,7 @@
 #ifndef _CRYPTO_ARIA_H
 #define _CRYPTO_ARIA_H
 
+#include <crypto/api.h>
 #include <crypto/algapi.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -450,9 +451,16 @@ static inline void aria_gsrk(u32 *rk, u32 *x, u32 *y, u32 n)
 		((y[(q + 2) % 4]) << (32 - r));
 }
 
-void aria_encrypt(void *ctx, u8 *out, const u8 *in);
-void aria_decrypt(void *ctx, u8 *out, const u8 *in);
-int aria_set_key(struct crypto_tfm *tfm, const u8 *in_key,
-		 unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ARIA, aria_encrypt, void,
+	(void *ctx, u8 *out, const u8 *in),
+	(ctx, out, in));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ARIA, aria_decrypt, void,
+	(void *ctx, u8 *out, const u8 *in),
+	(ctx, out, in));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ARIA, aria_set_key, int,
+	(struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len),
+	(tfm, in_key, key_len));
 
 #endif
-- 
2.47.3


^ permalink raw reply related

* [PATCH 075/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SEED crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SEED-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/seed.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index fb863dcef44f..3e515caa72f5 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -145,7 +145,7 @@ crypto-objs-$(CONFIG_CRYPTO_ARC4) += arc4.o
 crypto-objs-$(CONFIG_CRYPTO_TEA) += tea.o
 crypto-objs-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 crypto-objs-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
-obj-$(CONFIG_CRYPTO_SEED) += seed.o
+crypto-objs-$(CONFIG_CRYPTO_SEED) += seed.o
 obj-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
 CFLAGS_chacha.o += -DARCH=$(ARCH)
diff --git a/crypto/seed.c b/crypto/seed.c
index 815391f213de..f98ea0d623bd 100644
--- a/crypto/seed.c
+++ b/crypto/seed.c
@@ -460,8 +460,8 @@ static void __exit seed_fini(void)
 	crypto_unregister_alg(&seed_alg);
 }
 
-module_init(seed_init);
-module_exit(seed_fini);
+crypto_module_init(seed_init);
+crypto_module_exit(seed_fini);
 
 MODULE_DESCRIPTION("SEED Cipher Algorithm");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 074/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ANUBIS crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ANUBIS-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/anubis.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 87f1b0e315f2..fb863dcef44f 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -144,7 +144,7 @@ crypto-objs-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
 crypto-objs-$(CONFIG_CRYPTO_ARC4) += arc4.o
 crypto-objs-$(CONFIG_CRYPTO_TEA) += tea.o
 crypto-objs-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
-obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
+crypto-objs-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 obj-$(CONFIG_CRYPTO_SEED) += seed.o
 obj-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CHACHA20) += chacha.o
diff --git a/crypto/anubis.c b/crypto/anubis.c
index 4b01b6ec961a..3d179d739fbd 100644
--- a/crypto/anubis.c
+++ b/crypto/anubis.c
@@ -691,8 +691,8 @@ static void __exit anubis_mod_fini(void)
 	crypto_unregister_alg(&anubis_alg);
 }
 
-module_init(anubis_mod_init);
-module_exit(anubis_mod_fini);
+crypto_module_init(anubis_mod_init);
+crypto_module_exit(anubis_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Anubis Cryptographic Algorithm");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 073/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_KHAZAD crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_KHAZAD-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/khazad.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 1854a70babc0..87f1b0e315f2 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -143,7 +143,7 @@ crypto-objs-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
 crypto-objs-$(CONFIG_CRYPTO_ARC4) += arc4.o
 crypto-objs-$(CONFIG_CRYPTO_TEA) += tea.o
-obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
+crypto-objs-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 obj-$(CONFIG_CRYPTO_SEED) += seed.o
 obj-$(CONFIG_CRYPTO_ARIA) += aria_generic.o
diff --git a/crypto/khazad.c b/crypto/khazad.c
index dee54ad5f0e4..d54214a9bc3f 100644
--- a/crypto/khazad.c
+++ b/crypto/khazad.c
@@ -868,8 +868,8 @@ static void __exit khazad_mod_fini(void)
 }
 
 
-module_init(khazad_mod_init);
-module_exit(khazad_mod_fini);
+crypto_module_init(khazad_mod_init);
+crypto_module_exit(khazad_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Khazad Cryptographic Algorithm");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 072/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_TEA crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_TEA-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/tea.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index a7ad0f5dd1d9..1854a70babc0 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -142,7 +142,7 @@ crypto-objs-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
 crypto-objs-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
 crypto-objs-$(CONFIG_CRYPTO_ARC4) += arc4.o
-obj-$(CONFIG_CRYPTO_TEA) += tea.o
+crypto-objs-$(CONFIG_CRYPTO_TEA) += tea.o
 obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 obj-$(CONFIG_CRYPTO_SEED) += seed.o
diff --git a/crypto/tea.c b/crypto/tea.c
index cb05140e3470..9f42e296377f 100644
--- a/crypto/tea.c
+++ b/crypto/tea.c
@@ -255,8 +255,8 @@ MODULE_ALIAS_CRYPTO("tea");
 MODULE_ALIAS_CRYPTO("xtea");
 MODULE_ALIAS_CRYPTO("xeta");
 
-module_init(tea_mod_init);
-module_exit(tea_mod_fini);
+crypto_module_init(tea_mod_init);
+crypto_module_exit(tea_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("TEA, XTEA & XETA Cryptographic Algorithms");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 071/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API_SKCIPHER crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_USER_API_SKCIPHER-related crypto to convert them into
pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile         | 2 +-
 crypto/algif_skcipher.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 5c363d865b45..a7ad0f5dd1d9 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -174,7 +174,7 @@ obj-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
 crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
 obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
-obj-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
+crypto-objs-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
 obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
 obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
 obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 125d395c5e00..8fbfb6c7ba14 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -435,7 +435,7 @@ static void __exit algif_skcipher_exit(void)
 	BUG_ON(err);
 }
 
-module_init(algif_skcipher_init);
-module_exit(algif_skcipher_exit);
+crypto_module_init(algif_skcipher_init);
+crypto_module_exit(algif_skcipher_exit);
 MODULE_DESCRIPTION("Userspace interface for skcipher algorithms");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 070/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_USER_API crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_USER_API-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/af_alg.c              |  4 +-
 crypto/fips140/fips140-api.c | 25 +++++++++++
 include/crypto/if_alg.h      | 84 ++++++++++++++++++++++++++----------
 4 files changed, 89 insertions(+), 26 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 623651445612..5c363d865b45 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -172,7 +172,7 @@ jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o
 obj-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testing.o
 obj-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
-obj-$(CONFIG_CRYPTO_USER_API) += af_alg.o
+crypto-objs-$(CONFIG_CRYPTO_USER_API) += af_alg.o
 obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
 obj-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
 obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index e468714f539d..48ce5a420fed 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -1322,8 +1322,8 @@ static void __exit af_alg_exit(void)
 	proto_unregister(&alg_proto);
 }
 
-module_init(af_alg_init);
-module_exit(af_alg_exit);
+crypto_module_init(af_alg_init);
+crypto_module_exit(af_alg_exit);
 MODULE_DESCRIPTION("Crypto userspace interface");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_NETPROTO(AF_ALG);
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index f6d6a6e79a9e..e20c9601637a 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -738,3 +738,28 @@ DEFINE_CRYPTO_API_STUB(__cast6_encrypt);
 DEFINE_CRYPTO_API_STUB(__cast6_decrypt);
 
 #endif
+/*
+ * crypto/af_alg.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_USER_API)
+
+#include <crypto/if_alg.h>
+
+DEFINE_CRYPTO_API_STUB(af_alg_register_type);
+DEFINE_CRYPTO_API_STUB(af_alg_unregister_type);
+DEFINE_CRYPTO_API_STUB(af_alg_release);
+DEFINE_CRYPTO_API_STUB(af_alg_release_parent);
+DEFINE_CRYPTO_API_STUB(af_alg_accept);
+DEFINE_CRYPTO_API_STUB(af_alg_free_sg);
+DEFINE_CRYPTO_API_STUB(af_alg_count_tsgl);
+DEFINE_CRYPTO_API_STUB(af_alg_pull_tsgl);
+DEFINE_CRYPTO_API_STUB(af_alg_wmem_wakeup);
+DEFINE_CRYPTO_API_STUB(af_alg_wait_for_data);
+DEFINE_CRYPTO_API_STUB(af_alg_sendmsg);
+DEFINE_CRYPTO_API_STUB(af_alg_free_resources);
+DEFINE_CRYPTO_API_STUB(af_alg_async_cb);
+DEFINE_CRYPTO_API_STUB(af_alg_poll);
+DEFINE_CRYPTO_API_STUB(af_alg_alloc_areq);
+DEFINE_CRYPTO_API_STUB(af_alg_get_rsgl);
+
+#endif
diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h
index 107b797c33ec..1c5f2ed140ea 100644
--- a/include/crypto/if_alg.h
+++ b/include/crypto/if_alg.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_IF_ALG_H
 #define _CRYPTO_IF_ALG_H
 
+#include <crypto/api.h>
 #include <linux/compiler.h>
 #include <linux/completion.h>
 #include <linux/if_alg.h>
@@ -163,15 +164,29 @@ struct af_alg_ctx {
 	unsigned int inflight;
 };
 
-int af_alg_register_type(const struct af_alg_type *type);
-int af_alg_unregister_type(const struct af_alg_type *type);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_register_type, int,
+	(const struct af_alg_type *type),
+	(type));
 
-int af_alg_release(struct socket *sock);
-void af_alg_release_parent(struct sock *sk);
-int af_alg_accept(struct sock *sk, struct socket *newsock,
-		  struct proto_accept_arg *arg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_unregister_type, int,
+	(const struct af_alg_type *type),
+	(type));
 
-void af_alg_free_sg(struct af_alg_sgl *sgl);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_release, int,
+	(struct socket *sock),
+	(sock));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_release_parent, void,
+	(struct sock *sk),
+	(sk));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_accept, int,
+	(struct sock *sk, struct socket *newsock, struct proto_accept_arg *arg),
+	(sk, newsock, arg));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_free_sg, void,
+	(struct af_alg_sgl *sgl),
+	(sgl));
 
 static inline struct alg_sock *alg_sk(struct sock *sk)
 {
@@ -230,21 +245,44 @@ static inline bool af_alg_readable(struct sock *sk)
 	return PAGE_SIZE <= af_alg_rcvbuf(sk);
 }
 
-unsigned int af_alg_count_tsgl(struct sock *sk, size_t bytes, size_t offset);
-void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
-		      size_t dst_offset);
-void af_alg_wmem_wakeup(struct sock *sk);
-int af_alg_wait_for_data(struct sock *sk, unsigned flags, unsigned min);
-int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
-		   unsigned int ivsize);
-void af_alg_free_resources(struct af_alg_async_req *areq);
-void af_alg_async_cb(void *data, int err);
-__poll_t af_alg_poll(struct file *file, struct socket *sock,
-			 poll_table *wait);
-struct af_alg_async_req *af_alg_alloc_areq(struct sock *sk,
-					   unsigned int areqlen);
-int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags,
-		    struct af_alg_async_req *areq, size_t maxsize,
-		    size_t *outlen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_count_tsgl, unsigned int,
+	(struct sock *sk, size_t bytes, size_t offset),
+	(sk, bytes, offset));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_pull_tsgl, void,
+	(struct sock *sk, size_t used, struct scatterlist *dst, size_t dst_offset),
+	(sk, used, dst, dst_offset));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_wmem_wakeup, void,
+	(struct sock *sk),
+	(sk));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_wait_for_data, int,
+	(struct sock *sk, unsigned flags, unsigned min),
+	(sk, flags, min));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_sendmsg, int,
+	(struct socket *sock, struct msghdr *msg, size_t size, unsigned int ivsize),
+	(sock, msg, size, ivsize));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_free_resources, void,
+	(struct af_alg_async_req *areq),
+	(areq));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_async_cb, void,
+	(void *data, int err),
+	(data, err));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_poll, __poll_t,
+	(struct file *file, struct socket *sock, poll_table *wait),
+	(file, sock, wait));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_alloc_areq, struct af_alg_async_req *,
+	(struct sock *sk, unsigned int areqlen),
+	(sk, areqlen));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_USER_API, af_alg_get_rsgl, int,
+	(struct sock *sk, struct msghdr *msg, int flags, struct af_alg_async_req *areq, size_t maxsize, size_t *outlen),
+	(sk, msg, flags, areq, maxsize, outlen));
 
 #endif	/* _CRYPTO_IF_ALG_H */
-- 
2.47.3


^ permalink raw reply related

* [PATCH 069/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ARC4 crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ARC4-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile | 2 +-
 crypto/arc4.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 7635fd4b698c..623651445612 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -141,7 +141,7 @@ crypto-objs-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
 crypto-objs-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
-obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
+crypto-objs-$(CONFIG_CRYPTO_ARC4) += arc4.o
 obj-$(CONFIG_CRYPTO_TEA) += tea.o
 obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
diff --git a/crypto/arc4.c b/crypto/arc4.c
index 1608018111d0..f2bad33acb74 100644
--- a/crypto/arc4.c
+++ b/crypto/arc4.c
@@ -73,8 +73,8 @@ static void __exit arc4_exit(void)
 	crypto_unregister_lskcipher(&arc4_alg);
 }
 
-module_init(arc4_init);
-module_exit(arc4_exit);
+crypto_module_init(arc4_init);
+crypto_module_exit(arc4_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("ARC4 Cipher Algorithm");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 068/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CAST_COMMON, CONFIG_CRYPTO_CAST5, CONFIG_CRYPTO_CAST6 crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CAST_COMMON-, CONFIG_CRYPTO_CAST5-, and
CONFIG_CRYPTO_CAST6-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  6 +++---
 crypto/cast5_generic.c       |  4 ++--
 crypto/cast6_generic.c       |  4 ++--
 crypto/fips140/fips140-api.c | 42 ++++++++++++++++++++++++++++++++++++
 include/crypto/cast5.h       | 14 +++++++++---
 include/crypto/cast6.h       | 19 ++++++++++++----
 include/crypto/cast_common.h | 17 +++++++++++----
 7 files changed, 88 insertions(+), 18 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 4b6e56ad4d1c..7635fd4b698c 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -138,9 +138,9 @@ crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
 crypto-objs-$(CONFIG_CRYPTO_SM4) += sm4.o
 crypto-objs-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
 crypto-objs-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
-obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
-obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
-obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
+crypto-objs-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
+crypto-objs-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
+crypto-objs-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
 obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
 obj-$(CONFIG_CRYPTO_TEA) += tea.o
 obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
diff --git a/crypto/cast5_generic.c b/crypto/cast5_generic.c
index f68330793e0c..241738e09945 100644
--- a/crypto/cast5_generic.c
+++ b/crypto/cast5_generic.c
@@ -531,8 +531,8 @@ static void __exit cast5_mod_fini(void)
 	crypto_unregister_alg(&alg);
 }
 
-module_init(cast5_mod_init);
-module_exit(cast5_mod_fini);
+crypto_module_init(cast5_mod_init);
+crypto_module_exit(cast5_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Cast5 Cipher Algorithm");
diff --git a/crypto/cast6_generic.c b/crypto/cast6_generic.c
index 4c08c42646f0..53deace18e63 100644
--- a/crypto/cast6_generic.c
+++ b/crypto/cast6_generic.c
@@ -271,8 +271,8 @@ static void __exit cast6_mod_fini(void)
 	crypto_unregister_alg(&alg);
 }
 
-module_init(cast6_mod_init);
-module_exit(cast6_mod_fini);
+crypto_module_init(cast6_mod_init);
+crypto_module_exit(cast6_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Cast6 Cipher Algorithm");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 475cab990549..f6d6a6e79a9e 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -696,3 +696,45 @@ DEFINE_CRYPTO_API_STUB(__serpent_encrypt);
 DEFINE_CRYPTO_API_STUB(__serpent_decrypt);
 
 #endif
+/*
+ * crypto/cast_common.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_CAST_COMMON)
+
+#include <crypto/cast_common.h>
+
+#undef cast_s1
+#undef cast_s2
+#undef cast_s3
+#undef cast_s4
+DEFINE_CRYPTO_VAR_STUB(cast_s1);
+DEFINE_CRYPTO_VAR_STUB(cast_s2);
+DEFINE_CRYPTO_VAR_STUB(cast_s3);
+DEFINE_CRYPTO_VAR_STUB(cast_s4);
+
+#endif
+/*
+ * crypto/cast5_generic.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_CAST5)
+
+#include <crypto/cast5.h>
+
+DEFINE_CRYPTO_API_STUB(cast5_setkey);
+DEFINE_CRYPTO_API_STUB(__cast5_encrypt);
+DEFINE_CRYPTO_API_STUB(__cast5_decrypt);
+
+#endif
+/*
+ * crypto/cast6_generic.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_CAST6)
+
+#include <crypto/cast6.h>
+
+DEFINE_CRYPTO_API_STUB(__cast6_setkey);
+DEFINE_CRYPTO_API_STUB(cast6_setkey);
+DEFINE_CRYPTO_API_STUB(__cast6_encrypt);
+DEFINE_CRYPTO_API_STUB(__cast6_decrypt);
+
+#endif
diff --git a/include/crypto/cast5.h b/include/crypto/cast5.h
index 3d4ed4ea9c3b..cdd85cd974bb 100644
--- a/include/crypto/cast5.h
+++ b/include/crypto/cast5.h
@@ -2,6 +2,7 @@
 #ifndef _CRYPTO_CAST5_H
 #define _CRYPTO_CAST5_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 #include <crypto/cast_common.h>
@@ -16,9 +17,16 @@ struct cast5_ctx {
 	int rr;	/* rr ? rounds = 12 : rounds = 16; (rfc 2144) */
 };
 
-int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST5, cast5_setkey, int,
+	(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen),
+	(tfm, key, keylen));
 
-void __cast5_encrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
-void __cast5_decrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST5, __cast5_encrypt, void,
+	(struct cast5_ctx *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST5, __cast5_decrypt, void,
+	(struct cast5_ctx *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
 
 #endif
diff --git a/include/crypto/cast6.h b/include/crypto/cast6.h
index 38f490cd50a8..5fd28d7ed70f 100644
--- a/include/crypto/cast6.h
+++ b/include/crypto/cast6.h
@@ -2,6 +2,7 @@
 #ifndef _CRYPTO_CAST6_H
 #define _CRYPTO_CAST6_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 #include <crypto/cast_common.h>
@@ -15,10 +16,20 @@ struct cast6_ctx {
 	u8 Kr[12][4];
 };
 
-int __cast6_setkey(struct cast6_ctx *ctx, const u8 *key, unsigned int keylen);
-int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST6, __cast6_setkey, int,
+	(struct cast6_ctx *ctx, const u8 *key, unsigned int keylen),
+	(ctx, key, keylen));
 
-void __cast6_encrypt(const void *ctx, u8 *dst, const u8 *src);
-void __cast6_decrypt(const void *ctx, u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST6, cast6_setkey, int,
+	(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen),
+	(tfm, key, keylen));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST6, __cast6_encrypt, void,
+	(const void *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAST6, __cast6_decrypt, void,
+	(const void *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
 
 #endif
diff --git a/include/crypto/cast_common.h b/include/crypto/cast_common.h
index b90090244164..68f8b4b5ea76 100644
--- a/include/crypto/cast_common.h
+++ b/include/crypto/cast_common.h
@@ -2,9 +2,18 @@
 #ifndef _CRYPTO_CAST_COMMON_H
 #define _CRYPTO_CAST_COMMON_H
 
-extern const u32 cast_s1[256];
-extern const u32 cast_s2[256];
-extern const u32 cast_s3[256];
-extern const u32 cast_s4[256];
+#include <crypto/api.h>
+
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_CAST_COMMON, cast_s1, const u32, [256]);
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_CAST_COMMON, cast_s2, const u32, [256]);
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_CAST_COMMON, cast_s3, const u32, [256]);
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_CAST_COMMON, cast_s4, const u32, [256]);
+
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_CRYPTO_CAST_COMMON)
+#define cast_s1 (((const u32*)CRYPTO_VAR_NAME(cast_s1)))
+#define cast_s2 (((const u32*)CRYPTO_VAR_NAME(cast_s2)))
+#define cast_s3 (((const u32*)CRYPTO_VAR_NAME(cast_s3)))
+#define cast_s4 (((const u32*)CRYPTO_VAR_NAME(cast_s4)))
+#endif
 
 #endif
-- 
2.47.3


^ permalink raw reply related

* [PATCH 067/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CAMELLIA crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CAMELLIA-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile           | 2 +-
 crypto/camellia_generic.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index c14713e9cc55..4b6e56ad4d1c 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -137,7 +137,7 @@ CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gn
 crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
 crypto-objs-$(CONFIG_CRYPTO_SM4) += sm4.o
 crypto-objs-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
-obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
+crypto-objs-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
 obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
 obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
 obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
diff --git a/crypto/camellia_generic.c b/crypto/camellia_generic.c
index ee4336a04b93..15a68abc387b 100644
--- a/crypto/camellia_generic.c
+++ b/crypto/camellia_generic.c
@@ -1064,8 +1064,8 @@ static void __exit camellia_fini(void)
 	crypto_unregister_alg(&camellia_alg);
 }
 
-module_init(camellia_init);
-module_exit(camellia_fini);
+crypto_module_init(camellia_init);
+crypto_module_exit(camellia_fini);
 
 MODULE_DESCRIPTION("Camellia Cipher Algorithm");
 MODULE_LICENSE("GPL");
-- 
2.47.3


^ permalink raw reply related

* [PATCH 066/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SERPENT crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SERPENT-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  2 +-
 crypto/fips140/fips140-api.c | 13 +++++++++++++
 crypto/serpent_generic.c     |  4 ++--
 include/crypto/serpent.h     | 20 +++++++++++++++-----
 4 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index e93edc49840a..c14713e9cc55 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -132,7 +132,7 @@ crypto-objs-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
 crypto-objs-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
 crypto-objs-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
 crypto-objs-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
-obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
+crypto-objs-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
 CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
 crypto-objs-$(CONFIG_CRYPTO_SM4) += sm4.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 9ad530743d1f..475cab990549 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -683,3 +683,16 @@ DEFINE_CRYPTO_API_STUB(__twofish_setkey);
 DEFINE_CRYPTO_API_STUB(twofish_setkey);
 
 #endif
+/*
+ * crypto/serpent_generic.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_SERPENT)
+
+#include <crypto/serpent.h>
+
+DEFINE_CRYPTO_API_STUB(__serpent_setkey);
+DEFINE_CRYPTO_API_STUB(serpent_setkey);
+DEFINE_CRYPTO_API_STUB(__serpent_encrypt);
+DEFINE_CRYPTO_API_STUB(__serpent_decrypt);
+
+#endif
diff --git a/crypto/serpent_generic.c b/crypto/serpent_generic.c
index b21e7606c652..27c2da015d20 100644
--- a/crypto/serpent_generic.c
+++ b/crypto/serpent_generic.c
@@ -599,8 +599,8 @@ static void __exit serpent_mod_fini(void)
 	crypto_unregister_alg(&srp_alg);
 }
 
-module_init(serpent_mod_init);
-module_exit(serpent_mod_fini);
+crypto_module_init(serpent_mod_init);
+crypto_module_exit(serpent_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Serpent Cipher Algorithm");
diff --git a/include/crypto/serpent.h b/include/crypto/serpent.h
index 75c7eaa20853..8985ff684aeb 100644
--- a/include/crypto/serpent.h
+++ b/include/crypto/serpent.h
@@ -6,6 +6,7 @@
 #ifndef _CRYPTO_SERPENT_H
 #define _CRYPTO_SERPENT_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 
@@ -18,11 +19,20 @@ struct serpent_ctx {
 	u32 expkey[SERPENT_EXPKEY_WORDS];
 };
 
-int __serpent_setkey(struct serpent_ctx *ctx, const u8 *key,
-		     unsigned int keylen);
-int serpent_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SERPENT, __serpent_setkey, int,
+	(struct serpent_ctx *ctx, const u8 *key, unsigned int keylen),
+	(ctx, key, keylen));
 
-void __serpent_encrypt(const void *ctx, u8 *dst, const u8 *src);
-void __serpent_decrypt(const void *ctx, u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SERPENT, serpent_setkey, int,
+	(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen),
+	(tfm, key, keylen));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SERPENT, __serpent_encrypt, void,
+	(const void *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SERPENT, __serpent_decrypt, void,
+	(const void *ctx, u8 *dst, const u8 *src),
+	(ctx, dst, src));
 
 #endif
-- 
2.47.3


^ permalink raw reply related

* [PATCH 065/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_TWOFISH and CONFIG_CRYPTO_TWOFISH_COMMON crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_TWOFISH- and CONFIG_CRYPTO_TWOFISH_COMMON-related crypto
to convert them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  4 ++--
 crypto/fips140/fips140-api.c | 11 +++++++++++
 crypto/twofish_generic.c     |  4 ++--
 include/crypto/twofish.h     | 11 ++++++++---
 4 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 326b37002e3d..e93edc49840a 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -130,8 +130,8 @@ crypto-objs-$(CONFIG_CRYPTO_DES) += des_generic.o
 crypto-objs-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
 crypto-objs-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
-obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
-obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
+crypto-objs-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
+crypto-objs-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
 CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 5b0ae8476ce7..9ad530743d1f 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -672,3 +672,14 @@ DEFINE_CRYPTO_API_STUB(sm4_expandkey);
 DEFINE_CRYPTO_API_STUB(sm4_crypt_block);
 
 #endif
+/*
+ * crypto/twofish_common.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_TWOFISH_COMMON)
+
+#include <crypto/twofish.h>
+
+DEFINE_CRYPTO_API_STUB(__twofish_setkey);
+DEFINE_CRYPTO_API_STUB(twofish_setkey);
+
+#endif
diff --git a/crypto/twofish_generic.c b/crypto/twofish_generic.c
index 368018cfa9bf..0d9cefa3350b 100644
--- a/crypto/twofish_generic.c
+++ b/crypto/twofish_generic.c
@@ -187,8 +187,8 @@ static void __exit twofish_mod_fini(void)
 	crypto_unregister_alg(&alg);
 }
 
-module_init(twofish_mod_init);
-module_exit(twofish_mod_fini);
+crypto_module_init(twofish_mod_init);
+crypto_module_exit(twofish_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION ("Twofish Cipher Algorithm");
diff --git a/include/crypto/twofish.h b/include/crypto/twofish.h
index f6b307a58554..4695480f5d44 100644
--- a/include/crypto/twofish.h
+++ b/include/crypto/twofish.h
@@ -2,6 +2,7 @@
 #ifndef _CRYPTO_TWOFISH_H
 #define _CRYPTO_TWOFISH_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 
 #define TF_MIN_KEY_SIZE 16
@@ -18,8 +19,12 @@ struct twofish_ctx {
 	u32 s[4][256], w[8], k[32];
 };
 
-int __twofish_setkey(struct twofish_ctx *ctx, const u8 *key,
-		     unsigned int key_len);
-int twofish_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_TWOFISH_COMMON, __twofish_setkey, int,
+	(struct twofish_ctx *ctx, const u8 *key, unsigned int key_len),
+	(ctx, key, key_len));
+
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_TWOFISH_COMMON, twofish_setkey, int,
+	(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len),
+	(tfm, key, key_len));
 
 #endif
-- 
2.47.3


^ permalink raw reply related

* [PATCH 064/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SM4 and CONFIG_CRYPTO_SM4_GENERIC crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SM4- and CONFIG_CRYPTO_SM4_GENERIC-related crypto to
convert them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  4 ++--
 crypto/fips140/fips140-api.c | 18 ++++++++++++++++++
 crypto/sm4_generic.c         |  4 ++--
 include/crypto/sm4.h         | 22 ++++++++++++++++------
 4 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 795c76357bff..326b37002e3d 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -135,8 +135,8 @@ obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
 CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
 crypto-objs-$(CONFIG_CRYPTO_AES) += aes.o
-obj-$(CONFIG_CRYPTO_SM4) += sm4.o
-obj-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
+crypto-objs-$(CONFIG_CRYPTO_SM4) += sm4.o
+crypto-objs-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
 obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
 obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
 obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 61f7884d0f34..5b0ae8476ce7 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -654,3 +654,21 @@ DEFINE_CRYPTO_API_STUB(cryptd_free_aead);
 DEFINE_CRYPTO_API_STUB(blowfish_setkey);
 
 #endif
+/*
+ * crypto/sm4.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_SM4)
+
+#include <crypto/sm4.h>
+
+#undef crypto_sm4_fk
+#undef crypto_sm4_ck
+#undef crypto_sm4_sbox
+DEFINE_CRYPTO_VAR_STUB(crypto_sm4_fk);
+DEFINE_CRYPTO_VAR_STUB(crypto_sm4_ck);
+DEFINE_CRYPTO_VAR_STUB(crypto_sm4_sbox);
+
+DEFINE_CRYPTO_API_STUB(sm4_expandkey);
+DEFINE_CRYPTO_API_STUB(sm4_crypt_block);
+
+#endif
diff --git a/crypto/sm4_generic.c b/crypto/sm4_generic.c
index d57444e8428c..aba3e3271d37 100644
--- a/crypto/sm4_generic.c
+++ b/crypto/sm4_generic.c
@@ -83,8 +83,8 @@ static void __exit sm4_fini(void)
 	crypto_unregister_alg(&sm4_alg);
 }
 
-module_init(sm4_init);
-module_exit(sm4_fini);
+crypto_module_init(sm4_init);
+crypto_module_exit(sm4_fini);
 
 MODULE_DESCRIPTION("SM4 Cipher Algorithm");
 MODULE_LICENSE("GPL v2");
diff --git a/include/crypto/sm4.h b/include/crypto/sm4.h
index 9656a9a40326..10cb9c379357 100644
--- a/include/crypto/sm4.h
+++ b/include/crypto/sm4.h
@@ -9,6 +9,7 @@
 #ifndef _CRYPTO_SM4_H
 #define _CRYPTO_SM4_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 
@@ -21,9 +22,15 @@ struct sm4_ctx {
 	u32 rkey_dec[SM4_RKEY_WORDS];
 };
 
-extern const u32 crypto_sm4_fk[];
-extern const u32 crypto_sm4_ck[];
-extern const u8 crypto_sm4_sbox[];
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_SM4, crypto_sm4_fk, const u32, [4]);
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_SM4, crypto_sm4_ck, const u32, [32]);
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_SM4, crypto_sm4_sbox, const u8, [256]);
+
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_CRYPTO_SM4)
+#define crypto_sm4_fk (((const u32*)CRYPTO_VAR_NAME(crypto_sm4_fk)))
+#define crypto_sm4_ck (((const u32*)CRYPTO_VAR_NAME(crypto_sm4_ck)))
+#define crypto_sm4_sbox (((const u8*)CRYPTO_VAR_NAME(crypto_sm4_sbox)))
+#endif
 
 /**
  * sm4_expandkey - Expands the SM4 key as described in GB/T 32907-2016
@@ -34,8 +41,9 @@ extern const u8 crypto_sm4_sbox[];
  * Returns 0 on success. The function fails only if an invalid key size (or
  * pointer) is supplied.
  */
-int sm4_expandkey(struct sm4_ctx *ctx, const u8 *in_key,
-			  unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SM4, sm4_expandkey, int,
+	(struct sm4_ctx *ctx, const u8 *in_key, unsigned int key_len),
+	(ctx, in_key, key_len));
 
 /**
  * sm4_crypt_block - Encrypt or decrypt a single SM4 block
@@ -43,6 +51,8 @@ int sm4_expandkey(struct sm4_ctx *ctx, const u8 *in_key,
  * @out:	Buffer to store output data
  * @in: 	Buffer containing the input data
  */
-void sm4_crypt_block(const u32 *rk, u8 *out, const u8 *in);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_SM4, sm4_crypt_block, void,
+	(const u32 *rk, u8 *out, const u8 *in),
+	(rk, out, in));
 
 #endif
-- 
2.47.3


^ permalink raw reply related

* [PATCH 063/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_BLOWFISH and CONFIG_CRYPTO_BLOWFISH_COMMON crypto
From: Jay Wang @ 2026-02-12  2:46 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, linux-crypto
  Cc: Jay Wang, Vegard Nossum, Nicolai Stange, Ilia Okomin,
	Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Luis Chamberlain, Petr Pavlu, Nathan Chancellor,
	Nicolas Schier, linux-arm-kernel, x86, linux-kbuild,
	linux-modules
In-Reply-To: <20260212024725.11264-1-wanjay@amazon.com>

Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_BLOWFISH- and CONFIG_CRYPTO_BLOWFISH_COMMON-related crypto
to convert them into pluggable interface.

Signed-off-by: Jay Wang <wanjay@amazon.com>
---
 crypto/Makefile              |  4 ++--
 crypto/blowfish_generic.c    |  4 ++--
 crypto/fips140/fips140-api.c | 10 ++++++++++
 include/crypto/blowfish.h    |  6 ++++--
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/crypto/Makefile b/crypto/Makefile
index 84dff7084f71..795c76357bff 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -128,8 +128,8 @@ crypto-objs-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
 crypto-objs-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
 crypto-objs-$(CONFIG_CRYPTO_DES) += des_generic.o
 crypto-objs-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
-obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
-obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
+crypto-objs-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
+crypto-objs-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
 obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
 obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
diff --git a/crypto/blowfish_generic.c b/crypto/blowfish_generic.c
index f3c5f9b09850..8a0390b14867 100644
--- a/crypto/blowfish_generic.c
+++ b/crypto/blowfish_generic.c
@@ -124,8 +124,8 @@ static void __exit blowfish_mod_fini(void)
 	crypto_unregister_alg(&alg);
 }
 
-module_init(blowfish_mod_init);
-module_exit(blowfish_mod_fini);
+crypto_module_init(blowfish_mod_init);
+crypto_module_exit(blowfish_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Blowfish Cipher Algorithm");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 1452439319cc..61f7884d0f34 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -644,3 +644,13 @@ DEFINE_CRYPTO_API_STUB(cryptd_aead_queued);
 DEFINE_CRYPTO_API_STUB(cryptd_free_aead);
 
 #endif
+/*
+ * crypto/blowfish_common.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_BLOWFISH_COMMON)
+
+#include <crypto/blowfish.h>
+
+DEFINE_CRYPTO_API_STUB(blowfish_setkey);
+
+#endif
diff --git a/include/crypto/blowfish.h b/include/crypto/blowfish.h
index 9b384670b356..46e42a89bdf9 100644
--- a/include/crypto/blowfish.h
+++ b/include/crypto/blowfish.h
@@ -6,6 +6,7 @@
 #ifndef _CRYPTO_BLOWFISH_H
 #define _CRYPTO_BLOWFISH_H
 
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 
@@ -18,7 +19,8 @@ struct bf_ctx {
 	u32 s[1024];
 };
 
-int blowfish_setkey(struct crypto_tfm *tfm, const u8 *key,
-		    unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_BLOWFISH_COMMON, blowfish_setkey, int,
+	(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len),
+	(tfm, key, key_len));
 
 #endif
-- 
2.47.3


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox