Apply Crypto API wrappers to the exported crypto symbol in
CONFIG_CRYPTO_CAMELLIA_X86_64-related crypto to convert them into pluggable
interface.

Signed-off-by: Jay Wang <[email protected]>
---
 arch/x86/crypto/Makefile              |  2 +-
 arch/x86/crypto/camellia.h            | 29 ++++++++++++++++++---------
 arch/x86/crypto/camellia_glue.c       |  4 ++--
 arch/x86/crypto/fips140/fips140-api.c | 16 +++++++++++++++
 4 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
index 7118a7dba3c6..8751154e1328 100644
--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -23,7 +23,7 @@ serpent-avx2-y := serpent-avx2-asm_64.o serpent_avx2_glue.o
 crypto-objs-$(CONFIG_CRYPTO_DES3_EDE_X86_64) += des3_ede-x86_64.o
 des3_ede-x86_64-y := des3_ede-asm_64.o des3_ede_glue.o
 
-obj-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o
+crypto-objs-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o
 camellia-x86_64-y := camellia-x86_64-asm_64.o camellia_glue.o
 obj-$(CONFIG_CRYPTO_CAMELLIA_AESNI_AVX_X86_64) += camellia-aesni-avx-x86_64.o
 camellia-aesni-avx-x86_64-y := camellia-aesni-avx-asm_64.o 
camellia_aesni_avx_glue.o
diff --git a/arch/x86/crypto/camellia.h b/arch/x86/crypto/camellia.h
index 1dcea79e8f8e..bca0b64ab8d7 100644
--- a/arch/x86/crypto/camellia.h
+++ b/arch/x86/crypto/camellia.h
@@ -2,6 +2,7 @@
 #ifndef ASM_X86_CAMELLIA_H
 #define ASM_X86_CAMELLIA_H
 
+#include <crypto/api.h>
 #include <crypto/b128ops.h>
 #include <linux/crypto.h>
 #include <linux/kernel.h>
@@ -19,19 +20,25 @@ struct camellia_ctx {
        u32 key_length;
 };
 
-extern int __camellia_setkey(struct camellia_ctx *cctx,
-                            const unsigned char *key,
-                            unsigned int key_len);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAMELLIA_X86_64, __camellia_setkey, int,
+       (struct camellia_ctx *cctx, const unsigned char *key, unsigned int 
key_len),
+       (cctx, key, key_len));
 
 /* regular block cipher functions */
-asmlinkage void __camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src,
-                                  bool xor);
-asmlinkage void camellia_dec_blk(const void *ctx, u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAMELLIA_X86_64, __camellia_enc_blk, 
asmlinkage void,
+       (const void *ctx, u8 *dst, const u8 *src, bool xor),
+       (ctx, dst, src, xor));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAMELLIA_X86_64, camellia_dec_blk, asmlinkage 
void,
+       (const void *ctx, u8 *dst, const u8 *src),
+       (ctx, dst, src));
 
 /* 2-way parallel cipher functions */
-asmlinkage void __camellia_enc_blk_2way(const void *ctx, u8 *dst, const u8 
*src,
-                                       bool xor);
-asmlinkage void camellia_dec_blk_2way(const void *ctx, u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAMELLIA_X86_64, __camellia_enc_blk_2way, 
asmlinkage void,
+       (const void *ctx, u8 *dst, const u8 *src, bool xor),
+       (ctx, dst, src, xor));
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAMELLIA_X86_64, camellia_dec_blk_2way, 
asmlinkage void,
+       (const void *ctx, u8 *dst, const u8 *src),
+       (ctx, dst, src));
 
 /* 16-way parallel cipher functions (avx/aes-ni) */
 asmlinkage void camellia_ecb_enc_16way(const void *ctx, u8 *dst, const u8 
*src);
@@ -62,6 +69,8 @@ static inline void camellia_enc_blk_xor_2way(const void *ctx, 
u8 *dst,
 }
 
 /* glue helpers */
-extern void camellia_decrypt_cbc_2way(const void *ctx, u8 *dst, const u8 *src);
+DECLARE_CRYPTO_API(CONFIG_CRYPTO_CAMELLIA_X86_64, camellia_decrypt_cbc_2way, 
void,
+       (const void *ctx, u8 *dst, const u8 *src),
+       (ctx, dst, src));
 
 #endif /* ASM_X86_CAMELLIA_H */
diff --git a/arch/x86/crypto/camellia_glue.c b/arch/x86/crypto/camellia_glue.c
index cbede120e5f2..e545da7c8530 100644
--- a/arch/x86/crypto/camellia_glue.c
+++ b/arch/x86/crypto/camellia_glue.c
@@ -1408,8 +1408,8 @@ static void __exit camellia_fini(void)
                                    ARRAY_SIZE(camellia_skcipher_algs));
 }
 
-module_init(camellia_init);
-module_exit(camellia_fini);
+crypto_module_init(camellia_init);
+crypto_module_exit(camellia_fini);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Camellia Cipher Algorithm, asm optimized");
diff --git a/arch/x86/crypto/fips140/fips140-api.c 
b/arch/x86/crypto/fips140/fips140-api.c
index 15a60258d4ee..57a1625219e0 100644
--- a/arch/x86/crypto/fips140/fips140-api.c
+++ b/arch/x86/crypto/fips140/fips140-api.c
@@ -34,4 +34,20 @@ DEFINE_CRYPTO_API_STUB(serpent_ecb_enc_8way_avx);
 DEFINE_CRYPTO_API_STUB(serpent_ecb_dec_8way_avx);
 DEFINE_CRYPTO_API_STUB(serpent_cbc_dec_8way_avx);
 
+#endif
+
+/*
+ * arch/x86/crypto/camellia_glue.c
+ */
+#if IS_BUILTIN(CONFIG_CRYPTO_CAMELLIA_X86_64)
+
+#include <arch/x86/crypto/camellia.h>
+
+DEFINE_CRYPTO_API_STUB(__camellia_setkey);
+DEFINE_CRYPTO_API_STUB(__camellia_enc_blk);
+DEFINE_CRYPTO_API_STUB(camellia_dec_blk);
+DEFINE_CRYPTO_API_STUB(__camellia_enc_blk_2way);
+DEFINE_CRYPTO_API_STUB(camellia_dec_blk_2way);
+DEFINE_CRYPTO_API_STUB(camellia_decrypt_cbc_2way);
+
 #endif
\ No newline at end of file
-- 
2.47.3


Reply via email to