openssl/providers/implementations/ciphers
Daniel Hu 15b7175f55 SM4 optimization for ARM by HW instruction
This patch implements the SM4 optimization for ARM processor,
using SM4 HW instruction, which is an optional feature of
crypto extension for aarch64 V8.

Tested on some modern ARM micro-architectures with SM4 support, the
performance uplift can be observed around 8X~40X over existing
C implementation in openssl. Algorithms that can be parallelized
(like CTR, ECB, CBC decryption) are on higher end, with algorithm
like CBC encryption on lower end (due to inter-block dependency)

Perf data on Yitian-710 2.75GHz hardware, before and after optimization:

Before:
  type      16 bytes     64 bytes    256 bytes    1024 bytes   8192 bytes  16384 bytes
  SM4-CTR  105787.80k   107837.87k   108380.84k   108462.08k   108549.46k   108554.92k
  SM4-ECB  111924.58k   118173.76k   119776.00k   120093.70k   120264.02k   120274.94k
  SM4-CBC  106428.09k   109190.98k   109674.33k   109774.51k   109827.41k   109827.41k

After (7.4x - 36.6x faster):
  type      16 bytes     64 bytes    256 bytes    1024 bytes   8192 bytes  16384 bytes
  SM4-CTR  781979.02k  2432994.28k  3437753.86k  3834177.88k  3963715.58k  3974556.33k
  SM4-ECB  937590.69k  2941689.02k  3945751.81k  4328655.87k  4459181.40k  4468692.31k
  SM4-CBC  890639.88k  1027746.58k  1050621.78k  1056696.66k  1058613.93k  1058701.31k

