[PATCH RFC 036/104] crypto: fips140: convert crypto/authenc.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_AUTHENC --source crypto/authenc.c --header include/crypto/authenc.h

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

diff --git a/crypto/authenc.c b/crypto/authenc.c
index a723769c8777..4fcb42a66e80 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -41,7 +41,7 @@ static void authenc_request_complete(struct aead_request *req, int err)
 		aead_request_complete(req, err);
 }
 
-int crypto_authenc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key,
+int CRYPTO_API(crypto_authenc_extractkeys)(struct crypto_authenc_keys *keys, const u8 *key,
 			       unsigned int keylen)
 {
 	struct rtattr *rta = (struct rtattr *)key;
@@ -77,7 +77,7 @@ int crypto_authenc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key,
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(crypto_authenc_extractkeys);
+DEFINE_CRYPTO_API(crypto_authenc_extractkeys);
 
 static int crypto_authenc_setkey(struct crypto_aead *authenc, const u8 *key,
 				 unsigned int keylen)
@@ -421,8 +421,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/fips140-api.c b/crypto/fips140-api.c
index f5cf473f1f25..df1dfcd5cf22 100644
--- a/crypto/fips140-api.c
+++ b/crypto/fips140-api.c
@@ -302,3 +302,14 @@ DEFINE_CRYPTO_API_STUB(crypto_destroy_alg);
 
 #endif
 
+/*
+ * crypto/authenc.c
+ */
+#if !IS_BUILTIN(CONFIG_CRYPTO_AUTHENC)
+
+#include <crypto/authenc.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_authenc_extractkeys);
+
+#endif
+
diff --git a/include/crypto/authenc.h b/include/crypto/authenc.h
index 15a9caa2354a..2f01a570e899 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(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.39.3





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux