[PATCH 017/106] crypto: convert exported crypto symbol into pluggable interface for CONFIG_CRYPTO_MD5 crypto
Jay Wang
wanjay at amazon.com
Wed Feb 11 18:45:53 PST 2026
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 at 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
More information about the linux-arm-kernel
mailing list