[PATCH RFC 068/104] crypto: fips140: convert crypto/sha3_generic.c to using crypto API wrappers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use CRYPTO_API() etc. from include/crypto/api.h in preparation for
compilation as part of support for FIPS 140 standalone modules.

Generated using:

  ./fipsify.py --config CONFIG_CRYPTO_SHA3 --source crypto/sha3_generic.c --header include/crypto/sha3.h

Signed-off-by: Vegard Nossum <vegard.nossum@xxxxxxxxxx>
---
 crypto/fips140-api.c  | 11 +++++++++++
 crypto/sha3_generic.c |  8 ++++----
 include/crypto/sha3.h |  5 ++++-
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/crypto/fips140-api.c b/crypto/fips140-api.c
index 47977f5b8554..2567c6d6622f 100644
--- a/crypto/fips140-api.c
+++ b/crypto/fips140-api.c
@@ -500,3 +500,14 @@ DEFINE_CRYPTO_API_STUB(rsa_parse_priv_key);
 
 #endif
 
+/*
+ * crypto/sha3_generic.c
+ */
+#if !IS_BUILTIN(CONFIG_CRYPTO_SHA3)
+
+#include <crypto/sha3.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_sha3_init);
+
+#endif
+
diff --git a/crypto/sha3_generic.c b/crypto/sha3_generic.c
index 41d1e506e6de..b04bd86d6d2f 100644
--- a/crypto/sha3_generic.c
+++ b/crypto/sha3_generic.c
@@ -158,14 +158,14 @@ static void keccakf(u64 st[25])
 	}
 }
 
-int crypto_sha3_init(struct shash_desc *desc)
+int CRYPTO_API(crypto_sha3_init)(struct shash_desc *desc)
 {
 	struct sha3_state *sctx = shash_desc_ctx(desc);
 
 	memset(sctx->st, 0, sizeof(sctx->st));
 	return 0;
 }
-EXPORT_SYMBOL(crypto_sha3_init);
+DEFINE_CRYPTO_API(crypto_sha3_init);
 
 static int crypto_sha3_update(struct shash_desc *desc, const u8 *data,
 			      unsigned int len)
@@ -274,8 +274,8 @@ static void __exit sha3_generic_mod_fini(void)
 	crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
 }
 
-module_init(sha3_generic_mod_init);
-module_exit(sha3_generic_mod_fini);
+crypto_module_init(sha3_generic_mod_init);
+crypto_module_exit(sha3_generic_mod_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("SHA-3 Secure Hash Algorithm");
diff --git a/include/crypto/sha3.h b/include/crypto/sha3.h
index 41e1b83a6d91..7ae0affff089 100644
--- a/include/crypto/sha3.h
+++ b/include/crypto/sha3.h
@@ -5,6 +5,7 @@
 #ifndef __CRYPTO_SHA3_H__
 #define __CRYPTO_SHA3_H__
 
+#include <crypto/api.h>
 #include <linux/types.h>
 
 #define SHA3_224_DIGEST_SIZE	(224 / 8)
@@ -31,6 +32,8 @@ struct sha3_state {
 	u64		st[SHA3_STATE_SIZE / 8];
 };
 
-int crypto_sha3_init(struct shash_desc *desc);
+DECLARE_CRYPTO_API(crypto_sha3_init, int,
+	(struct shash_desc *desc),
+	(desc));
 
 #endif
-- 
2.39.3





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux