[PATCH RFC 072/104] crypto: fips140: convert crypto/simd.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_SIMD --source crypto/simd.c --header include/crypto/internal/simd.h

Signed-off-by: Vegard Nossum <vegard.nossum@xxxxxxxxxx>
---
 crypto/fips140-api.c           | 16 ++++++++++++++++
 crypto/simd.c                  | 24 ++++++++++++------------
 include/crypto/internal/simd.h | 32 +++++++++++++++++++-------------
 3 files changed, 47 insertions(+), 25 deletions(-)

diff --git a/crypto/fips140-api.c b/crypto/fips140-api.c
index c4e66d008be2..112212b32d6d 100644
--- a/crypto/fips140-api.c
+++ b/crypto/fips140-api.c
@@ -562,3 +562,19 @@ DEFINE_CRYPTO_API_STUB(crypto_grab_sig);
 
 #endif
 
+/*
+ * crypto/simd.c
+ */
+#if !IS_BUILTIN(CONFIG_CRYPTO_SIMD)
+
+#include <crypto/internal/simd.h>
+
+DEFINE_CRYPTO_API_STUB(simd_skcipher_create_compat);
+DEFINE_CRYPTO_API_STUB(simd_skcipher_free);
+DEFINE_CRYPTO_API_STUB(simd_register_skciphers_compat);
+DEFINE_CRYPTO_API_STUB(simd_unregister_skciphers);
+DEFINE_CRYPTO_API_STUB(simd_register_aeads_compat);
+DEFINE_CRYPTO_API_STUB(simd_unregister_aeads);
+
+#endif
+
diff --git a/crypto/simd.c b/crypto/simd.c
index b07721d1f3f6..32e3eb04462c 100644
--- a/crypto/simd.c
+++ b/crypto/simd.c
@@ -136,7 +136,7 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
 	return 0;
 }
 