Signed-off-by: Daniel Hu <Daniel.Hu@arm.com>

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17455)
2022-01-18 11:52:14 +01:00
..
build.info providers: Add SM4 GCM implementation 2021-09-28 19:27:58 +10:00
cipher_aes_cbc_hmac_sha1_hw.c Update copyright year 2021-06-17 13:24:59 +01:00
cipher_aes_cbc_hmac_sha256_hw.c Update copyright year 2021-06-17 13:24:59 +01:00
cipher_aes_cbc_hmac_sha.c Move libssl related defines used by fips provider to prov_ssl.h 2021-06-04 17:06:47 +02:00
cipher_aes_cbc_hmac_sha.h
cipher_aes_ccm_hw_aesni.inc
cipher_aes_ccm_hw_s390x.inc
cipher_aes_ccm_hw_t4.inc
cipher_aes_ccm_hw.c
cipher_aes_ccm.c
cipher_aes_ccm.h
cipher_aes_cts.inc Refactor cipher aes_cts code so that it can be used by other 128bit ciphers 2021-08-18 08:38:40 +10:00
cipher_aes_gcm_hw_aesni.inc
cipher_aes_gcm_hw_armv8.inc Fix typos 2022-01-05 12:37:20 +01:00
cipher_aes_gcm_hw_s390x.inc Update copyright year 2021-06-17 13:24:59 +01:00
cipher_aes_gcm_hw_t4.inc
cipher_aes_gcm_hw.c aes: rename new bsaes_ symbols -> ossl_bsaes_ ones 2021-05-27 09:35:50 +10:00
cipher_aes_gcm.c Remove lower limit on GCM mode ciphers 2021-07-14 12:02:03 +02:00
cipher_aes_gcm.h Update copyright year 2021-06-17 13:24:59 +01:00
cipher_aes_hw_aesni.inc
cipher_aes_hw_s390x.inc Fix CipherInit on s390x. 2021-06-08 14:32:44 +10:00
cipher_aes_hw_t4.inc
cipher_aes_hw.c aes: rename new bsaes_ symbols -> ossl_bsaes_ ones 2021-05-27 09:35:50 +10:00
cipher_aes_ocb_hw.c
cipher_aes_ocb.c support params argument to AES cipher init calls 2021-03-12 08:27:21 +10:00
cipher_aes_ocb.h
cipher_aes_siv_hw.c Update copyright year 2021-04-08 13:04:41 +01:00
cipher_aes_siv.c Fix incorrect OSSL_CIPHER_PARAM_SPEED get_ctx_params 2021-05-28 14:29:13 +02:00
cipher_aes_siv.h
cipher_aes_wrp.c aes-wrap: improve error handling 2021-08-26 09:33:52 +10:00
cipher_aes_xts_fips.c Update copyright year 2021-04-08 13:04:41 +01:00
cipher_aes_xts_hw.c Update copyright year 2021-06-17 13:24:59 +01:00
cipher_aes_xts.c Add ossl_provider symbols 2021-03-18 17:52:38 +10:00
cipher_aes_xts.h Update copyright year 2021-04-08 13:04:41 +01:00
cipher_aes.c
cipher_aes.h
cipher_aria_ccm_hw.c Add ossl_aria symbols 2021-03-18 17:52:37 +10:00
cipher_aria_ccm.c
cipher_aria_ccm.h
cipher_aria_gcm_hw.c Add ossl_aria symbols 2021-03-18 17:52:37 +10:00
cipher_aria_gcm.c Remove lower limit on GCM mode ciphers 2021-07-14 12:02:03 +02:00
cipher_aria_gcm.h
cipher_aria_hw.c Add ossl_aria symbols 2021-03-18 17:52:37 +10:00
cipher_aria.c
cipher_aria.h
cipher_blowfish_hw.c
cipher_blowfish.c
cipher_blowfish.h
cipher_camellia_cts.inc Add support for camellia cbc cts mode 2021-08-18 08:38:40 +10:00
cipher_camellia_hw_t4.inc
cipher_camellia_hw.c
cipher_camellia.c Update copyright year 2021-09-07 13:35:43 +02:00
cipher_camellia.h Update copyright year 2021-06-17 13:24:59 +01:00
cipher_cast5_hw.c
cipher_cast5.c
cipher_cast.h
cipher_chacha20_hw.c
cipher_chacha20_poly1305_hw.c prov: support params argument to CHACHA20 ciphers 2021-03-12 08:27:21 +10:00
cipher_chacha20_poly1305.c prov: support params argument to CHACHA20 ciphers 2021-03-12 08:27:21 +10:00
cipher_chacha20_poly1305.h
cipher_chacha20.c fix some code with obvious wrong coding style 2021-10-28 13:10:46 +10:00
cipher_chacha20.h
cipher_cts.c Fix CTS cipher decrypt so that the updated IV is returned correctly. 2021-08-18 08:38:40 +10:00
cipher_cts.h Refactor cipher aes_cts code so that it can be used by other 128bit ciphers 2021-08-18 08:38:40 +10:00
cipher_des_hw.c
cipher_des.c Add a gettable for provider ciphers to return the EVP_CIPH_RAND_KEY flag 2021-06-08 15:16:06 +10:00
cipher_des.h
cipher_desx_hw.c
cipher_desx.c
cipher_idea_hw.c
cipher_idea.c
cipher_idea.h
cipher_null.c prov: support param argument to null cipher init calls 2021-03-12 08:27:21 +10:00
cipher_rc2_hw.c
cipher_rc2.c Fixes #15070. Allow custom algorithm ID ASN.1 encoding for provided ciphers 2021-05-07 11:00:54 +02:00
cipher_rc2.h
cipher_rc4_hmac_md5_hw.c
cipher_rc4_hmac_md5.c
cipher_rc4_hmac_md5.h
cipher_rc4_hw.c
cipher_rc4.c
cipher_rc4.h
cipher_rc5_hw.c
cipher_rc5.c
cipher_rc5.h
cipher_seed_hw.c
cipher_seed.c
cipher_seed.h
cipher_sm4_ccm_hw.c providers: Add SM4 GCM implementation 2021-09-28 19:27:58 +10:00
cipher_sm4_ccm.c providers: Add SM4 GCM implementation 2021-09-28 19:27:58 +10:00
cipher_sm4_ccm.h providers: Add SM4 GCM implementation 2021-09-28 19:27:58 +10:00
cipher_sm4_gcm_hw.c SM4 optimization for ARM by HW instruction 2022-01-18 11:52:14 +01:00
cipher_sm4_gcm.c providers: Add SM4 GCM implementation 2021-09-28 19:27:58 +10:00
cipher_sm4_gcm.h providers: Add SM4 GCM implementation 2021-09-28 19:27:58 +10:00
cipher_sm4_hw.c SM4 optimization for ARM by HW instruction 2022-01-18 11:52:14 +01:00
cipher_sm4.c
cipher_sm4.h SM4 optimization for ARM by HW instruction 2022-01-18 11:52:14 +01:00
cipher_tdes_common.c prov: add zero strenght arguments to BN and RAND RNG calls 2021-05-29 17:17:12 +10:00
cipher_tdes_default_hw.c
cipher_tdes_default.c
cipher_tdes_default.h
cipher_tdes_hw.c
cipher_tdes_wrap_hw.c
cipher_tdes_wrap.c Add a gettable for provider ciphers to return the EVP_CIPH_RAND_KEY flag 2021-06-08 15:16:06 +10:00
cipher_tdes.c
cipher_tdes.h Add a gettable for provider ciphers to return the EVP_CIPH_RAND_KEY flag 2021-06-08 15:16:06 +10:00
ciphercommon_block.c fix some code with obvious wrong coding style 2021-10-28 13:10:46 +10:00
ciphercommon_ccm_hw.c
ciphercommon_ccm.c prov: support params argument to common cipher init calls 2021-03-12 08:27:21 +10:00
ciphercommon_gcm_hw.c
ciphercommon_gcm.c Remove lower limit on GCM mode ciphers 2021-07-14 12:02:03 +02:00
ciphercommon_hw.c Fix param indentation in ciphercommon_hw.c 2021-06-01 15:22:30 +10:00
ciphercommon_local.h
ciphercommon.c Add a gettable for provider ciphers to return the EVP_CIPH_RAND_KEY flag 2021-06-08 15:16:06 +10:00