openssl/crypto
zhangzhilei 13ba91cb02 SM4 optimization for non-asm mode
This patch use table-lookup borrow from aes in crypto/aes/aes_core.c.

Test on my PC(AMD Ryzen Threadripper 3990X 64-Core Processor),

before and after optimization:

debug mode:

Before:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
SM4-CBC          40101.14k    41453.80k    42073.86k    42174.81k    42216.11k    42227.03k
SM4-ECB          41222.60k    42074.88k    42673.66k    42868.05k    42896.04k    42844.16k
SM4-CTR          35867.22k    36874.47k    37004.97k    37083.82k    37052.42k    37076.99k

After:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
SM4-CBC          47273.51k    48957.40k    49665.19k    49810.77k    49859.24k    49834.67k
SM4-ECB          48100.01k    49323.34k    50224.04k    50273.28k    50533.72k    50730.12k
SM4-CTR          41352.64k    42621.29k    42971.22k    43061.59k    43089.92k    43100.84k

non-debug mode:

Before:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
SM4-CBC         141596.59k   145102.93k   146794.50k   146540.89k   146650.45k   146877.10k
SM4-ECB         144774.71k   155106.28k   158166.36k   158279.00k   158520.66k   159280.97k
SM4-CTR         138021.10k   141577.60k   142493.53k   142736.38k   142852.10k   143125.16k

After:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
SM4-CBC         142016.95k   150068.48k   152238.25k   152773.97k   153094.83k   152027.14k
SM4-ECB         148842.94k   159919.87k   163628.37k   164515.84k   164697.43k   164790.27k
SM4-CTR         141774.23k   146206.89k   147470.25k   147816.28k   146770.60k   148346.20k

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17766)
2022-03-03 13:19:55 +01:00
..
aes aes: make the no-asm constant time code path not the default 2022-01-31 11:39:00 +11:00
aria fix some code with obvious wrong coding style 2021-10-28 13:10:46 +10:00
asn1 Add tests for do_updatedb 2022-02-14 10:18:46 +01:00
async aarch64: Fix async_fibre_swapcontext() on clang BTI builds 2022-03-01 09:51:29 +11:00
bf
bio Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
bn Fix NULL pointer dereference for BN_mod_exp2_mont 2022-03-03 10:31:24 +01:00
buffer
camellia
cast
chacha chacha20 performance optimizations for ppc64le with 8x lanes, 2022-02-22 16:58:55 +11:00
cmac EVP_Cipher: fix the incomplete return check 2021-11-16 17:28:23 +01:00
cmp CMP: add subject of any provided CSR as default message sender 2022-02-22 12:01:57 +01:00
cms Fix malloc failure handling of X509_ALGOR_set0() 2022-01-14 18:47:20 +01:00
comp Fix coverity 1493364 & 1493375: unchecked return value 2021-11-08 08:55:32 +10:00
conf Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
crmf Fix the return check of OBJ_obj2txt 2021-11-22 11:17:48 +01:00
ct
des Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
dh Replace size check with more meaningful pubkey check 2022-02-07 16:32:40 +01:00
dsa Fix EVP todata and fromdata when used with selection of EVP_PKEY_PUBLIC_KEY. 2022-02-03 13:48:42 +01:00
dso Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
ec Apply the correct Apache v2 license 2022-02-14 10:08:21 +01:00
encode_decode fetch: convert a NULL property query to "" 2022-02-28 16:20:33 +11:00
engine Check for presence of 1.1.x openssl runtime 2022-02-08 13:26:13 +01:00
err Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
ess
evp fetch: convert a NULL property query to "" 2022-02-28 16:20:33 +11:00
ffc Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
hmac
http Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
idea
kdf
lhash lhash: Avoid 32 bit right shift of a 32 bit value 2022-01-27 10:36:57 +01:00
md2
md4
md5
mdc2
modes AES-GCM enabled with AVX512 vAES and vPCLMULQDQ. 2022-02-10 15:10:12 +01:00
objects Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
ocsp add OSSL_STACK_OF_X509_free() for commonly used pattern 2021-12-21 12:11:49 +01:00
pem Allow empty passphrase in PEM_write_bio_PKCS8PrivateKey_nid() 2022-01-26 17:15:52 +01:00
perlasm chacha20 performance optimizations for ppc64le with 8x lanes, 2022-02-22 16:58:55 +11:00
pkcs7 Fix malloc failure handling of X509_ALGOR_set0() 2022-01-14 18:47:20 +01:00
pkcs12 add OSSL_STACK_OF_X509_free() for commonly used pattern 2021-12-21 12:11:49 +01:00
poly1305 Don't use __ARMEL__/__ARMEB__ in aarch64 assembly 2022-01-09 07:40:44 +01:00
property fetch: convert a NULL property query to "" 2022-02-28 16:20:33 +11:00
rand rand: Add missing check for rand_get_global 2022-02-20 13:09:27 +01:00
rc2
rc4
rc5
ripemd
rsa rsa: add check after calling BN_BLINDING_lock 2022-02-08 15:22:35 +01:00
seed
sha Fix outdated comments 2022-02-10 13:52:17 +01:00
siphash
sm2 Add missing check according to SM2 Digital Signature generation algorithm 2021-11-02 12:02:56 +01:00
sm3 Fix sm3ss1 translation issue in sm3-armv8.pl 2022-01-20 12:50:20 +11:00
sm4 SM4 optimization for non-asm mode 2022-03-03 13:19:55 +01:00
srp fix some code with obvious wrong coding style 2021-10-28 13:10:46 +10:00
stack Fix Coverity 1493746: constant expression result 2021-11-17 08:15:35 +10:00
store fetch: convert a NULL property query to "" 2022-02-28 16:20:33 +11:00
ts Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
txt_db
ui Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
whrlpool
x509 crypto/x509/v3_utl.c: Add missing check for OPENSSL_strndup 2022-02-28 12:18:24 +01:00
alphacpuid.pl
arm64cpuid.pl aarch64: fix branch target indications in arm64cpuid.pl and keccak1600 2022-02-09 13:24:31 +11:00
arm_arch.h Optimize AES-GCM for uarchs with unroll and new instructions 2022-01-25 14:30:00 +11:00
armcap.c Optimize AES-GCM for uarchs with unroll and new instructions 2022-01-25 14:30:00 +11:00
armv4cpuid.pl
asn1_dsa.c
bsearch.c
build.info Statically link the legacy provider to endecode_test 2022-01-11 11:00:21 +00:00
c64xpluscpuid.pl
context.c Add missing CRYPTO_THREAD_cleanup_local of default_context_thread_local 2022-02-04 08:59:08 +01:00
core_algorithm.c CORE: add a provider argument to ossl_method_construct() 2021-10-27 12:41:10 +02:00
core_fetch.c CORE: Encure that cached fetches can be done per provider 2021-10-27 12:41:15 +02:00
core_namemap.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
cpt_err.c err: add additional errors 2022-01-12 20:10:21 +11:00
cpuid.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
cryptlib.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
ctype.c
cversion.c
der_writer.c
dllmain.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
ebcdic.c
ex_data.c
getenv.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
ia64cpuid.S
info.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
init.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
initthread.c Avoid a race in init_thread_stop() 2021-11-12 17:16:14 +00:00
LPdir_nyi.c
LPdir_unix.c fix some code with obvious wrong coding style 2021-10-28 13:10:46 +10:00
LPdir_vms.c
LPdir_win32.c
LPdir_win.c
LPdir_wince.c
mem_clr.c
mem_sec.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
mem.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
mips_arch.h
o_dir.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
o_fopen.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
o_init.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
o_str.c Change strlen' argument name to strlength' to avoid c++ reserved words. 2022-02-28 16:24:27 +11:00
o_time.c
packet.c
param_build_set.c param build set: add errors to failure returns 2022-01-12 20:10:21 +11:00
param_build.c Add support for signed BIGNUMs in the OSSL_PARAM_BLD API 2022-01-26 21:35:39 +01:00
params_dup.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
params_from_text.c Allow sign extension in OSSL_PARAM_allocate_from_text() 2021-11-24 19:18:19 +01:00
params.c Add support for signed BIGNUMs in the OSSL_PARAM API 2022-01-26 21:35:39 +01:00
pariscid.pl
passphrase.c Fix invalid malloc failures in PEM_write_bio_PKCS8PrivateKey() 2022-01-26 17:15:52 +01:00
ppccap.c chacha20 performance optimizations for ppc64le with 8x lanes, 2022-02-22 16:58:55 +11:00
ppccpuid.pl chacha20 performance optimizations for ppc64le with 8x lanes, 2022-02-22 16:58:55 +11:00
provider_child.c Stop receiving child callbacks in a child libctx when appropriate 2021-11-12 17:16:14 +00:00
provider_conf.c Refactor: a separate func for provider activation from config 2021-12-01 15:49:38 +01:00
provider_core.c ossl_provider_add_to_store: Avoid use-after-free 2021-12-17 17:33:49 +01:00
provider_local.h
provider_predefined.c
provider.c Correctly activate the provider in OSSL_PROVIDER_try_load 2021-11-12 17:16:14 +00:00
punycode.c Move more general parts of internal/cryptlib.h to new internal/common.h 2021-11-17 15:48:37 +01:00
README-sparse_array.md
s390x_arch.h
s390xcap.c
s390xcpuid.pl
self_test_core.c
sparccpuid.S
sparcv9cap.c
sparse_array.c
threads_lib.c
threads_none.c
threads_pthread.c
threads_win.c
trace.c Move e_os.h to include/internal 2022-02-05 05:31:09 +01:00
uid.c
vms_rms.h
x86_64cpuid.pl
x86cpuid.pl