]> git.baikalelectronics.ru Git - kernel.git/commitdiff
crypto: sm4 - export encrypt/decrypt routines to other drivers
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 25 Apr 2018 12:20:45 +0000 (14:20 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 5 May 2018 06:52:51 +0000 (14:52 +0800)
In preparation of adding support for the SIMD based arm64 implementation
of arm64, which requires a fallback to non-SIMD code when invoked in
certain contexts, expose the generic SM4 encrypt and decrypt routines
to other drivers.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/sm4_generic.c
include/crypto/sm4.h

index f537a2766c55782fa0cae0bec404012d3c2f8f66..c18eebfd5edda1651d1c08a8c1e9da71e6e866d9 100644 (file)
@@ -190,21 +190,23 @@ static void sm4_do_crypt(const u32 *rk, u32 *out, const u32 *in)
 
 /* encrypt a block of text */
 
-static void sm4_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
+void crypto_sm4_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
 {
        const struct crypto_sm4_ctx *ctx = crypto_tfm_ctx(tfm);
 
        sm4_do_crypt(ctx->rkey_enc, (u32 *)out, (u32 *)in);
 }
+EXPORT_SYMBOL_GPL(crypto_sm4_encrypt);
 
 /* decrypt a block of text */
 
-static void sm4_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
+void crypto_sm4_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
 {
        const struct crypto_sm4_ctx *ctx = crypto_tfm_ctx(tfm);
 
        sm4_do_crypt(ctx->rkey_dec, (u32 *)out, (u32 *)in);
 }
+EXPORT_SYMBOL_GPL(crypto_sm4_decrypt);
 
 static struct crypto_alg sm4_alg = {
        .cra_name               =       "sm4",
@@ -219,8 +221,8 @@ static struct crypto_alg sm4_alg = {
                        .cia_min_keysize        =       SM4_KEY_SIZE,
                        .cia_max_keysize        =       SM4_KEY_SIZE,
                        .cia_setkey             =       crypto_sm4_set_key,
-                       .cia_encrypt            =       sm4_encrypt,
-                       .cia_decrypt            =       sm4_decrypt
+                       .cia_encrypt            =       crypto_sm4_encrypt,
+                       .cia_decrypt            =       crypto_sm4_decrypt
                }
        }
 };
index b64e64d20b288f4a245766ed3e6552d76296a41e..7afd730d16ffbbb8935b4136cb150cdd8d68eda4 100644 (file)
@@ -25,4 +25,7 @@ int crypto_sm4_set_key(struct crypto_tfm *tfm, const u8 *in_key,
 int crypto_sm4_expand_key(struct crypto_sm4_ctx *ctx, const u8 *in_key,
                          unsigned int key_len);
 
+void crypto_sm4_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in);
+void crypto_sm4_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in);
+
 #endif