[PATCH RFC 030/104] crypto: fips140: convert crypto/aes_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_AES --source crypto/aes_generic.c --header include/crypto/aes.h

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

diff --git a/crypto/aes_generic.c b/crypto/aes_generic.c
index 85d2e78c8ef2..b3bf792f82f2 100644
--- a/crypto/aes_generic.c
+++ b/crypto/aes_generic.c
@@ -1133,14 +1133,14 @@ EXPORT_SYMBOL_GPL(crypto_it_tab);
  *
  * Return: 0 on success; -EINVAL on failure (only happens for bad key lengths)
  */
-int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
+int CRYPTO_API(crypto_aes_set_key)(struct crypto_tfm *tfm, const u8 *in_key,
 		unsigned int key_len)
 {
 	struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm);
 
 	return aes_expandkey(ctx, in_key, key_len);
 }
-EXPORT_SYMBOL_GPL(crypto_aes_set_key);
+DEFINE_CRYPTO_API(crypto_aes_set_key);
 
 /* encrypt a block of text */
 
@@ -1311,8 +1311,8 @@ static void __exit aes_fini(void)
 	crypto_unregister_alg(&aes_alg);
 }
 
-module_init(aes_init);
-module_exit(aes_fini);
+crypto_module_init(aes_init);
+crypto_module_exit(aes_fini);
 
 MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm");
 MODULE_LICENSE("Dual BSD/GPL");
diff --git a/crypto/fips140-api.c b/crypto/fips140-api.c
index 896b42fb4330..88858a1f9915 100644
--- a/crypto/fips140-api.c
+++ b/crypto/fips140-api.c
@@ -152,3 +152,14 @@ DEFINE_CRYPTO_API_STUB(aead_register_instance);
 
 #endif
 
+/*
+ * crypto/aes_generic.c
+ */
+#if !IS_BUILTIN(CONFIG_CRYPTO_AES)
+
+#include <crypto/aes.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_aes_set_key);
+
+#endif
+
diff --git a/include/crypto/aes.h b/include/crypto/aes.h
index a72621f552d8..6a732ea5ee1b 100644
--- a/include/crypto/aes.h
+++ b/include/crypto/aes.h
@@ -49,8 +49,9 @@ static inline int aes_check_keylen(unsigned int keylen)
 	return 0;
 }
 
-int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
-		unsigned int key_len);
+DECLARE_CRYPTO_API(crypto_aes_set_key, int,
+	(struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len),
+	(tfm, in_key, key_len));
 
 /**
  * aes_expandkey - Expands the AES key as described in FIPS-197
-- 
2.39.3





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