-struct simd_skcipher_alg *simd_skcipher_create_compat(struct skcipher_alg *ialg,
+struct simd_skcipher_alg *CRYPTO_API(simd_skcipher_create_compat)(struct skcipher_alg *ialg,
 						      const char *algname,
 						      const char *drvname,
 						      const char *basename)
@@ -195,16 +195,16 @@ struct simd_skcipher_alg *simd_skcipher_create_compat(struct skcipher_alg *ialg,
 	salg = ERR_PTR(err);
 	goto out;
 }
-EXPORT_SYMBOL_GPL(simd_skcipher_create_compat);
+DEFINE_CRYPTO_API(simd_skcipher_create_compat);
 
-void simd_skcipher_free(struct simd_skcipher_alg *salg)
+void CRYPTO_API(simd_skcipher_free)(struct simd_skcipher_alg *salg)
 {
 	crypto_unregister_skcipher(&salg->alg);
 	kfree(salg);
 }
-EXPORT_SYMBOL_GPL(simd_skcipher_free);
+DEFINE_CRYPTO_API(simd_skcipher_free);
 
-int simd_register_skciphers_compat(struct skcipher_alg *algs, int count,
+int CRYPTO_API(simd_register_skciphers_compat)(struct skcipher_alg *algs, int count,
 				   struct simd_skcipher_alg **simd_algs)
 {
 	int err;
@@ -236,9 +236,9 @@ int simd_register_skciphers_compat(struct skcipher_alg *algs, int count,
 	simd_unregister_skciphers(algs, count, simd_algs);
 	return err;
 }
-EXPORT_SYMBOL_GPL(simd_register_skciphers_compat);
+DEFINE_CRYPTO_API(simd_register_skciphers_compat);
 
-void simd_unregister_skciphers(struct skcipher_alg *algs, int count,
+void CRYPTO_API(simd_unregister_skciphers)(struct skcipher_alg *algs, int count,
 			       struct simd_skcipher_alg **simd_algs)
 {
 	int i;
@@ -252,7 +252,7 @@ void simd_unregister_skciphers(struct skcipher_alg *algs, int count,
 		}
 	}
 }
-EXPORT_SYMBOL_GPL(simd_unregister_skciphers);
+DEFINE_CRYPTO_API(simd_unregister_skciphers);
 
 /* AEAD support */
 
@@ -427,7 +427,7 @@ static void simd_aead_free(struct simd_aead_alg *salg)
 	kfree(salg);
 }
 
-int simd_register_aeads_compat(struct aead_alg *algs, int count,
+int CRYPTO_API(simd_register_aeads_compat)(struct aead_alg *algs, int count,
 			       struct simd_aead_alg **simd_algs)
 {
 	int err;
@@ -459,9 +459,9 @@ int simd_register_aeads_compat(struct aead_alg *algs, int count,
 	simd_unregister_aeads(algs, count, simd_algs);
 	return err;
 }
-EXPORT_SYMBOL_GPL(simd_register_aeads_compat);
+DEFINE_CRYPTO_API(simd_register_aeads_compat);
 
-void simd_unregister_aeads(struct aead_alg *algs, int count,
+void CRYPTO_API(simd_unregister_aeads)(struct aead_alg *algs, int count,
 			   struct simd_aead_alg **simd_algs)
 {
 	int i;
@@ -475,7 +475,7 @@ void simd_unregister_aeads(struct aead_alg *algs, int count,
 		}
 	}
 }
-EXPORT_SYMBOL_GPL(simd_unregister_aeads);
+DEFINE_CRYPTO_API(simd_unregister_aeads);
 
 MODULE_DESCRIPTION("Shared crypto SIMD helpers");
 MODULE_LICENSE("GPL");
diff --git a/include/crypto/internal/simd.h b/include/crypto/internal/simd.h
index 9e338e7aafbd..a1a419f7fd57 100644
--- a/include/crypto/internal/simd.h
+++ b/include/crypto/internal/simd.h
@@ -6,6 +6,7 @@
 #ifndef _CRYPTO_INTERNAL_SIMD_H
 #define _CRYPTO_INTERNAL_SIMD_H
 
+#include <crypto/api.h>
 #include <asm/simd.h>
 #include <linux/percpu.h>
 #include <linux/types.h>
@@ -15,28 +16,33 @@
 struct simd_skcipher_alg;
 struct skcipher_alg;
 
-struct simd_skcipher_alg *simd_skcipher_create_compat(struct skcipher_alg *ialg,
-						      const char *algname,
-						      const char *drvname,
-						      const char *basename);
-void simd_skcipher_free(struct simd_skcipher_alg *alg);
+DECLARE_CRYPTO_API(simd_skcipher_create_compat, struct simd_skcipher_alg *,
+	(struct skcipher_alg *ialg, const char *algname, const char *drvname, const char *basename),
+	(ialg, algname, drvname, basename));
+DECLARE_CRYPTO_API(simd_skcipher_free, void,
+	(struct simd_skcipher_alg *alg),
+	(alg));
 
-int simd_register_skciphers_compat(struct skcipher_alg *algs, int count,
-				   struct simd_skcipher_alg **simd_algs);
+DECLARE_CRYPTO_API(simd_register_skciphers_compat, int,
+	(struct skcipher_alg *algs, int count, struct simd_skcipher_alg **simd_algs),
+	(algs, count, simd_algs));
 
-void simd_unregister_skciphers(struct skcipher_alg *algs, int count,
-			       struct simd_skcipher_alg **simd_algs);
+DECLARE_CRYPTO_API(simd_unregister_skciphers, void,
+	(struct skcipher_alg *algs, int count, struct simd_skcipher_alg **simd_algs),
+	(algs, count, simd_algs));
 
 /* AEAD support */
 
 struct simd_aead_alg;
 struct aead_alg;
 
-int simd_register_aeads_compat(struct aead_alg *algs, int count,
-			       struct simd_aead_alg **simd_algs);
+DECLARE_CRYPTO_API(simd_register_aeads_compat, int,
+	(struct aead_alg *algs, int count, struct simd_aead_alg **simd_algs),
+	(algs, count, simd_algs));
 
-void simd_unregister_aeads(struct aead_alg *algs, int count,
-			   struct simd_aead_alg **simd_algs);
+DECLARE_CRYPTO_API(simd_unregister_aeads, void,
+	(struct aead_alg *algs, int count, struct simd_aead_alg **simd_algs),
+	(algs, count, simd_algs));
 
 /*
  * crypto_simd_usable() - is it allowed at this time to use SIMD instructions or
-- 
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