* [PATCH 036/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ENGINE 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_ENGINE-related crypto to convert them into pluggable
interface.
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/fips140/fips140-api.c | 40 ++++++++++
include/crypto/engine.h | 140 +++++++++++++++++++++++------------
3 files changed, 135 insertions(+), 47 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index d58b5e2b5b43..f2b9532a0320 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -8,7 +8,7 @@ CONTEXT_ANALYSIS := y
crypto-objs-$(CONFIG_CRYPTO) += crypto.o
crypto-y := api.o cipher.o
-obj-$(CONFIG_CRYPTO_ENGINE) += crypto_engine.o
+crypto-objs-$(CONFIG_CRYPTO_ENGINE) += crypto_engine.o
obj-$(CONFIG_CRYPTO_FIPS) += fips.o
crypto_algapi-$(CONFIG_PROC_FS) += proc.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index e679932ab552..05ada434d1ac 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -526,3 +526,43 @@ DEFINE_CRYPTO_API_STUB(pkcs7_verify);
DEFINE_CRYPTO_API_STUB(pkcs7_supply_detached_data);
#endif
+/*
+ * crypto/crypto_engine.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ENGINE)
+
+#include <crypto/engine.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_transfer_aead_request_to_engine);
+DEFINE_CRYPTO_API_STUB(crypto_transfer_akcipher_request_to_engine);
+DEFINE_CRYPTO_API_STUB(crypto_transfer_hash_request_to_engine);
+DEFINE_CRYPTO_API_STUB(crypto_transfer_kpp_request_to_engine);
+DEFINE_CRYPTO_API_STUB(crypto_transfer_skcipher_request_to_engine);
+DEFINE_CRYPTO_API_STUB(crypto_finalize_aead_request);
+DEFINE_CRYPTO_API_STUB(crypto_finalize_akcipher_request);
+DEFINE_CRYPTO_API_STUB(crypto_finalize_hash_request);
+DEFINE_CRYPTO_API_STUB(crypto_finalize_kpp_request);
+DEFINE_CRYPTO_API_STUB(crypto_finalize_skcipher_request);
+DEFINE_CRYPTO_API_STUB(crypto_engine_start);
+DEFINE_CRYPTO_API_STUB(crypto_engine_stop);
+DEFINE_CRYPTO_API_STUB(crypto_engine_alloc_init);
+DEFINE_CRYPTO_API_STUB(crypto_engine_alloc_init_and_set);
+DEFINE_CRYPTO_API_STUB(crypto_engine_exit);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_aead);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_aead);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_aeads);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_aeads);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_ahash);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_ahash);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_ahashes);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_ahashes);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_akcipher);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_akcipher);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_kpp);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_kpp);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_skcipher);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_skcipher);
+DEFINE_CRYPTO_API_STUB(crypto_engine_register_skciphers);
+DEFINE_CRYPTO_API_STUB(crypto_engine_unregister_skciphers);
+
+#endif
\ No newline at end of file
diff --git a/include/crypto/engine.h b/include/crypto/engine.h
index 2e60344437da..82552e11880a 100644
--- a/include/crypto/engine.h
+++ b/include/crypto/engine.h
@@ -7,6 +7,7 @@
#ifndef _CRYPTO_ENGINE_H
#define _CRYPTO_ENGINE_H
+#include <crypto/api.h>
#include <crypto/aead.h>
#include <crypto/akcipher.h>
#include <crypto/hash.h>
@@ -51,56 +52,103 @@ struct skcipher_engine_alg {
struct crypto_engine_op op;
};
-int crypto_transfer_aead_request_to_engine(struct crypto_engine *engine,
- struct aead_request *req);
-int crypto_transfer_akcipher_request_to_engine(struct crypto_engine *engine,
- struct akcipher_request *req);
-int crypto_transfer_hash_request_to_engine(struct crypto_engine *engine,
- struct ahash_request *req);
-int crypto_transfer_kpp_request_to_engine(struct crypto_engine *engine,
- struct kpp_request *req);
-int crypto_transfer_skcipher_request_to_engine(struct crypto_engine *engine,
- struct skcipher_request *req);
-void crypto_finalize_aead_request(struct crypto_engine *engine,
- struct aead_request *req, int err);
-void crypto_finalize_akcipher_request(struct crypto_engine *engine,
- struct akcipher_request *req, int err);
-void crypto_finalize_hash_request(struct crypto_engine *engine,
- struct ahash_request *req, int err);
-void crypto_finalize_kpp_request(struct crypto_engine *engine,
- struct kpp_request *req, int err);
-void crypto_finalize_skcipher_request(struct crypto_engine *engine,
- struct skcipher_request *req, int err);
-int crypto_engine_start(struct crypto_engine *engine);
-int crypto_engine_stop(struct crypto_engine *engine);
-struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt);
-struct crypto_engine *crypto_engine_alloc_init_and_set(struct device *dev,
- bool retry_support,
- bool rt, int qlen);
-void crypto_engine_exit(struct crypto_engine *engine);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_transfer_aead_request_to_engine, int,
+ (struct crypto_engine *engine, struct aead_request *req),
+ (engine, req));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_transfer_akcipher_request_to_engine, int,
+ (struct crypto_engine *engine, struct akcipher_request *req),
+ (engine, req));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_transfer_hash_request_to_engine, int,
+ (struct crypto_engine *engine, struct ahash_request *req),
+ (engine, req));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_transfer_kpp_request_to_engine, int,
+ (struct crypto_engine *engine, struct kpp_request *req),
+ (engine, req));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_transfer_skcipher_request_to_engine, int,
+ (struct crypto_engine *engine, struct skcipher_request *req),
+ (engine, req));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_finalize_aead_request, void,
+ (struct crypto_engine *engine, struct aead_request *req, int err),
+ (engine, req, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_finalize_akcipher_request, void,
+ (struct crypto_engine *engine, struct akcipher_request *req, int err),
+ (engine, req, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_finalize_hash_request, void,
+ (struct crypto_engine *engine, struct ahash_request *req, int err),
+ (engine, req, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_finalize_kpp_request, void,
+ (struct crypto_engine *engine, struct kpp_request *req, int err),
+ (engine, req, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_finalize_skcipher_request, void,
+ (struct crypto_engine *engine, struct skcipher_request *req, int err),
+ (engine, req, err));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_start, int,
+ (struct crypto_engine *engine),
+ (engine));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_stop, int,
+ (struct crypto_engine *engine),
+ (engine));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_alloc_init, struct crypto_engine *,
+ (struct device *dev, bool rt),
+ (dev, rt));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_alloc_init_and_set, struct crypto_engine *,
+ (struct device *dev, bool retry_support, bool rt, int qlen),
+ (dev, retry_support, rt, qlen));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_exit, void,
+ (struct crypto_engine *engine),
+ (engine));
-int crypto_engine_register_aead(struct aead_engine_alg *alg);
-void crypto_engine_unregister_aead(struct aead_engine_alg *alg);
-int crypto_engine_register_aeads(struct aead_engine_alg *algs, int count);
-void crypto_engine_unregister_aeads(struct aead_engine_alg *algs, int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_aead, int,
+ (struct aead_engine_alg *alg),
+ (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_aead, void,
+ (struct aead_engine_alg *alg),
+ (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_aeads, int,
+ (struct aead_engine_alg *algs, int count),
+ (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_aeads, void,
+ (struct aead_engine_alg *algs, int count),
+ (algs, count));
-int crypto_engine_register_ahash(struct ahash_engine_alg *alg);
-void crypto_engine_unregister_ahash(struct ahash_engine_alg *alg);
-int crypto_engine_register_ahashes(struct ahash_engine_alg *algs, int count);
-void crypto_engine_unregister_ahashes(struct ahash_engine_alg *algs,
- int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_ahash, int,
+ (struct ahash_engine_alg *alg),
+ (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_ahash, void,
+ (struct ahash_engine_alg *alg),
+ (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_ahashes, int,
+ (struct ahash_engine_alg *algs, int count),
+ (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_ahashes, void,
+ (struct ahash_engine_alg *algs, int count),
+ (algs, count));
-int crypto_engine_register_akcipher(struct akcipher_engine_alg *alg);
-void crypto_engine_unregister_akcipher(struct akcipher_engine_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_akcipher, int,
+ (struct akcipher_engine_alg *alg),
+ (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_akcipher, void,
+ (struct akcipher_engine_alg *alg),
+ (alg));
-int crypto_engine_register_kpp(struct kpp_engine_alg *alg);
-void crypto_engine_unregister_kpp(struct kpp_engine_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_kpp, int,
+ (struct kpp_engine_alg *alg),
+ (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_kpp, void,
+ (struct kpp_engine_alg *alg),
+ (alg));
-int crypto_engine_register_skcipher(struct skcipher_engine_alg *alg);
-void crypto_engine_unregister_skcipher(struct skcipher_engine_alg *alg);
-int crypto_engine_register_skciphers(struct skcipher_engine_alg *algs,
- int count);
-void crypto_engine_unregister_skciphers(struct skcipher_engine_alg *algs,
- int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_skcipher, int,
+ (struct skcipher_engine_alg *alg),
+ (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_skcipher, void,
+ (struct skcipher_engine_alg *alg),
+ (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_register_skciphers, int,
+ (struct skcipher_engine_alg *algs, int count),
+ (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ENGINE, crypto_engine_unregister_skciphers, void,
+ (struct skcipher_engine_alg *algs, int count),
+ (algs, count));
#endif /* _CRYPTO_ENGINE_H */
--
2.47.3
^ permalink raw reply related
* [PATCH 035/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_PKCS7_MESSAGE_PARSER 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_PKCS7_MESSAGE_PARSER-related crypto to convert them into pluggable
interface.
This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.
Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/asymmetric_keys/Makefile | 2 +-
crypto/fips140/fips140-api.c | 33 +++++++++++++++++++++++++++++++++
include/crypto/pkcs7.h | 31 +++++++++++++++++++------------
3 files changed, 53 insertions(+), 13 deletions(-)
diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index b42c48d973d3..c68fdcd2c5cf 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -50,7 +50,7 @@ clean-files += pkcs8.asn1.c pkcs8.asn1.h
#
# PKCS#7 message handling
#
-obj-$(CONFIG_PKCS7_MESSAGE_PARSER) += pkcs7_message.o
+crypto-objs-$(CONFIG_PKCS7_MESSAGE_PARSER) += pkcs7_message.o
pkcs7_message-y := \
pkcs7.asn1.o \
pkcs7_parser.o \
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index d08a001bb0db..e679932ab552 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -493,3 +493,36 @@ DEFINE_CRYPTO_API_STUB(x509_decode_time);
DEFINE_CRYPTO_API_STUB(x509_load_certificate_list);
#endif
+/*
+ * crypto/asymmetric_keys/pkcs7_parser.c
+ */
+#if IS_BUILTIN(CONFIG_PKCS7_MESSAGE_PARSER)
+
+#include <crypto/pkcs7.h>
+
+DEFINE_CRYPTO_API_STUB(pkcs7_parse_message);
+DEFINE_CRYPTO_API_STUB(pkcs7_free_message);
+DEFINE_CRYPTO_API_STUB(pkcs7_get_content_data);
+
+#endif
+/*
+ * crypto/asymmetric_keys/pkcs7_trust.c
+ */
+#if IS_BUILTIN(CONFIG_PKCS7_MESSAGE_PARSER)
+
+#include <crypto/pkcs7.h>
+
+DEFINE_CRYPTO_API_STUB(pkcs7_validate_trust);
+
+#endif
+/*
+ * crypto/asymmetric_keys/pkcs7_verify.c
+ */
+#if IS_BUILTIN(CONFIG_PKCS7_MESSAGE_PARSER)
+
+#include <crypto/pkcs7.h>
+
+DEFINE_CRYPTO_API_STUB(pkcs7_verify);
+DEFINE_CRYPTO_API_STUB(pkcs7_supply_detached_data);
+
+#endif
diff --git a/include/crypto/pkcs7.h b/include/crypto/pkcs7.h
index 38ec7f5f9041..63a7f2dbe627 100644
--- a/include/crypto/pkcs7.h
+++ b/include/crypto/pkcs7.h
@@ -8,6 +8,7 @@
#ifndef _CRYPTO_PKCS7_H
#define _CRYPTO_PKCS7_H
+#include <crypto/api.h>
#include <linux/verification.h>
#include <linux/hash_info.h>
#include <crypto/public_key.h>
@@ -18,28 +19,34 @@ struct pkcs7_message;
/*
* pkcs7_parser.c
*/
-extern struct pkcs7_message *pkcs7_parse_message(const void *data,
- size_t datalen);
-extern void pkcs7_free_message(struct pkcs7_message *pkcs7);
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_parse_message, struct pkcs7_message *,
+ (const void *data, size_t datalen),
+ (data, datalen));
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_free_message, void,
+ (struct pkcs7_message *pkcs7),
+ (pkcs7));
-extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7,
- const void **_data, size_t *_datalen,
- size_t *_headerlen);
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_get_content_data, int,
+ (const struct pkcs7_message *pkcs7, const void **_data, size_t *_datalen, size_t *_headerlen),
+ (pkcs7, _data, _datalen, _headerlen));
/*
* pkcs7_trust.c
*/
-extern int pkcs7_validate_trust(struct pkcs7_message *pkcs7,
- struct key *trust_keyring);
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_validate_trust, int,
+ (struct pkcs7_message *pkcs7, struct key *trust_keyring),
+ (pkcs7, trust_keyring));
/*
* pkcs7_verify.c
*/
-extern int pkcs7_verify(struct pkcs7_message *pkcs7,
- enum key_being_used_for usage);
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_verify, int,
+ (struct pkcs7_message *pkcs7, enum key_being_used_for usage),
+ (pkcs7, usage));
-extern int pkcs7_supply_detached_data(struct pkcs7_message *pkcs7,
- const void *data, size_t datalen);
+DECLARE_CRYPTO_API(CONFIG_PKCS7_MESSAGE_PARSER, pkcs7_supply_detached_data, int,
+ (struct pkcs7_message *pkcs7, const void *data, size_t datalen),
+ (pkcs7, data, datalen));
extern int pkcs7_get_digest(struct pkcs7_message *pkcs7, const u8 **buf,
u32 *len, enum hash_algo *hash_algo);
--
2.47.3
^ permalink raw reply related
* [PATCH 034/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_X509_CERTIFICATE_PARSER 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_X509_CERTIFICATE_PARSER-related crypto to convert them into
pluggable interface.
This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.
Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/asymmetric_keys/Makefile | 2 +-
crypto/asymmetric_keys/x509_parser.h | 15 ++++++++++-----
crypto/asymmetric_keys/x509_public_key.c | 4 ++--
crypto/fips140/fips140-api.c | 22 ++++++++++++++++++++++
include/keys/asymmetric-type.h | 5 +++--
5 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index 4f29401016f1..b42c48d973d3 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -15,7 +15,7 @@ crypto-objs-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
#
# X.509 Certificate handling
#
-obj-$(CONFIG_X509_CERTIFICATE_PARSER) += x509_key_parser.o
+crypto-objs-$(CONFIG_X509_CERTIFICATE_PARSER) += x509_key_parser.o
x509_key_parser-y := \
x509.asn1.o \
x509_akid.asn1.o \
diff --git a/crypto/asymmetric_keys/x509_parser.h b/crypto/asymmetric_keys/x509_parser.h
index b7aeebdddb36..53bfc5f807bb 100644
--- a/crypto/asymmetric_keys/x509_parser.h
+++ b/crypto/asymmetric_keys/x509_parser.h
@@ -5,6 +5,7 @@
* Written by David Howells (dhowells@redhat.com)
*/
+#include <crypto/api.h>
#include <linux/cleanup.h>
#include <linux/time.h>
#include <crypto/public_key.h>
@@ -46,13 +47,17 @@ struct x509_certificate {
/*
* x509_cert_parser.c
*/
-extern void x509_free_certificate(struct x509_certificate *cert);
+DECLARE_CRYPTO_API(CONFIG_X509_CERTIFICATE_PARSER, x509_free_certificate, void,
+ (struct x509_certificate *cert),
+ (cert));
DEFINE_FREE(x509_free_certificate, struct x509_certificate *,
if (!IS_ERR(_T)) x509_free_certificate(_T))
-extern struct x509_certificate *x509_cert_parse(const void *data, size_t datalen);
-extern int x509_decode_time(time64_t *_t, size_t hdrlen,
- unsigned char tag,
- const unsigned char *value, size_t vlen);
+DECLARE_CRYPTO_API(CONFIG_X509_CERTIFICATE_PARSER, x509_cert_parse, struct x509_certificate *,
+ (const void *data, size_t datalen),
+ (data, datalen));
+DECLARE_CRYPTO_API(CONFIG_X509_CERTIFICATE_PARSER, x509_decode_time, int,
+ (time64_t *_t, size_t hdrlen, unsigned char tag, const unsigned char *value, size_t vlen),
+ (_t, hdrlen, tag, value, vlen));
/*
* x509_public_key.c
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
index 27b4fea37845..e840bd8019be 100644
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -258,8 +258,8 @@ static void __exit x509_key_exit(void)
unregister_asymmetric_key_parser(&x509_key_parser);
}
-module_init(x509_key_init);
-module_exit(x509_key_exit);
+crypto_module_init(x509_key_init);
+crypto_module_exit(x509_key_exit);
MODULE_DESCRIPTION("X.509 certificate parser");
MODULE_AUTHOR("Red Hat, Inc.");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 6dce18f81e91..d08a001bb0db 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -471,3 +471,25 @@ DEFINE_CRYPTO_API_STUB(public_key_verify_signature);
DEFINE_CRYPTO_VAR_STUB(public_key_subtype);
#endif
+/*
+ * crypto/asymmetric_keys/x509_cert_parser.c
+ */
+#if IS_BUILTIN(CONFIG_X509_CERTIFICATE_PARSER)
+
+#include <crypto/asymmetric_keys/x509_parser.h>
+
+DEFINE_CRYPTO_API_STUB(x509_free_certificate);
+DEFINE_CRYPTO_API_STUB(x509_cert_parse);
+DEFINE_CRYPTO_API_STUB(x509_decode_time);
+
+#endif
+/*
+ * crypto/asymmetric_keys/x509_loader.c
+ */
+#if IS_BUILTIN(CONFIG_X509_CERTIFICATE_PARSER)
+
+#include <keys/asymmetric-type.h>
+
+DEFINE_CRYPTO_API_STUB(x509_load_certificate_list);
+
+#endif
diff --git a/include/keys/asymmetric-type.h b/include/keys/asymmetric-type.h
index 96e718a550a3..dd5b4d9980c1 100644
--- a/include/keys/asymmetric-type.h
+++ b/include/keys/asymmetric-type.h
@@ -88,8 +88,9 @@ DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, find_asymmetric_key, struct key *
(struct key *keyring, const struct asymmetric_key_id *id_0, const struct asymmetric_key_id *id_1, const struct asymmetric_key_id *id_2, bool partial),
(keyring, id_0, id_1, id_2, partial));
-int x509_load_certificate_list(const u8 cert_list[], const unsigned long list_size,
- const struct key *keyring);
+DECLARE_CRYPTO_API(CONFIG_X509_CERTIFICATE_PARSER, x509_load_certificate_list, int,
+ (const u8 cert_list[], const unsigned long list_size, const struct key *keyring),
+ (cert_list, list_size, keyring));
/*
* The payload is at the discretion of the subtype.
--
2.47.3
^ permalink raw reply related
* [PATCH 033/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE 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_ASYMMETRIC_PUBLIC_KEY_SUBTYPE-related crypto to convert them into
pluggable interface.
This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.
Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/asymmetric_keys/Makefile | 2 +-
crypto/fips140/fips140-api.c | 14 ++++++++++++++
include/crypto/public_key.h | 15 +++++++++++----
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index 252536153d73..4f29401016f1 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -10,7 +10,7 @@ asymmetric_keys-y := \
restrict.o \
signature.o
-obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
+crypto-objs-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
#
# X.509 Certificate handling
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 100f50ad7b43..6dce18f81e91 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -457,3 +457,17 @@ DEFINE_CRYPTO_API_STUB(restrict_link_by_signature);
DEFINE_CRYPTO_API_STUB(restrict_link_by_digsig);
#endif
+/*
+ * crypto/asymmetric_keys/public_key.c
+ */
+#if IS_BUILTIN(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE)
+
+#include <crypto/public_key.h>
+
+DEFINE_CRYPTO_API_STUB(public_key_free);
+DEFINE_CRYPTO_API_STUB(public_key_verify_signature);
+
+#undef public_key_subtype
+DEFINE_CRYPTO_VAR_STUB(public_key_subtype);
+
+#endif
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
index be789854fdcb..b0e737d1dc1a 100644
--- a/include/crypto/public_key.h
+++ b/include/crypto/public_key.h
@@ -36,7 +36,9 @@ struct public_key {
#define KEY_EFLAG_KEYCERTSIGN 2 /* set if the keyCertSign usage is set */
};
-extern void public_key_free(struct public_key *key);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE, public_key_free, void,
+ (struct public_key *key),
+ (key));
/*
* Public key cryptography signature data
@@ -58,7 +60,11 @@ DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, public_key_signature_free, void,
(struct public_key_signature *sig),
(sig));
-extern struct asymmetric_key_subtype public_key_subtype;
+DECLARE_CRYPTO_VAR(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE, public_key_subtype, struct asymmetric_key_subtype, );
+
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE)
+#define public_key_subtype (*((struct asymmetric_key_subtype*)CRYPTO_VAR_NAME(public_key_subtype)))
+#endif
struct key;
struct key_type;
@@ -113,8 +119,9 @@ DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, verify_signature, int,
(arg1, arg2));
#if IS_REACHABLE(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE)
-int public_key_verify_signature(const struct public_key *pkey,
- const struct public_key_signature *sig);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE, public_key_verify_signature, int,
+ (const struct public_key *pkey, const struct public_key_signature *sig),
+ (pkey, sig));
#else
static inline
int public_key_verify_signature(const struct public_key *pkey,
--
2.47.3
^ permalink raw reply related
* [PATCH 032/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_ASYMMETRIC_KEY_TYPE 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_ASYMMETRIC_KEY_TYPE-related crypto to convert them into pluggable
interface.
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
certs/system_keyring.c | 1 +
crypto/asymmetric_keys/Makefile | 2 +-
crypto/asymmetric_keys/asymmetric_type.c | 4 +--
crypto/asymmetric_keys/restrict.c | 3 +-
crypto/fips140/fips140-api.c | 44 ++++++++++++++++++++++++
include/crypto/public_key.h | 29 +++++++++-------
include/keys/asymmetric-parser.h | 8 +++--
include/keys/asymmetric-type.h | 32 +++++++++--------
8 files changed, 90 insertions(+), 33 deletions(-)
diff --git a/certs/system_keyring.c b/certs/system_keyring.c
index 9de610bf1f4b..a53261dc5629 100644
--- a/certs/system_keyring.c
+++ b/certs/system_keyring.c
@@ -50,6 +50,7 @@ int restrict_link_by_builtin_trusted(struct key *dest_keyring,
return restrict_link_by_signature(dest_keyring, type, payload,
builtin_trusted_keys);
}
+EXPORT_SYMBOL_GPL(restrict_link_by_builtin_trusted);
/**
* restrict_link_by_digsig_builtin - Restrict digitalSignature key additions by the built-in keyring
diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index bc65d3b98dcb..252536153d73 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -3,7 +3,7 @@
# Makefile for asymmetric cryptographic keys
#
-obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
+crypto-objs-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
asymmetric_keys-y := \
asymmetric_type.o \
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index 2326743310b1..9afc58536cf6 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -677,5 +677,5 @@ static void __exit asymmetric_key_cleanup(void)
unregister_key_type(&key_type_asymmetric);
}
-module_init(asymmetric_key_init);
-module_exit(asymmetric_key_cleanup);
+crypto_module_init(asymmetric_key_init);
+crypto_module_exit(asymmetric_key_cleanup);
diff --git a/crypto/asymmetric_keys/restrict.c b/crypto/asymmetric_keys/restrict.c
index 86292965f493..5d6ecf9eadbc 100644
--- a/crypto/asymmetric_keys/restrict.c
+++ b/crypto/asymmetric_keys/restrict.c
@@ -114,7 +114,7 @@ int restrict_link_by_signature(struct key *dest_keyring,
key_put(key);
return ret;
}
-
+EXPORT_SYMBOL_GPL(restrict_link_by_signature);
/**
* restrict_link_by_ca - Restrict additions to a ring of CA keys
* @dest_keyring: Keyring being linked to.
@@ -198,6 +198,7 @@ int restrict_link_by_digsig(struct key *dest_keyring,
return restrict_link_by_signature(dest_keyring, type, payload,
trust_keyring);
}
+EXPORT_SYMBOL_GPL(restrict_link_by_digsig);
static bool match_either_id(const struct asymmetric_key_id **pair,
const struct asymmetric_key_id *single)
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 20afa1c21cf0..100f50ad7b43 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -413,3 +413,47 @@ DEFINE_CRYPTO_API_STUB(crypto_unregister_rngs);
DEFINE_CRYPTO_API_STUB(crypto_del_default_rng);
#endif
+/*
+ * crypto/asymmetric_keys/asymmetric_type.c
+ */
+#if IS_BUILTIN(CONFIG_ASYMMETRIC_KEY_TYPE)
+
+#include <keys/asymmetric-parser.h>
+
+DEFINE_CRYPTO_API_STUB(register_asymmetric_key_parser);
+DEFINE_CRYPTO_API_STUB(unregister_asymmetric_key_parser);
+
+#include <keys/asymmetric-type.h>
+
+DEFINE_CRYPTO_API_STUB(asymmetric_key_id_same);
+DEFINE_CRYPTO_API_STUB(asymmetric_key_id_partial);
+DEFINE_CRYPTO_API_STUB(asymmetric_key_generate_id);
+DEFINE_CRYPTO_API_STUB(find_asymmetric_key);
+
+#undef key_type_asymmetric
+DEFINE_CRYPTO_VAR_STUB(key_type_asymmetric);
+
+#endif
+/*
+ * crypto/asymmetric_keys/signature.c
+ */
+#if IS_BUILTIN(CONFIG_ASYMMETRIC_KEY_TYPE)
+
+#include <crypto/public_key.h>
+
+DEFINE_CRYPTO_API_STUB(public_key_signature_free);
+DEFINE_CRYPTO_API_STUB(query_asymmetric_key);
+DEFINE_CRYPTO_API_STUB(verify_signature);
+
+#endif
+/*
+ * crypto/asymmetric_keys/restrict.c
+ */
+#if IS_BUILTIN(CONFIG_ASYMMETRIC_KEY_TYPE)
+
+#include <crypto/public_key.h>
+
+DEFINE_CRYPTO_API_STUB(restrict_link_by_signature);
+DEFINE_CRYPTO_API_STUB(restrict_link_by_digsig);
+
+#endif
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
index 4c5199b20338..be789854fdcb 100644
--- a/include/crypto/public_key.h
+++ b/include/crypto/public_key.h
@@ -10,6 +10,7 @@
#ifndef _LINUX_PUBLIC_KEY_H
#define _LINUX_PUBLIC_KEY_H
+#include <crypto/api.h>
#include <linux/errno.h>
#include <linux/keyctl.h>
#include <linux/oid_registry.h>
@@ -53,7 +54,9 @@ struct public_key_signature {
const char *encoding;
};
-extern void public_key_signature_free(struct public_key_signature *sig);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, public_key_signature_free, void,
+ (struct public_key_signature *sig),
+ (sig));
extern struct asymmetric_key_subtype public_key_subtype;
@@ -61,10 +64,9 @@ struct key;
struct key_type;
union key_payload;
-extern int restrict_link_by_signature(struct key *dest_keyring,
- const struct key_type *type,
- const union key_payload *payload,
- struct key *trust_keyring);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, restrict_link_by_signature, int,
+ (struct key *dest_keyring, const struct key_type *type, const union key_payload *payload, struct key *trust_keyring),
+ (dest_keyring, type, payload, trust_keyring));
extern int restrict_link_by_key_or_keyring(struct key *dest_keyring,
const struct key_type *type,
@@ -81,10 +83,9 @@ extern int restrict_link_by_ca(struct key *dest_keyring,
const struct key_type *type,
const union key_payload *payload,
struct key *trust_keyring);
-int restrict_link_by_digsig(struct key *dest_keyring,
- const struct key_type *type,
- const union key_payload *payload,
- struct key *trust_keyring);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, restrict_link_by_digsig, int,
+ (struct key *dest_keyring, const struct key_type *type, const union key_payload *payload, struct key *trust_keyring),
+ (dest_keyring, type, payload, trust_keyring));
#else
static inline int restrict_link_by_ca(struct key *dest_keyring,
const struct key_type *type,
@@ -103,11 +104,13 @@ static inline int restrict_link_by_digsig(struct key *dest_keyring,
}
#endif
-extern int query_asymmetric_key(const struct kernel_pkey_params *,
- struct kernel_pkey_query *);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, query_asymmetric_key, int,
+ (const struct kernel_pkey_params *arg1, struct kernel_pkey_query *arg2),
+ (arg1, arg2));
-extern int verify_signature(const struct key *,
- const struct public_key_signature *);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, verify_signature, int,
+ (const struct key *arg1, const struct public_key_signature *arg2),
+ (arg1, arg2));
#if IS_REACHABLE(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE)
int public_key_verify_signature(const struct public_key *pkey,
diff --git a/include/keys/asymmetric-parser.h b/include/keys/asymmetric-parser.h
index 516a3f51179e..13474b17055b 100644
--- a/include/keys/asymmetric-parser.h
+++ b/include/keys/asymmetric-parser.h
@@ -29,7 +29,11 @@ struct asymmetric_key_parser {
int (*parse)(struct key_preparsed_payload *prep);
};
-extern int register_asymmetric_key_parser(struct asymmetric_key_parser *);
-extern void unregister_asymmetric_key_parser(struct asymmetric_key_parser *);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, register_asymmetric_key_parser, int,
+ (struct asymmetric_key_parser *parser),
+ (parser));
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, unregister_asymmetric_key_parser, void,
+ (struct asymmetric_key_parser *parser),
+ (parser));
#endif /* _KEYS_ASYMMETRIC_PARSER_H */
diff --git a/include/keys/asymmetric-type.h b/include/keys/asymmetric-type.h
index 1b91c8f98688..96e718a550a3 100644
--- a/include/keys/asymmetric-type.h
+++ b/include/keys/asymmetric-type.h
@@ -10,10 +10,15 @@
#ifndef _KEYS_ASYMMETRIC_TYPE_H
#define _KEYS_ASYMMETRIC_TYPE_H
+#include <crypto/api.h>
#include <linux/key-type.h>
#include <linux/verification.h>
-extern struct key_type key_type_asymmetric;
+DECLARE_CRYPTO_VAR(CONFIG_ASYMMETRIC_KEY_TYPE, key_type_asymmetric, struct key_type, );
+
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_ASYMMETRIC_KEY_TYPE)
+#define key_type_asymmetric (*((struct key_type*)CRYPTO_VAR_NAME(key_type_asymmetric)))
+#endif
/*
* The key payload is four words. The asymmetric-type key uses them as
@@ -56,16 +61,17 @@ struct asymmetric_key_ids {
void *id[3];
};
-extern bool asymmetric_key_id_same(const struct asymmetric_key_id *kid1,
- const struct asymmetric_key_id *kid2);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, asymmetric_key_id_same, bool,
+ (const struct asymmetric_key_id *kid1, const struct asymmetric_key_id *kid2),
+ (kid1, kid2));
-extern bool asymmetric_key_id_partial(const struct asymmetric_key_id *kid1,
- const struct asymmetric_key_id *kid2);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, asymmetric_key_id_partial, bool,
+ (const struct asymmetric_key_id *kid1, const struct asymmetric_key_id *kid2),
+ (kid1, kid2));
-extern struct asymmetric_key_id *asymmetric_key_generate_id(const void *val_1,
- size_t len_1,
- const void *val_2,
- size_t len_2);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, asymmetric_key_generate_id, struct asymmetric_key_id *,
+ (const void *val_1, size_t len_1, const void *val_2, size_t len_2),
+ (val_1, len_1, val_2, len_2));
static inline
const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key)
{
@@ -78,11 +84,9 @@ const struct public_key *asymmetric_key_public_key(const struct key *key)
return key->payload.data[asym_crypto];
}
-extern struct key *find_asymmetric_key(struct key *keyring,
- const struct asymmetric_key_id *id_0,
- const struct asymmetric_key_id *id_1,
- const struct asymmetric_key_id *id_2,
- bool partial);
+DECLARE_CRYPTO_API(CONFIG_ASYMMETRIC_KEY_TYPE, find_asymmetric_key, struct key *,
+ (struct key *keyring, const struct asymmetric_key_id *id_0, const struct asymmetric_key_id *id_1, const struct asymmetric_key_id *id_2, bool partial),
+ (keyring, id_0, id_1, id_2, partial));
int x509_load_certificate_list(const u8 cert_list[], const unsigned long list_size,
const struct key *keyring);
--
2.47.3
^ permalink raw reply related
* [PATCH 031/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GHASH 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_GHASH-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add ghash-generic.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/ghash-generic.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 1d5ee8dc24d9..d58b5e2b5b43 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -171,7 +171,7 @@ UBSAN_SANITIZE_jitterentropy.o = n
jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o
obj-$(CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE) += jitterentropy-testing.o
obj-$(CONFIG_CRYPTO_BENCHMARK) += tcrypt.o
-obj-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
+crypto-objs-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
obj-$(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
diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c
index e5803c249c12..37e98aa546c7 100644
--- a/crypto/ghash-generic.c
+++ b/crypto/ghash-generic.c
@@ -153,8 +153,8 @@ static void __exit ghash_mod_exit(void)
crypto_unregister_shash(&ghash_alg);
}
-module_init(ghash_mod_init);
-module_exit(ghash_mod_exit);
+crypto_module_init(ghash_mod_init);
+crypto_module_exit(ghash_mod_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GHASH hash function");
--
2.47.3
^ permalink raw reply related
* [PATCH 030/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_JITTERENTROPY 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_JITTERENTROPY-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add jitterentropy_rng.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/jitterentropy-kcapi.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 25f0d9d56469..1d5ee8dc24d9 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -164,7 +164,7 @@ obj-$(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
-obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
+crypto-objs-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
CFLAGS_jitterentropy.o = -O0
KASAN_SANITIZE_jitterentropy.o = n
UBSAN_SANITIZE_jitterentropy.o = n
diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
index 7c880cf34c52..11115b8df694 100644
--- a/crypto/jitterentropy-kcapi.c
+++ b/crypto/jitterentropy-kcapi.c
@@ -361,8 +361,8 @@ static void __exit jent_mod_exit(void)
crypto_unregister_rng(&jent_alg);
}
-module_init(jent_mod_init);
-module_exit(jent_mod_exit);
+crypto_module_init(jent_mod_init);
+crypto_module_exit(jent_mod_exit);
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>");
--
2.47.3
^ permalink raw reply related
* [PATCH 029/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_DRBG 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_DRBG-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add drbg.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/drbg.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 4c87e141c961..25f0d9d56469 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -163,7 +163,7 @@ obj-$(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
-obj-$(CONFIG_CRYPTO_DRBG) += drbg.o
+crypto-objs-$(CONFIG_CRYPTO_DRBG) += drbg.o
obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
CFLAGS_jitterentropy.o = -O0
KASAN_SANITIZE_jitterentropy.o = n
diff --git a/crypto/drbg.c b/crypto/drbg.c
index 5e7ed5f5c192..f4eba9ef6d59 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1882,8 +1882,8 @@ static void __exit drbg_exit(void)
crypto_unregister_rngs(drbg_algs, (ARRAY_SIZE(drbg_cores) * 2));
}
-module_init(drbg_init);
-module_exit(drbg_exit);
+crypto_module_init(drbg_init);
+crypto_module_exit(drbg_exit);
#ifndef CRYPTO_DRBG_HASH_STRING
#define CRYPTO_DRBG_HASH_STRING ""
#endif
--
2.47.3
^ permalink raw reply related
* [PATCH 028/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RNG2 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_RNG2-related crypto to convert them into pluggable
interface.
This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.
Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/fips140/fips140-api.c | 23 ++++++++++++++++++++++-
include/crypto/internal/rng.h | 21 ++++++++++++++++-----
include/crypto/rng.h | 18 +++++++++++++-----
4 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 647797922678..4c87e141c961 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -162,7 +162,7 @@ obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
obj-$(CONFIG_CRYPTO_842) += 842.o
-obj-$(CONFIG_CRYPTO_RNG2) += rng.o
+crypto-objs-$(CONFIG_CRYPTO_RNG2) += rng.o
obj-$(CONFIG_CRYPTO_DRBG) += drbg.o
obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o
CFLAGS_jitterentropy.o = -O0
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 3cfe147b984c..20afa1c21cf0 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -391,4 +391,25 @@ DEFINE_CRYPTO_VAR_STUB(md5_zero_message_hash);
DEFINE_CRYPTO_API_STUB(crypto_authenc_extractkeys);
-#endif
\ No newline at end of file
+#endif
+/*
+ * crypto/rng.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_RNG2)
+
+#include <crypto/rng.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_get_default_rng);
+DEFINE_CRYPTO_API_STUB(crypto_put_default_rng);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_rng);
+DEFINE_CRYPTO_API_STUB(crypto_rng_reset);
+
+#include <crypto/internal/rng.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_register_rng);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_rng);
+DEFINE_CRYPTO_API_STUB(crypto_register_rngs);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_rngs);
+DEFINE_CRYPTO_API_STUB(crypto_del_default_rng);
+
+#endif
diff --git a/include/crypto/internal/rng.h b/include/crypto/internal/rng.h
index e0711b6a597f..b281d8eb9405 100644
--- a/include/crypto/internal/rng.h
+++ b/include/crypto/internal/rng.h
@@ -9,16 +9,27 @@
#ifndef _CRYPTO_INTERNAL_RNG_H
#define _CRYPTO_INTERNAL_RNG_H
+#include <crypto/api.h>
#include <crypto/algapi.h>
#include <crypto/rng.h>
-int crypto_register_rng(struct rng_alg *alg);
-void crypto_unregister_rng(struct rng_alg *alg);
-int crypto_register_rngs(struct rng_alg *algs, int count);
-void crypto_unregister_rngs(struct rng_alg *algs, int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_register_rng, int,
+ (struct rng_alg *alg),
+ (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_unregister_rng, void,
+ (struct rng_alg *alg),
+ (alg));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_register_rngs, int,
+ (struct rng_alg *algs, int count),
+ (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_unregister_rngs, void,
+ (struct rng_alg *algs, int count),
+ (algs, count));
#if defined(CONFIG_CRYPTO_RNG) || defined(CONFIG_CRYPTO_RNG_MODULE)
-int crypto_del_default_rng(void);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_del_default_rng, int,
+ (void),
+ ());
#else
static inline int crypto_del_default_rng(void)
{
diff --git a/include/crypto/rng.h b/include/crypto/rng.h
index d451b54b322a..89a78f4a6e37 100644
--- a/include/crypto/rng.h
+++ b/include/crypto/rng.h
@@ -9,6 +9,7 @@
#ifndef _CRYPTO_RNG_H
#define _CRYPTO_RNG_H
+#include <crypto/api.h>
#include <linux/atomic.h>
#include <linux/container_of.h>
#include <linux/crypto.h>
@@ -59,8 +60,12 @@ struct crypto_rng {
extern struct crypto_rng *crypto_default_rng;
-int crypto_get_default_rng(void);
-void crypto_put_default_rng(void);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_get_default_rng, int,
+ (void),
+ ());
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_put_default_rng, void,
+ (void),
+ ());
/**
* DOC: Random number generator API
@@ -89,7 +94,9 @@ void crypto_put_default_rng(void);
* Return: allocated cipher handle in case of success; IS_ERR() is true in case
* of an error, PTR_ERR() returns the error code.
*/
-struct crypto_rng *crypto_alloc_rng(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_alloc_rng, struct crypto_rng *,
+ (const char *alg_name, u32 type, u32 mask),
+ (alg_name, type, mask));
static inline struct crypto_tfm *crypto_rng_tfm(struct crypto_rng *tfm)
{
@@ -177,8 +184,9 @@ static inline int crypto_rng_get_bytes(struct crypto_rng *tfm,
*
* Return: 0 if the setting of the key was successful; < 0 if an error occurred
*/
-int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed,
- unsigned int slen);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RNG2, crypto_rng_reset, int,
+ (struct crypto_rng *tfm, const u8 *seed, unsigned int slen),
+ (tfm, seed, slen));
/**
* crypto_rng_seedsize() - obtain seed size of RNG
--
2.47.3
^ permalink raw reply related
* [PATCH 027/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_LZO 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_LZO-related crypto to convert them into pluggable
interface.
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/lzo-rle.c | 4 ++--
crypto/lzo.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 3a2da61b4581..647797922678 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -157,7 +157,7 @@ obj-$(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
-obj-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
+crypto-objs-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o
diff --git a/crypto/lzo-rle.c b/crypto/lzo-rle.c
index 794e7ec49536..10af97e741fa 100644
--- a/crypto/lzo-rle.c
+++ b/crypto/lzo-rle.c
@@ -93,8 +93,8 @@ static void __exit lzorle_mod_fini(void)
crypto_unregister_scomp(&scomp);
}
-module_init(lzorle_mod_init);
-module_exit(lzorle_mod_fini);
+crypto_module_init(lzorle_mod_init);
+crypto_module_exit(lzorle_mod_fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("LZO-RLE Compression Algorithm");
diff --git a/crypto/lzo.c b/crypto/lzo.c
index d43242b24b4e..e1f9bc40f89f 100644
--- a/crypto/lzo.c
+++ b/crypto/lzo.c
@@ -93,8 +93,8 @@ static void __exit lzo_mod_fini(void)
crypto_unregister_scomp(&scomp);
}
-module_init(lzo_mod_init);
-module_exit(lzo_mod_fini);
+crypto_module_init(lzo_mod_init);
+crypto_module_exit(lzo_mod_fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("LZO Compression Algorithm");
--
2.47.3
^ permalink raw reply related
* [PATCH 026/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_AUTHENC 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_AUTHENC-related crypto to convert them into pluggable
interface.
This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.
Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/authenc.c | 4 ++--
crypto/authencesn.c | 4 ++--
crypto/fips140/fips140-api.c | 12 ++++++++++++
include/crypto/authenc.h | 6 ++++--
5 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 9dc0d5d55eaa..3a2da61b4581 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -155,7 +155,7 @@ obj-$(CONFIG_CRYPTO_CRC32C) += crc32c-cryptoapi.o
crc32c-cryptoapi-y := crc32c.o
obj-$(CONFIG_CRYPTO_CRC32) += crc32-cryptoapi.o
crc32-cryptoapi-y := crc32.o
-obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
+crypto-objs-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
obj-$(CONFIG_CRYPTO_KRB5ENC) += krb5enc.o
obj-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o
obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
diff --git a/crypto/authenc.c b/crypto/authenc.c
index ac679ce2cb95..132c30d75165 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -446,8 +446,8 @@ static void __exit crypto_authenc_module_exit(void)
crypto_unregister_template(&crypto_authenc_tmpl);
}
-module_init(crypto_authenc_module_init);
-module_exit(crypto_authenc_module_exit);
+crypto_module_init(crypto_authenc_module_init);
+crypto_module_exit(crypto_authenc_module_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Simple AEAD wrapper for IPsec");
diff --git a/crypto/authencesn.c b/crypto/authencesn.c
index 542a978663b9..6279d877a95a 100644
--- a/crypto/authencesn.c
+++ b/crypto/authencesn.c
@@ -439,8 +439,8 @@ static void __exit crypto_authenc_esn_module_exit(void)
crypto_unregister_template(&crypto_authenc_esn_tmpl);
}
-module_init(crypto_authenc_esn_module_init);
-module_exit(crypto_authenc_esn_module_exit);
+crypto_module_init(crypto_authenc_esn_module_init);
+crypto_module_exit(crypto_authenc_esn_module_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Steffen Klassert <steffen.klassert@secunet.com>");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 77ed24a3cd3b..3cfe147b984c 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -379,4 +379,16 @@ DEFINE_CRYPTO_API_STUB(alg_test);
#undef md5_zero_message_hash
DEFINE_CRYPTO_VAR_STUB(md5_zero_message_hash);
+
+#endif
+
+/*
+ * crypto/authenc.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_AUTHENC)
+
+#include <crypto/authenc.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_authenc_extractkeys);
+
#endif
\ No newline at end of file
diff --git a/include/crypto/authenc.h b/include/crypto/authenc.h
index 15a9caa2354a..4871b7bdcd8e 100644
--- a/include/crypto/authenc.h
+++ b/include/crypto/authenc.h
@@ -7,6 +7,7 @@
#ifndef _CRYPTO_AUTHENC_H
#define _CRYPTO_AUTHENC_H
+#include <crypto/api.h>
#include <linux/types.h>
enum {
@@ -26,8 +27,9 @@ struct crypto_authenc_keys {
unsigned int enckeylen;
};
-int crypto_authenc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key,
- unsigned int keylen);
+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);
--
2.47.3
^ permalink raw reply related
* [PATCH 025/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CCM 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CCM-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add ccm.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/ccm.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 11bb65cf0094..9dc0d5d55eaa 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -99,7 +99,7 @@ obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
crypto-objs-$(CONFIG_CRYPTO_GCM) += gcm.o
-obj-$(CONFIG_CRYPTO_CCM) += ccm.o
+crypto-objs-$(CONFIG_CRYPTO_CCM) += ccm.o
obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
aegis128-y := aegis128-core.o
diff --git a/crypto/ccm.c b/crypto/ccm.c
index 2ae929ffdef8..e76946e05b5e 100644
--- a/crypto/ccm.c
+++ b/crypto/ccm.c
@@ -929,8 +929,8 @@ static void __exit crypto_ccm_module_exit(void)
ARRAY_SIZE(crypto_ccm_tmpls));
}
-module_init(crypto_ccm_module_init);
-module_exit(crypto_ccm_module_exit);
+crypto_module_init(crypto_ccm_module_init);
+crypto_module_exit(crypto_ccm_module_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Counter with CBC MAC");
--
2.47.3
^ permalink raw reply related
* [PATCH 024/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_GCM 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_GCM-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add gcm.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/gcm.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index d5b5ca797dc6..11bb65cf0094 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -98,7 +98,7 @@ crypto-objs-$(CONFIG_CRYPTO_CTR) += ctr.o
obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
-obj-$(CONFIG_CRYPTO_GCM) += gcm.o
+crypto-objs-$(CONFIG_CRYPTO_GCM) += gcm.o
obj-$(CONFIG_CRYPTO_CCM) += ccm.o
obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
diff --git a/crypto/gcm.c b/crypto/gcm.c
index 97716482bed0..54a376e782d1 100644
--- a/crypto/gcm.c
+++ b/crypto/gcm.c
@@ -1119,8 +1119,8 @@ static void __exit crypto_gcm_module_exit(void)
ARRAY_SIZE(crypto_gcm_tmpls));
}
-module_init(crypto_gcm_module_init);
-module_exit(crypto_gcm_module_exit);
+crypto_module_init(crypto_gcm_module_init);
+crypto_module_exit(crypto_gcm_module_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Galois/Counter Mode");
--
2.47.3
^ permalink raw reply related
* [PATCH 023/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CTR crypto
From: Jay Wang @ 2026-02-12 2:45 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CTR-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add ctr.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/ctr.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 354ce7a46a0a..d5b5ca797dc6 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -94,7 +94,7 @@ obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
obj-$(CONFIG_CRYPTO_CTS) += cts.o
obj-$(CONFIG_CRYPTO_LRW) += lrw.o
obj-$(CONFIG_CRYPTO_XTS) += xts.o
-obj-$(CONFIG_CRYPTO_CTR) += ctr.o
+crypto-objs-$(CONFIG_CRYPTO_CTR) += ctr.o
obj-$(CONFIG_CRYPTO_XCTR) += xctr.o
obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o
obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o
diff --git a/crypto/ctr.c b/crypto/ctr.c
index a388f0ceb3a0..fa67cf6de4b1 100644
--- a/crypto/ctr.c
+++ b/crypto/ctr.c
@@ -350,8 +350,8 @@ static void __exit crypto_ctr_module_exit(void)
ARRAY_SIZE(crypto_ctr_tmpls));
}
-module_init(crypto_ctr_module_init);
-module_exit(crypto_ctr_module_exit);
+crypto_module_init(crypto_ctr_module_init);
+crypto_module_exit(crypto_ctr_module_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("CTR block cipher mode of operation");
--
2.47.3
^ permalink raw reply related
* [PATCH 022/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CBC crypto
From: Jay Wang @ 2026-02-12 2:45 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CBC-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add cbc.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/cbc.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 11a6714dee42..354ce7a46a0a 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -89,7 +89,7 @@ obj-$(CONFIG_CRYPTO_WP512) += wp512.o
CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b.o
crypto-objs-$(CONFIG_CRYPTO_ECB) += ecb.o
-obj-$(CONFIG_CRYPTO_CBC) += cbc.o
+crypto-objs-$(CONFIG_CRYPTO_CBC) += cbc.o
obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
obj-$(CONFIG_CRYPTO_CTS) += cts.o
obj-$(CONFIG_CRYPTO_LRW) += lrw.o
diff --git a/crypto/cbc.c b/crypto/cbc.c
index ed3df6246765..03ee7008ab12 100644
--- a/crypto/cbc.c
+++ b/crypto/cbc.c
@@ -179,8 +179,8 @@ static void __exit crypto_cbc_module_exit(void)
crypto_unregister_template(&crypto_cbc_tmpl);
}
-module_init(crypto_cbc_module_init);
-module_exit(crypto_cbc_module_exit);
+crypto_module_init(crypto_cbc_module_init);
+crypto_module_exit(crypto_cbc_module_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("CBC block cipher mode of operation");
--
2.47.3
^ permalink raw reply related
* [PATCH 021/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ECB crypto
From: Jay Wang @ 2026-02-12 2:45 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_ECB-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add ecb.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/ecb.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 251b20fad9c2..11a6714dee42 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -88,7 +88,7 @@ obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
obj-$(CONFIG_CRYPTO_WP512) += wp512.o
CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b.o
-obj-$(CONFIG_CRYPTO_ECB) += ecb.o
+crypto-objs-$(CONFIG_CRYPTO_ECB) += ecb.o
obj-$(CONFIG_CRYPTO_CBC) += cbc.o
obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
obj-$(CONFIG_CRYPTO_CTS) += cts.o
diff --git a/crypto/ecb.c b/crypto/ecb.c
index cd1b20456dad..20127b20f483 100644
--- a/crypto/ecb.c
+++ b/crypto/ecb.c
@@ -219,8 +219,8 @@ static void __exit crypto_ecb_module_exit(void)
crypto_unregister_template(&crypto_ecb_tmpl);
}
-module_init(crypto_ecb_module_init);
-module_exit(crypto_ecb_module_exit);
+crypto_module_init(crypto_ecb_module_init);
+crypto_module_exit(crypto_ecb_module_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("ECB block cipher mode of operation");
--
2.47.3
^ permalink raw reply related
* [PATCH 020/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA3 crypto
From: Jay Wang @ 2026-02-12 2:45 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_SHA3-related crypto to convert them into pluggable
interface.
This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.
Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/sha3.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 47ff0136c7c5..251b20fad9c2 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -82,7 +82,7 @@ obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
crypto-objs-$(CONFIG_CRYPTO_SHA256) += sha256.o
crypto-objs-$(CONFIG_CRYPTO_SHA512) += sha512.o
-obj-$(CONFIG_CRYPTO_SHA3) += sha3.o
+crypto-objs-$(CONFIG_CRYPTO_SHA3) += sha3.o
obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
obj-$(CONFIG_CRYPTO_WP512) += wp512.o
diff --git a/crypto/sha3.c b/crypto/sha3.c
index 8f364979ec89..1aefb256dd72 100644
--- a/crypto/sha3.c
+++ b/crypto/sha3.c
@@ -145,13 +145,13 @@ static int __init crypto_sha3_mod_init(void)
{
return crypto_register_shashes(algs, ARRAY_SIZE(algs));
}
-module_init(crypto_sha3_mod_init);
+crypto_module_init(crypto_sha3_mod_init);
static void __exit crypto_sha3_mod_exit(void)
{
crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
}
-module_exit(crypto_sha3_mod_exit);
+crypto_module_exit(crypto_sha3_mod_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Crypto API support for SHA-3");
--
2.47.3
^ permalink raw reply related
* [PATCH 019/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA512 crypto
From: Jay Wang @ 2026-02-12 2:45 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SHA512-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add sha512.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/sha512.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 45e055a8c0f4..47ff0136c7c5 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -81,7 +81,7 @@ crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
crypto-objs-$(CONFIG_CRYPTO_SHA256) += sha256.o
-obj-$(CONFIG_CRYPTO_SHA512) += sha512.o
+crypto-objs-$(CONFIG_CRYPTO_SHA512) += sha512.o
obj-$(CONFIG_CRYPTO_SHA3) += sha3.o
obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
diff --git a/crypto/sha512.c b/crypto/sha512.c
index d320fe53913f..6e40932862d5 100644
--- a/crypto/sha512.c
+++ b/crypto/sha512.c
@@ -404,13 +404,13 @@ static int __init crypto_sha512_mod_init(void)
{
return crypto_register_shashes(algs, ARRAY_SIZE(algs));
}
-module_init(crypto_sha512_mod_init);
+crypto_module_init(crypto_sha512_mod_init);
static void __exit crypto_sha512_mod_exit(void)
{
crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
}
-module_exit(crypto_sha512_mod_exit);
+crypto_module_exit(crypto_sha512_mod_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Crypto API support for SHA-384, SHA-512, HMAC-SHA384, and HMAC-SHA512");
--
2.47.3
^ permalink raw reply related
* [PATCH 018/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_SHA256 crypto
From: Jay Wang @ 2026-02-12 2:45 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_SHA256-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add sha256.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/sha256.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 6310c3e88e4b..45e055a8c0f4 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -80,7 +80,7 @@ obj-$(CONFIG_CRYPTO_MD4) += md4.o
crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
-obj-$(CONFIG_CRYPTO_SHA256) += sha256.o
+crypto-objs-$(CONFIG_CRYPTO_SHA256) += sha256.o
obj-$(CONFIG_CRYPTO_SHA512) += sha512.o
obj-$(CONFIG_CRYPTO_SHA3) += sha3.o
obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
diff --git a/crypto/sha256.c b/crypto/sha256.c
index fb81defe084c..26ae39b4c1db 100644
--- a/crypto/sha256.c
+++ b/crypto/sha256.c
@@ -398,13 +398,13 @@ static int __init crypto_sha256_mod_init(void)
{
return crypto_register_shashes(algs, ARRAY_SIZE(algs));
}
-module_init(crypto_sha256_mod_init);
+crypto_module_init(crypto_sha256_mod_init);
static void __exit crypto_sha256_mod_exit(void)
{
crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
}
-module_exit(crypto_sha256_mod_exit);
+crypto_module_exit(crypto_sha256_mod_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Crypto API support for SHA-224, SHA-256, HMAC-SHA224, and HMAC-SHA256");
--
2.47.3
^ permalink raw reply related
* [PATCH 017/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MD5 crypto
From: Jay Wang @ 2026-02-12 2:45 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_MD5-related crypto to convert them into pluggable
interface.
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/fips140/fips140-api.c | 11 +++++++++++
crypto/md5.c | 4 ++--
include/crypto/md5.h | 8 +++++++-
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 4d03d612b942..6310c3e88e4b 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -77,7 +77,7 @@ crypto-objs-$(CONFIG_CRYPTO_HMAC) += hmac.o
obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
obj-$(CONFIG_CRYPTO_MD4) += md4.o
-obj-$(CONFIG_CRYPTO_MD5) += md5.o
+crypto-objs-$(CONFIG_CRYPTO_MD5) += md5.o
obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
obj-$(CONFIG_CRYPTO_SHA256) += sha256.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 17e03d4c1c9a..77ed24a3cd3b 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -368,4 +368,15 @@ DEFINE_CRYPTO_API_STUB(crypto_unregister_scomps);
DEFINE_CRYPTO_API_STUB(alg_test);
+#endif
+
+/*
+ * crypto/md5.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_MD5)
+
+#include <crypto/md5.h>
+
+#undef md5_zero_message_hash
+DEFINE_CRYPTO_VAR_STUB(md5_zero_message_hash);
#endif
\ No newline at end of file
diff --git a/crypto/md5.c b/crypto/md5.c
index c167d203c710..3a11675585c7 100644
--- a/crypto/md5.c
+++ b/crypto/md5.c
@@ -219,13 +219,13 @@ static int __init crypto_md5_mod_init(void)
{
return crypto_register_shashes(algs, ARRAY_SIZE(algs));
}
-module_init(crypto_md5_mod_init);
+crypto_module_init(crypto_md5_mod_init);
static void __exit crypto_md5_mod_exit(void)
{
crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
}
-module_exit(crypto_md5_mod_exit);
+crypto_module_exit(crypto_md5_mod_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Crypto API support for MD5 and HMAC-MD5");
diff --git a/include/crypto/md5.h b/include/crypto/md5.h
index c47aedfe67ec..9ec82ce94c1a 100644
--- a/include/crypto/md5.h
+++ b/include/crypto/md5.h
@@ -2,6 +2,7 @@
#ifndef _CRYPTO_MD5_H
#define _CRYPTO_MD5_H
+#include <crypto/api.h>
#include <crypto/hash.h>
#include <linux/types.h>
@@ -20,7 +21,12 @@
#define CRYPTO_MD5_STATESIZE \
CRYPTO_HASH_STATESIZE(MD5_STATE_SIZE, MD5_HMAC_BLOCK_SIZE)
-extern const u8 md5_zero_message_hash[MD5_DIGEST_SIZE];
+DECLARE_CRYPTO_VAR(CONFIG_CRYPTO_MD5, md5_zero_message_hash, const u8, [MD5_DIGEST_SIZE]);
+
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE) && IS_BUILTIN(CONFIG_CRYPTO_MD5)
+#define md5_zero_message_hash (((const u8*)CRYPTO_VAR_NAME(md5_zero_message_hash)))
+#endif
+
struct md5_state {
u32 hash[MD5_HASH_WORDS];
--
2.47.3
^ permalink raw reply related
* [PATCH 016/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_HMAC crypto
From: Jay Wang @ 2026-02-12 2:45 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_HMAC-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add hmac.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/hmac.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index d37e00783f84..4d03d612b942 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -73,7 +73,7 @@ cryptomgr-y := algboss.o testmgr.o
crypto-objs-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
crypto-objs-$(CONFIG_CRYPTO_CMAC) += cmac.o
-obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
+crypto-objs-$(CONFIG_CRYPTO_HMAC) += hmac.o
obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
obj-$(CONFIG_CRYPTO_MD4) += md4.o
diff --git a/crypto/hmac.c b/crypto/hmac.c
index 148af460ae97..d8d24a2ea2f7 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -573,8 +573,8 @@ static void __exit hmac_module_exit(void)
crypto_unregister_templates(hmac_tmpls, ARRAY_SIZE(hmac_tmpls));
}
-module_init(hmac_module_init);
-module_exit(hmac_module_exit);
+crypto_module_init(hmac_module_init);
+crypto_module_exit(hmac_module_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("HMAC hash algorithm");
--
2.47.3
^ permalink raw reply related
* [PATCH 015/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_CMAC crypto
From: Jay Wang @ 2026-02-12 2:45 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>
From: Vegard Nossum <vegard.nossum@oracle.com>
Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CMAC-related crypto to convert them into pluggable
interface.
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[add cmac.o into crypto-objs-y; revise commit message]
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/cmac.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 10cf1c6991fa..d37e00783f84 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -72,7 +72,7 @@ cryptomgr-y := algboss.o testmgr.o
crypto-objs-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
-obj-$(CONFIG_CRYPTO_CMAC) += cmac.o
+crypto-objs-$(CONFIG_CRYPTO_CMAC) += cmac.o
obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
diff --git a/crypto/cmac.c b/crypto/cmac.c
index 1b03964abe00..f898c4612312 100644
--- a/crypto/cmac.c
+++ b/crypto/cmac.c
@@ -251,8 +251,8 @@ static void __exit crypto_cmac_module_exit(void)
crypto_unregister_template(&crypto_cmac_tmpl);
}
-module_init(crypto_cmac_module_init);
-module_exit(crypto_cmac_module_exit);
+crypto_module_init(crypto_cmac_module_init);
+crypto_module_exit(crypto_cmac_module_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("CMAC keyed hash algorithm");
--
2.47.3
^ permalink raw reply related
* [PATCH 014/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MANAGER2 crypto
From: Jay Wang @ 2026-02-12 2:45 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_MANAGER2-related crypto to convert them into pluggable
interface.
This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.
Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/algboss.c | 4 ++--
crypto/fips140/fips140-api.c | 11 +++++++++++
crypto/internal.h | 3 ++-
4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index e940f9ed357d..10cf1c6991fa 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -70,7 +70,7 @@ crypto-objs-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
cryptomgr-y := algboss.o testmgr.o
-obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
+crypto-objs-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
obj-$(CONFIG_CRYPTO_CMAC) += cmac.o
obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
diff --git a/crypto/algboss.c b/crypto/algboss.c
index 846f586889ee..1c26524e2541 100644
--- a/crypto/algboss.c
+++ b/crypto/algboss.c
@@ -247,8 +247,8 @@ static void __exit cryptomgr_exit(void)
BUG_ON(err);
}
-module_init(cryptomgr_init);
-module_exit(cryptomgr_exit);
+crypto_module_init(cryptomgr_init);
+crypto_module_exit(cryptomgr_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Crypto Algorithm Manager");
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 9a9c66cc1d90..17e03d4c1c9a 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -357,4 +357,15 @@ DEFINE_CRYPTO_API_STUB(crypto_unregister_scomp);
DEFINE_CRYPTO_API_STUB(crypto_register_scomps);
DEFINE_CRYPTO_API_STUB(crypto_unregister_scomps);
+#endif
+
+/*
+ * crypto/testmgr.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_MANAGER2)
+
+#include <crypto/internal.h>
+
+DEFINE_CRYPTO_API_STUB(alg_test);
+
#endif
\ No newline at end of file
diff --git a/crypto/internal.h b/crypto/internal.h
index 8ebe4dc336bc..0296d9830c62 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -8,6 +8,7 @@
#ifndef _CRYPTO_INTERNAL_H
#define _CRYPTO_INTERNAL_H
+#include <crypto/api.h>
#include <crypto/algapi.h>
#include <linux/completion.h>
#include <linux/err.h>
@@ -65,7 +66,7 @@ extern struct rw_semaphore crypto_alg_sem;
extern struct list_head crypto_alg_list __guarded_by(&crypto_alg_sem);
extern struct blocking_notifier_head crypto_chain;
-int alg_test(const char *driver, const char *alg, u32 type, u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_MANAGER2, alg_test, int, (const char *driver, const char *alg, u32 type, u32 mask), (driver, alg, type, mask));
#if !IS_BUILTIN(CONFIG_CRYPTO_ALGAPI) || !IS_ENABLED(CONFIG_CRYPTO_SELFTESTS)
static inline bool crypto_boot_test_finished(void)
--
2.47.3
^ permalink raw reply related
* [PATCH 013/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_ACOMP2 crypto
From: Jay Wang @ 2026-02-12 2:45 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_ACOMP2-related crypto to convert them into pluggable
interface.
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/fips140/fips140-api.c | 42 +++++++++++++++++++++++++++++
include/crypto/acompress.h | 14 +++++-----
include/crypto/internal/acompress.h | 27 +++++++++----------
include/crypto/internal/scompress.h | 9 ++++---
5 files changed, 67 insertions(+), 27 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 3e12b556bfa7..e940f9ed357d 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -66,7 +66,7 @@ obj-$(CONFIG_CRYPTO_MLDSA) += mldsa.o
crypto_acompress-y := acompress.o
crypto_acompress-y += scompress.o
-obj-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
+crypto-objs-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
cryptomgr-y := algboss.o testmgr.o
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index d10eded6b61e..9a9c66cc1d90 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -315,4 +315,46 @@ DEFINE_CRYPTO_API_STUB(kpp_register_instance);
DEFINE_CRYPTO_API_STUB(rsa_parse_pub_key);
DEFINE_CRYPTO_API_STUB(rsa_parse_priv_key);
+#endif
+
+/*
+ * crypto/acompress.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ACOMP2)
+
+#include <crypto/acompress.h>
+#include <crypto/internal/acompress.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_alloc_acomp);
+DEFINE_CRYPTO_API_STUB(crypto_alloc_acomp_node);
+DEFINE_CRYPTO_API_STUB(crypto_acomp_compress);
+DEFINE_CRYPTO_API_STUB(crypto_acomp_decompress);
+DEFINE_CRYPTO_API_STUB(crypto_register_acomp);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_acomp);
+DEFINE_CRYPTO_API_STUB(crypto_register_acomps);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_acomps);
+DEFINE_CRYPTO_API_STUB(crypto_acomp_free_streams);
+DEFINE_CRYPTO_API_STUB(crypto_acomp_alloc_streams);
+DEFINE_CRYPTO_API_STUB(_crypto_acomp_lock_stream_bh);
+DEFINE_CRYPTO_API_STUB(acomp_walk_done_src);
+DEFINE_CRYPTO_API_STUB(acomp_walk_done_dst);
+DEFINE_CRYPTO_API_STUB(acomp_walk_next_src);
+DEFINE_CRYPTO_API_STUB(acomp_walk_next_dst);
+DEFINE_CRYPTO_API_STUB(acomp_walk_virt);
+DEFINE_CRYPTO_API_STUB(acomp_request_clone);
+
+#endif
+
+/*
+ * crypto/scompress.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_ACOMP2)
+
+#include <crypto/internal/scompress.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_register_scomp);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_scomp);
+DEFINE_CRYPTO_API_STUB(crypto_register_scomps);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_scomps);
+
#endif
\ No newline at end of file
diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h
index 9eacb9fa375d..54545cd3f2f8 100644
--- a/include/crypto/acompress.h
+++ b/include/crypto/acompress.h
@@ -9,6 +9,7 @@
#ifndef _CRYPTO_ACOMP_H
#define _CRYPTO_ACOMP_H
+#include <crypto/api.h>
#include <linux/atomic.h>
#include <linux/args.h>
#include <linux/compiler_types.h>
@@ -143,8 +144,7 @@ struct comp_alg_common COMP_ALG_COMMON;
* Return: allocated handle in case of success; IS_ERR() is true in case
* of an error, PTR_ERR() returns the error code.
*/
-struct crypto_acomp *crypto_alloc_acomp(const char *alg_name, u32 type,
- u32 mask);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_alloc_acomp, struct crypto_acomp *, (const char *alg_name, u32 type, u32 mask), (alg_name, type, mask));
/**
* crypto_alloc_acomp_node() -- allocate ACOMPRESS tfm handle with desired NUMA node
* @alg_name: is the cra_name / name or cra_driver_name / driver name of the
@@ -161,8 +161,7 @@ struct crypto_acomp *crypto_alloc_acomp(const char *alg_name, u32 type,
* Return: allocated handle in case of success; IS_ERR() is true in case
* of an error, PTR_ERR() returns the error code.
*/
-struct crypto_acomp *crypto_alloc_acomp_node(const char *alg_name, u32 type,
- u32 mask, int node);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_alloc_acomp_node, struct crypto_acomp *, (const char *alg_name, u32 type, u32 mask, int node), (alg_name, type, mask, node));
static inline struct crypto_tfm *crypto_acomp_tfm(struct crypto_acomp *tfm)
{
@@ -529,7 +528,7 @@ static inline void acomp_request_set_dst_folio(struct acomp_req *req,
*
* Return: zero on success; error code in case of error
*/
-int crypto_acomp_compress(struct acomp_req *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_acomp_compress, int, (struct acomp_req *req), (req));
/**
* crypto_acomp_decompress() -- Invoke asynchronous decompress operation
@@ -540,7 +539,7 @@ int crypto_acomp_compress(struct acomp_req *req);
*
* Return: zero on success; error code in case of error
*/
-int crypto_acomp_decompress(struct acomp_req *req);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_acomp_decompress, int, (struct acomp_req *req), (req));
static inline struct acomp_req *acomp_request_on_stack_init(
char *buf, struct crypto_acomp *tfm)
@@ -551,7 +550,6 @@ static inline struct acomp_req *acomp_request_on_stack_init(
return req;
}
-struct acomp_req *acomp_request_clone(struct acomp_req *req,
- size_t total, gfp_t gfp);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_request_clone, struct acomp_req *, (struct acomp_req *req, size_t total, gfp_t gfp), (req, total, gfp));
#endif
diff --git a/include/crypto/internal/acompress.h b/include/crypto/internal/acompress.h
index 9a3f28baa804..20a9c4e96e0c 100644
--- a/include/crypto/internal/acompress.h
+++ b/include/crypto/internal/acompress.h
@@ -9,6 +9,7 @@
#ifndef _CRYPTO_ACOMP_INT_H
#define _CRYPTO_ACOMP_INT_H
+#include <crypto/api.h>
#include <crypto/acompress.h>
#include <crypto/algapi.h>
#include <crypto/scatterwalk.h>
@@ -130,7 +131,7 @@ static inline void acomp_request_complete(struct acomp_req *req,
*
* Return: zero on success; error code in case of error
*/
-int crypto_register_acomp(struct acomp_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_register_acomp, int, (struct acomp_alg *alg), (alg));
/**
* crypto_unregister_acomp() -- Unregister asynchronous compression algorithm
@@ -140,10 +141,10 @@ int crypto_register_acomp(struct acomp_alg *alg);
*
* @alg: algorithm definition
*/
-void crypto_unregister_acomp(struct acomp_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_unregister_acomp, void, (struct acomp_alg *alg), (alg));
-int crypto_register_acomps(struct acomp_alg *algs, int count);
-void crypto_unregister_acomps(struct acomp_alg *algs, int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_register_acomps, int, (struct acomp_alg *algs, int count), (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_unregister_acomps, void, (struct acomp_alg *algs, int count), (algs, count));
static inline bool acomp_request_issg(struct acomp_req *req)
{
@@ -188,12 +189,11 @@ static inline bool crypto_acomp_req_virt(struct crypto_acomp *tfm)
return crypto_tfm_req_virt(&tfm->base);
}
-void crypto_acomp_free_streams(struct crypto_acomp_streams *s);
-int crypto_acomp_alloc_streams(struct crypto_acomp_streams *s);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_acomp_free_streams, void, (struct crypto_acomp_streams *s), (s));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_acomp_alloc_streams, int, (struct crypto_acomp_streams *s), (s));
#define crypto_acomp_lock_stream_bh(...) __acquire_ret(_crypto_acomp_lock_stream_bh(__VA_ARGS__), &__ret->lock);
-struct crypto_acomp_stream *_crypto_acomp_lock_stream_bh(
- struct crypto_acomp_streams *s) __acquires_ret;
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, _crypto_acomp_lock_stream_bh, struct crypto_acomp_stream *, (struct crypto_acomp_streams *s), (s)) __acquires_ret;
static inline void crypto_acomp_unlock_stream_bh(
struct crypto_acomp_stream *stream) __releases(&stream->lock)
@@ -201,12 +201,11 @@ static inline void crypto_acomp_unlock_stream_bh(
spin_unlock_bh(&stream->lock);
}
-void acomp_walk_done_src(struct acomp_walk *walk, int used);
-void acomp_walk_done_dst(struct acomp_walk *walk, int used);
-int acomp_walk_next_src(struct acomp_walk *walk);
-int acomp_walk_next_dst(struct acomp_walk *walk);
-int acomp_walk_virt(struct acomp_walk *__restrict walk,
- struct acomp_req *__restrict req, bool atomic);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_walk_done_src, void, (struct acomp_walk *walk, int used), (walk, used));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_walk_done_dst, void, (struct acomp_walk *walk, int used), (walk, used));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_walk_next_src, int, (struct acomp_walk *walk), (walk));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_walk_next_dst, int, (struct acomp_walk *walk), (walk));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, acomp_walk_virt, int, (struct acomp_walk *walk, struct acomp_req *req, bool atomic), (walk, req, atomic));
static inline bool acomp_walk_more_src(const struct acomp_walk *walk, int cur)
{
diff --git a/include/crypto/internal/scompress.h b/include/crypto/internal/scompress.h
index 6a2c5f2e90f9..02226b300ea8 100644
--- a/include/crypto/internal/scompress.h
+++ b/include/crypto/internal/scompress.h
@@ -9,6 +9,7 @@
#ifndef _CRYPTO_SCOMP_INT_H
#define _CRYPTO_SCOMP_INT_H
+#include <crypto/api.h>
#include <crypto/internal/acompress.h>
struct crypto_scomp {
@@ -90,7 +91,7 @@ static inline int crypto_scomp_decompress(struct crypto_scomp *tfm,
*
* Return: zero on success; error code in case of error
*/
-int crypto_register_scomp(struct scomp_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_register_scomp, int, (struct scomp_alg *alg), (alg));
/**
* crypto_unregister_scomp() -- Unregister synchronous compression algorithm
@@ -100,9 +101,9 @@ int crypto_register_scomp(struct scomp_alg *alg);
*
* @alg: algorithm definition
*/
-void crypto_unregister_scomp(struct scomp_alg *alg);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_unregister_scomp, void, (struct scomp_alg *alg), (alg));
-int crypto_register_scomps(struct scomp_alg *algs, int count);
-void crypto_unregister_scomps(struct scomp_alg *algs, int count);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_register_scomps, int, (struct scomp_alg *algs, int count), (algs, count));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_ACOMP2, crypto_unregister_scomps, void, (struct scomp_alg *algs, int count), (algs, count));
#endif
--
2.47.3
^ permalink raw reply related
* [PATCH 012/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_RSA crypto
From: Jay Wang @ 2026-02-12 2:45 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_RSA-related crypto to convert them into pluggable
interface.
This patch is partially based on work by Vegard Nossum, with
modifications. Unlike the original, we do not include
DEFINE_CRYPTO_API since only one copy of the crypto symbols is
kept, either in the crypto module or in the main kernel, and we ensure
such wrapper do not have impact on crypto already chosen built as
module.
Co-developed-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jay Wang <wanjay@amazon.com>
---
crypto/Makefile | 2 +-
crypto/fips140/fips140-api.c | 12 ++++++++++++
crypto/rsa.c | 4 ++--
include/crypto/internal/rsa.h | 7 +++----
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/crypto/Makefile b/crypto/Makefile
index 21197857ad7d..3e12b556bfa7 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -52,7 +52,7 @@ rsa_generic-y += rsa.o
rsa_generic-y += rsa_helper.o
rsa_generic-y += rsa-pkcs1pad.o
rsa_generic-y += rsassa-pkcs1.o
-obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
+crypto-objs-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
$(obj)/ecdsasignature.asn1.o: $(obj)/ecdsasignature.asn1.c $(obj)/ecdsasignature.asn1.h
$(obj)/ecdsa-x962.o: $(obj)/ecdsasignature.asn1.h
diff --git a/crypto/fips140/fips140-api.c b/crypto/fips140/fips140-api.c
index 50603e7a8bb0..d10eded6b61e 100644
--- a/crypto/fips140/fips140-api.c
+++ b/crypto/fips140/fips140-api.c
@@ -303,4 +303,16 @@ DEFINE_CRYPTO_API_STUB(crypto_register_kpp);
DEFINE_CRYPTO_API_STUB(crypto_unregister_kpp);
DEFINE_CRYPTO_API_STUB(kpp_register_instance);
+#endif
+
+/*
+ * crypto/rsa_helper.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_RSA)
+
+#include <crypto/internal/rsa.h>
+
+DEFINE_CRYPTO_API_STUB(rsa_parse_pub_key);
+DEFINE_CRYPTO_API_STUB(rsa_parse_priv_key);
+
#endif
\ No newline at end of file
diff --git a/crypto/rsa.c b/crypto/rsa.c
index 6c7734083c98..44eef74ebad8 100644
--- a/crypto/rsa.c
+++ b/crypto/rsa.c
@@ -430,8 +430,8 @@ static void __exit rsa_exit(void)
crypto_unregister_akcipher(&rsa);
}
-module_init(rsa_init);
-module_exit(rsa_exit);
+crypto_module_init(rsa_init);
+crypto_module_exit(rsa_exit);
MODULE_ALIAS_CRYPTO("rsa");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("RSA generic algorithm");
diff --git a/include/crypto/internal/rsa.h b/include/crypto/internal/rsa.h
index 071a1951b992..3d8fe098eaae 100644
--- a/include/crypto/internal/rsa.h
+++ b/include/crypto/internal/rsa.h
@@ -7,6 +7,7 @@
*/
#ifndef _RSA_HELPER_
#define _RSA_HELPER_
+#include <crypto/api.h>
#include <linux/types.h>
#include <crypto/akcipher.h>
@@ -48,11 +49,9 @@ struct rsa_key {
size_t qinv_sz;
};
-int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key,
- unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RSA, rsa_parse_pub_key, int, (struct rsa_key *rsa_key, const void *key, unsigned int key_len), (rsa_key, key, key_len));
-int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
- unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_RSA, rsa_parse_priv_key, int, (struct rsa_key *rsa_key, const void *key, unsigned int key_len), (rsa_key, key, key_len));
#define RSA_PUB (true)
#define RSA_PRIV (false)
--
2.47.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox