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_AKCIPHER2 --source crypto/akcipher.c 
--header include/crypto/akcipher.h include/crypto/internal/akcipher.h

Signed-off-by: Vegard Nossum <[email protected]>
---
 crypto/akcipher.c                  | 28 ++++++++++++++--------------
 crypto/fips140-api.c               | 20 ++++++++++++++++++++
 include/crypto/akcipher.h          | 18 ++++++++++--------
 include/crypto/internal/akcipher.h | 21 ++++++++++++++-------
 4 files changed, 58 insertions(+), 29 deletions(-)

diff --git a/crypto/akcipher.c b/crypto/akcipher.c
index a36f50c83827..1cfc6c7bfbae 100644
--- a/crypto/akcipher.c
+++ b/crypto/akcipher.c
@@ -100,21 +100,21 @@ static const struct crypto_type crypto_akcipher_type = {
        .algsize = offsetof(struct akcipher_alg, base),
 };
 
-int crypto_grab_akcipher(struct crypto_akcipher_spawn *spawn,
+int CRYPTO_API(crypto_grab_akcipher)(struct crypto_akcipher_spawn *spawn,
                         struct crypto_instance *inst,
                         const char *name, u32 type, u32 mask)
 {
        spawn->base.frontend = &crypto_akcipher_type;
        return crypto_grab_spawn(&spawn->base, inst, name, type, mask);
 }
-EXPORT_SYMBOL_GPL(crypto_grab_akcipher);
+DEFINE_CRYPTO_API(crypto_grab_akcipher);
 
-struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type,
+struct crypto_akcipher *CRYPTO_API(crypto_alloc_akcipher)(const char 
*alg_name, u32 type,
                                              u32 mask)
 {
        return crypto_alloc_tfm(alg_name, &crypto_akcipher_type, type, mask);
 }
-EXPORT_SYMBOL_GPL(crypto_alloc_akcipher);
+DEFINE_CRYPTO_API(crypto_alloc_akcipher);
 
 static void akcipher_prepare_alg(struct akcipher_alg *alg)
 {
@@ -136,7 +136,7 @@ static int akcipher_default_set_key(struct crypto_akcipher 
*tfm,
        return -ENOSYS;
 }
 
-int crypto_register_akcipher(struct akcipher_alg *alg)
+int CRYPTO_API(crypto_register_akcipher)(struct akcipher_alg *alg)
 {
        struct crypto_alg *base = &alg->base;
 
@@ -150,15 +150,15 @@ int crypto_register_akcipher(struct akcipher_alg *alg)
        akcipher_prepare_alg(alg);
        return crypto_register_alg(base);
 }
-EXPORT_SYMBOL_GPL(crypto_register_akcipher);
+DEFINE_CRYPTO_API(crypto_register_akcipher);
 
-void crypto_unregister_akcipher(struct akcipher_alg *alg)
+void CRYPTO_API(crypto_unregister_akcipher)(struct akcipher_alg *alg)
 {
        crypto_unregister_alg(&alg->base);
 }
-EXPORT_SYMBOL_GPL(crypto_unregister_akcipher);
+DEFINE_CRYPTO_API(crypto_unregister_akcipher);
 
-int akcipher_register_instance(struct crypto_template *tmpl,
+int CRYPTO_API(akcipher_register_instance)(struct crypto_template *tmpl,
                               struct akcipher_instance *inst)
 {
        if (WARN_ON(!inst->free))
@@ -166,7 +166,7 @@ int akcipher_register_instance(struct crypto_template *tmpl,
        akcipher_prepare_alg(&inst->alg);
        return crypto_register_instance(tmpl, akcipher_crypto_instance(inst));
 }
-EXPORT_SYMBOL_GPL(akcipher_register_instance);
+DEFINE_CRYPTO_API(akcipher_register_instance);
 
 static int crypto_akcipher_sync_prep(struct crypto_akcipher_sync_data *data)
 {
@@ -215,7 +215,7 @@ static int crypto_akcipher_sync_post(struct 
crypto_akcipher_sync_data *data,
        return err;
 }
 
-int crypto_akcipher_sync_encrypt(struct crypto_akcipher *tfm,
+int CRYPTO_API(crypto_akcipher_sync_encrypt)(struct crypto_akcipher *tfm,
                                 const void *src, unsigned int slen,
                                 void *dst, unsigned int dlen)
 {
@@ -231,9 +231,9 @@ int crypto_akcipher_sync_encrypt(struct crypto_akcipher 
*tfm,
               crypto_akcipher_sync_post(&data,
                                         crypto_akcipher_encrypt(data.req));
 }
-EXPORT_SYMBOL_GPL(crypto_akcipher_sync_encrypt);
+DEFINE_CRYPTO_API(crypto_akcipher_sync_encrypt);
 
-int crypto_akcipher_sync_decrypt(struct crypto_akcipher *tfm,
+int CRYPTO_API(crypto_akcipher_sync_decrypt)(struct crypto_akcipher *tfm,
                                 const void *src, unsigned int slen,
                                 void *dst, unsigned int dlen)
 {
@@ -250,7 +250,7 @@ int crypto_akcipher_sync_decrypt(struct crypto_akcipher 
*tfm,
                                         crypto_akcipher_decrypt(data.req)) ?:
               data.dlen;
 }
-EXPORT_SYMBOL_GPL(crypto_akcipher_sync_decrypt);
+DEFINE_CRYPTO_API(crypto_akcipher_sync_decrypt);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Generic public key cipher type");
diff --git a/crypto/fips140-api.c b/crypto/fips140-api.c
index 530195c057eb..3c3445523803 100644
--- a/crypto/fips140-api.c
+++ b/crypto/fips140-api.c
@@ -203,3 +203,23 @@ DEFINE_CRYPTO_API_STUB(crypto_hash_digest);
 
 #endif
 
+/*
+ * crypto/akcipher.c
+ */
+#if !IS_BUILTIN(CONFIG_CRYPTO_AKCIPHER2)
+
+#include <crypto/akcipher.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_alloc_akcipher);
+DEFINE_CRYPTO_API_STUB(crypto_akcipher_sync_encrypt);
+DEFINE_CRYPTO_API_STUB(crypto_akcipher_sync_decrypt);
+
+#include <crypto/internal/akcipher.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_grab_akcipher);
+DEFINE_CRYPTO_API_STUB(crypto_register_akcipher);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_akcipher);
+DEFINE_CRYPTO_API_STUB(akcipher_register_instance);
+
+#endif
+
diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
index cdf7da74bf2f..d6ae05da0811 100644
--- a/include/crypto/akcipher.h
+++ b/include/crypto/akcipher.h
@@ -8,6 +8,7 @@
 #ifndef _CRYPTO_AKCIPHER_H
 #define _CRYPTO_AKCIPHER_H
 
+#include <crypto/api.h>
 #include <linux/atomic.h>
 #include <linux/crypto.h>
 
@@ -116,8 +117,9 @@ struct akcipher_alg {
  * Return: allocated handle in case of success; IS_ERR() is true in case
  *        of an error, PTR_ERR() returns the error code.
  */
-struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type,
-                                             u32 mask);
+DECLARE_CRYPTO_API(crypto_alloc_akcipher, struct crypto_akcipher *,
+       (const char *alg_name, u32 type, u32 mask),
+       (alg_name, type, mask));
 
 static inline struct crypto_tfm *crypto_akcipher_tfm(
        struct crypto_akcipher *tfm)
@@ -310,9 +312,9 @@ static inline int crypto_akcipher_decrypt(struct 
akcipher_request *req)
  *
  * Return: zero on success; error code in case of error
  */
-int crypto_akcipher_sync_encrypt(struct crypto_akcipher *tfm,
-                                const void *src, unsigned int slen,
-                                void *dst, unsigned int dlen);
+DECLARE_CRYPTO_API(crypto_akcipher_sync_encrypt, int,
+       (struct crypto_akcipher *tfm, const void *src, unsigned int slen, void 
*dst, unsigned int dlen),
+       (tfm, src, slen, dst, dlen));
 
 /**
  * crypto_akcipher_sync_decrypt() - Invoke public key decrypt operation
@@ -328,9 +330,9 @@ int crypto_akcipher_sync_encrypt(struct crypto_akcipher 
*tfm,
  *
  * Return: Output length on success; error code in case of error
  */
-int crypto_akcipher_sync_decrypt(struct crypto_akcipher *tfm,
-                                const void *src, unsigned int slen,
-                                void *dst, unsigned int dlen);
+DECLARE_CRYPTO_API(crypto_akcipher_sync_decrypt, int,
+       (struct crypto_akcipher *tfm, const void *src, unsigned int slen, void 
*dst, unsigned int dlen),
+       (tfm, src, slen, dst, dlen));
 
 /**
  * crypto_akcipher_set_pub_key() - Invoke set public key operation
diff --git a/include/crypto/internal/akcipher.h 
b/include/crypto/internal/akcipher.h
index 14ee62bc52b6..5ea9c6cbce04 100644
--- a/include/crypto/internal/akcipher.h
+++ b/include/crypto/internal/akcipher.h
@@ -7,6 +7,8 @@
  */
 #ifndef _CRYPTO_AKCIPHER_INT_H
 #define _CRYPTO_AKCIPHER_INT_H
+
+#include <crypto/api.h>
 #include <crypto/akcipher.h>
 #include <crypto/algapi.h>
 
@@ -100,9 +102,9 @@ static inline void *akcipher_instance_ctx(struct 
akcipher_instance *inst)
        return crypto_instance_ctx(akcipher_crypto_instance(inst));
 }
 
-int crypto_grab_akcipher(struct crypto_akcipher_spawn *spawn,
-                        struct crypto_instance *inst,
-                        const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(crypto_grab_akcipher, int,
+       (struct crypto_akcipher_spawn *spawn, struct crypto_instance *inst, 
const char *name, u32 type, u32 mask),
+       (spawn, inst, name, type, mask));
 
 static inline struct crypto_akcipher *crypto_spawn_akcipher(
                struct crypto_akcipher_spawn *spawn)
@@ -130,7 +132,9 @@ static inline struct akcipher_alg 
*crypto_spawn_akcipher_alg(
  *
  * Return: zero on success; error code in case of error
  */
-int crypto_register_akcipher(struct akcipher_alg *alg);
+DECLARE_CRYPTO_API(crypto_register_akcipher, int,
+       (struct akcipher_alg *alg),
+       (alg));
 
 /**
  * crypto_unregister_akcipher() -- Unregister public key algorithm
@@ -139,7 +143,9 @@ int crypto_register_akcipher(struct akcipher_alg *alg);
  *
  * @alg:       algorithm definition
  */
-void crypto_unregister_akcipher(struct akcipher_alg *alg);
+DECLARE_CRYPTO_API(crypto_unregister_akcipher, void,
+       (struct akcipher_alg *alg),
+       (alg));
 
 /**
  * akcipher_register_instance() -- Unregister public key template instance
@@ -150,6 +156,7 @@ void crypto_unregister_akcipher(struct akcipher_alg *alg);
  * @tmpl:      the template from which the algorithm was created
  * @inst:      the template instance
  */
-int akcipher_register_instance(struct crypto_template *tmpl,
-               struct akcipher_instance *inst);
+DECLARE_CRYPTO_API(akcipher_register_instance, int,
+       (struct crypto_template *tmpl, struct akcipher_instance *inst),
+       (tmpl, inst));
 #endif
-- 
2.39.3


Reply via email to