Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: sm4 - export encrypt/decrypt routines to other drivers

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>

authored by

Ard Biesheuvel and committed by
Herbert Xu
8da02bf1 9bae5494

+9 -4
+6 -4
crypto/sm4_generic.c
··· 190 190 191 191 /* encrypt a block of text */ 192 192 193 - static void sm4_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) 193 + void crypto_sm4_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) 194 194 { 195 195 const struct crypto_sm4_ctx *ctx = crypto_tfm_ctx(tfm); 196 196 197 197 sm4_do_crypt(ctx->rkey_enc, (u32 *)out, (u32 *)in); 198 198 } 199 + EXPORT_SYMBOL_GPL(crypto_sm4_encrypt); 199 200 200 201 /* decrypt a block of text */ 201 202 202 - static void sm4_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) 203 + void crypto_sm4_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) 203 204 { 204 205 const struct crypto_sm4_ctx *ctx = crypto_tfm_ctx(tfm); 205 206 206 207 sm4_do_crypt(ctx->rkey_dec, (u32 *)out, (u32 *)in); 207 208 } 209 + EXPORT_SYMBOL_GPL(crypto_sm4_decrypt); 208 210 209 211 static struct crypto_alg sm4_alg = { 210 212 .cra_name = "sm4", ··· 221 219 .cia_min_keysize = SM4_KEY_SIZE, 222 220 .cia_max_keysize = SM4_KEY_SIZE, 223 221 .cia_setkey = crypto_sm4_set_key, 224 - .cia_encrypt = sm4_encrypt, 225 - .cia_decrypt = sm4_decrypt 222 + .cia_encrypt = crypto_sm4_encrypt, 223 + .cia_decrypt = crypto_sm4_decrypt 226 224 } 227 225 } 228 226 };
+3
include/crypto/sm4.h
··· 25 25 int crypto_sm4_expand_key(struct crypto_sm4_ctx *ctx, const u8 *in_key, 26 26 unsigned int key_len); 27 27 28 + void crypto_sm4_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in); 29 + void crypto_sm4_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in); 30 + 28 31 #endif