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

crypto: sm4 - export sm4 constant arrays

Export the constant arrays fk, ck, sbox of the SM4 algorithm, and
add the 'crypto_sm4_' prefix, where sbox is used in the SM4 NEON
implementation for the tbl/tbx instruction to replace the S-BOX,
and the fk, ck arrays are used in the SM4 CE implementation. Use
the sm4ekey instruction to speed up key expansion operations.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Tianjia Zhang and committed by
Herbert Xu
73c919d3 d2825fa9

+13 -1
+9 -1
crypto/sm4.c
··· 11 11 #include <asm/unaligned.h> 12 12 #include <crypto/sm4.h> 13 13 14 - static const u32 fk[4] = { 14 + static const u32 ____cacheline_aligned fk[4] = { 15 15 0xa3b1bac6, 0x56aa3350, 0x677d9197, 0xb27022dc 16 16 }; 17 17 ··· 60 60 0x18, 0xf0, 0x7d, 0xec, 0x3a, 0xdc, 0x4d, 0x20, 61 61 0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48 62 62 }; 63 + 64 + extern const u32 crypto_sm4_fk[4] __alias(fk); 65 + extern const u32 crypto_sm4_ck[32] __alias(ck); 66 + extern const u8 crypto_sm4_sbox[256] __alias(sbox); 67 + 68 + EXPORT_SYMBOL(crypto_sm4_fk); 69 + EXPORT_SYMBOL(crypto_sm4_ck); 70 + EXPORT_SYMBOL(crypto_sm4_sbox); 63 71 64 72 static inline u32 sm4_t_non_lin_sub(u32 x) 65 73 {
+4
include/crypto/sm4.h
··· 21 21 u32 rkey_dec[SM4_RKEY_WORDS]; 22 22 }; 23 23 24 + extern const u32 crypto_sm4_fk[]; 25 + extern const u32 crypto_sm4_ck[]; 26 + extern const u8 crypto_sm4_sbox[]; 27 + 24 28 /** 25 29 * sm4_expandkey - Expands the SM4 key as described in GB/T 32907-2016 26 30 * @ctx: The location where the computed key will be stored.