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>
This commit is contained in:
parent
d2825fa936
commit
73c919d314
10
crypto/sm4.c
10
crypto/sm4.c
|
@ -11,7 +11,7 @@
|
||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
#include <crypto/sm4.h>
|
#include <crypto/sm4.h>
|
||||||
|
|
||||||
static const u32 fk[4] = {
|
static const u32 ____cacheline_aligned fk[4] = {
|
||||||
0xa3b1bac6, 0x56aa3350, 0x677d9197, 0xb27022dc
|
0xa3b1bac6, 0x56aa3350, 0x677d9197, 0xb27022dc
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,6 +61,14 @@ static const u8 ____cacheline_aligned sbox[256] = {
|
||||||
0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48
|
0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const u32 crypto_sm4_fk[4] __alias(fk);
|
||||||
|
extern const u32 crypto_sm4_ck[32] __alias(ck);
|
||||||
|
extern const u8 crypto_sm4_sbox[256] __alias(sbox);
|
||||||
|
|
||||||
|
EXPORT_SYMBOL(crypto_sm4_fk);
|
||||||
|
EXPORT_SYMBOL(crypto_sm4_ck);
|
||||||
|
EXPORT_SYMBOL(crypto_sm4_sbox);
|
||||||
|
|
||||||
static inline u32 sm4_t_non_lin_sub(u32 x)
|
static inline u32 sm4_t_non_lin_sub(u32 x)
|
||||||
{
|
{
|
||||||
u32 out;
|
u32 out;
|
||||||
|
|
|
@ -21,6 +21,10 @@ struct sm4_ctx {
|
||||||
u32 rkey_dec[SM4_RKEY_WORDS];
|
u32 rkey_dec[SM4_RKEY_WORDS];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const u32 crypto_sm4_fk[];
|
||||||
|
extern const u32 crypto_sm4_ck[];
|
||||||
|
extern const u8 crypto_sm4_sbox[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sm4_expandkey - Expands the SM4 key as described in GB/T 32907-2016
|
* sm4_expandkey - Expands the SM4 key as described in GB/T 32907-2016
|
||||||
* @ctx: The location where the computed key will be stored.
|
* @ctx: The location where the computed key will be stored.
|
||||||
|
|
Loading…
Reference in New Issue