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

Signed-off-by: Vegard Nossum <vegard.nos...@oracle.com>
---
 crypto/fips140-api.c          | 18 ++++++++++++++++++
 crypto/sig.c                  | 20 ++++++++++----------
 include/crypto/internal/sig.h | 20 +++++++++++++-------
 include/crypto/sig.h          |  5 ++++-
 4 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/crypto/fips140-api.c b/crypto/fips140-api.c
index eec551e120e2..c4e66d008be2 100644
--- a/crypto/fips140-api.c
+++ b/crypto/fips140-api.c
@@ -544,3 +544,21 @@ DEFINE_CRYPTO_API_STUB(crypto_shash_import_core);
 
 #endif
 
+/*
+ * crypto/sig.c
+ */
+#if !IS_BUILTIN(CONFIG_CRYPTO_SIG2)
+
+#include <crypto/sig.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_alloc_sig);
+
+#include <crypto/internal/sig.h>
+
+DEFINE_CRYPTO_API_STUB(crypto_register_sig);
+DEFINE_CRYPTO_API_STUB(crypto_unregister_sig);
+DEFINE_CRYPTO_API_STUB(sig_register_instance);
+DEFINE_CRYPTO_API_STUB(crypto_grab_sig);
+
+#endif
+
diff --git a/crypto/sig.c b/crypto/sig.c
index beba745b6405..c0217bd437f6 100644
--- a/crypto/sig.c
+++ b/crypto/sig.c
@@ -77,11 +77,11 @@ static const struct crypto_type crypto_sig_type = {
        .algsize = offsetof(struct sig_alg, base),
 };
 
-struct crypto_sig *crypto_alloc_sig(const char *alg_name, u32 type, u32 mask)
+struct crypto_sig *CRYPTO_API(crypto_alloc_sig)(const char *alg_name, u32 
type, u32 mask)
 {
        return crypto_alloc_tfm(alg_name, &crypto_sig_type, type, mask);
 }
-EXPORT_SYMBOL_GPL(crypto_alloc_sig);
+DEFINE_CRYPTO_API(crypto_alloc_sig);
 
 static int sig_default_sign(struct crypto_sig *tfm,
                            const void *src, unsigned int slen,
@@ -134,7 +134,7 @@ static int sig_prepare_alg(struct sig_alg *alg)
        return 0;
 }
 
-int crypto_register_sig(struct sig_alg *alg)
+int CRYPTO_API(crypto_register_sig)(struct sig_alg *alg)
 {
        struct crypto_alg *base = &alg->base;
        int err;
@@ -145,15 +145,15 @@ int crypto_register_sig(struct sig_alg *alg)
 
        return crypto_register_alg(base);
 }
-EXPORT_SYMBOL_GPL(crypto_register_sig);
+DEFINE_CRYPTO_API(crypto_register_sig);
 
-void crypto_unregister_sig(struct sig_alg *alg)
+void CRYPTO_API(crypto_unregister_sig)(struct sig_alg *alg)
 {
        crypto_unregister_alg(&alg->base);
 }
-EXPORT_SYMBOL_GPL(crypto_unregister_sig);
+DEFINE_CRYPTO_API(crypto_unregister_sig);
 
-int sig_register_instance(struct crypto_template *tmpl,
+int CRYPTO_API(sig_register_instance)(struct crypto_template *tmpl,
                          struct sig_instance *inst)
 {
        int err;
@@ -167,16 +167,16 @@ int sig_register_instance(struct crypto_template *tmpl,
 
        return crypto_register_instance(tmpl, sig_crypto_instance(inst));
 }
-EXPORT_SYMBOL_GPL(sig_register_instance);
+DEFINE_CRYPTO_API(sig_register_instance);
 
-int crypto_grab_sig(struct crypto_sig_spawn *spawn,
+int CRYPTO_API(crypto_grab_sig)(struct crypto_sig_spawn *spawn,
                    struct crypto_instance *inst,
                    const char *name, u32 type, u32 mask)
 {
        spawn->base.frontend = &crypto_sig_type;
        return crypto_grab_spawn(&spawn->base, inst, name, type, mask);
 }
-EXPORT_SYMBOL_GPL(crypto_grab_sig);
+DEFINE_CRYPTO_API(crypto_grab_sig);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Public Key Signature Algorithms");
diff --git a/include/crypto/internal/sig.h b/include/crypto/internal/sig.h
index b16648c1a986..8efee2dfba72 100644
--- a/include/crypto/internal/sig.h
+++ b/include/crypto/internal/sig.h
@@ -7,6 +7,7 @@
 #ifndef _CRYPTO_INTERNAL_SIG_H
 #define _CRYPTO_INTERNAL_SIG_H
 
+#include <crypto/api.h>
 #include <crypto/algapi.h>
 #include <crypto/sig.h>
 
@@ -39,7 +40,9 @@ static inline void *crypto_sig_ctx(struct crypto_sig *tfm)
  *
  * Return: zero on success; error code in case of error
  */
-int crypto_register_sig(struct sig_alg *alg);
+DECLARE_CRYPTO_API(crypto_register_sig, int,
+       (struct sig_alg *alg),
+       (alg));
 
 /**
  * crypto_unregister_sig() -- Unregister public key signature algorithm
@@ -48,10 +51,13 @@ int crypto_register_sig(struct sig_alg *alg);
  *
  * @alg:       algorithm definition
  */
-void crypto_unregister_sig(struct sig_alg *alg);
+DECLARE_CRYPTO_API(crypto_unregister_sig, void,
+       (struct sig_alg *alg),
+       (alg));
 
-int sig_register_instance(struct crypto_template *tmpl,
-                         struct sig_instance *inst);
+DECLARE_CRYPTO_API(sig_register_instance, int,
+       (struct crypto_template *tmpl, struct sig_instance *inst),
+       (tmpl, inst));
 
 static inline struct sig_instance *sig_instance(struct crypto_instance *inst)
 {
@@ -74,9 +80,9 @@ static inline void *sig_instance_ctx(struct sig_instance 
*inst)
        return crypto_instance_ctx(sig_crypto_instance(inst));
 }
 
-int crypto_grab_sig(struct crypto_sig_spawn *spawn,
-                   struct crypto_instance *inst,
-                   const char *name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(crypto_grab_sig, int,
+       (struct crypto_sig_spawn *spawn, struct crypto_instance *inst, const 
char *name, u32 type, u32 mask),
+       (spawn, inst, name, type, mask));
 
 static inline struct crypto_sig *crypto_spawn_sig(struct crypto_sig_spawn
                                                                   *spawn)
diff --git a/include/crypto/sig.h b/include/crypto/sig.h
index fa6dafafab3f..d6da8df9fd28 100644
--- a/include/crypto/sig.h
+++ b/include/crypto/sig.h
@@ -7,6 +7,7 @@
 #ifndef _CRYPTO_SIG_H
 #define _CRYPTO_SIG_H
 
+#include <crypto/api.h>
 #include <linux/crypto.h>
 
 /**
@@ -91,7 +92,9 @@ struct sig_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_sig *crypto_alloc_sig(const char *alg_name, u32 type, u32 mask);
+DECLARE_CRYPTO_API(crypto_alloc_sig, struct crypto_sig *,
+       (const char *alg_name, u32 type, u32 mask),
+       (alg_name, type, mask));
 
 static inline struct crypto_tfm *crypto_sig_tfm(struct crypto_sig *tfm)
 {
-- 
2.39.3


Reply via email to