Home GnuPG

rijndael: add ECB acceleration (for benchmarking purposes)

Description

rijndael: add ECB acceleration (for benchmarking purposes)

* cipher/cipher-internal.h (cipher_bulk_ops): Add 'ecb_crypt'.
* cipher/cipher.c (do_ecb_crypt): Use bulk function if available.
* cipher/rijndael-aesni.c (do_aesni_enc_vec8): Change asm label
'.Ldeclast' to '.Lenclast'.
(_gcry_aes_aesni_ecb_crypt): New.
* cipher/rijndael-armv8-aarch32-ce.S (_gcry_aes_ecb_enc_armv8_ce)
(_gcry_aes_ecb_dec_armv8_ce): New.
* cipher/rijndael-armv8-aarch64-ce.S (_gcry_aes_ecb_enc_armv8_ce)
(_gcry_aes_ecb_dec_armv8_ce): New.
* cipher/rijndael-armv8-ce.c (_gcry_aes_ocb_enc_armv8_ce)
(_gcry_aes_ocb_dec_armv8_ce, _gcry_aes_ocb_auth_armv8_ce): Change
return value from void to size_t.
(ocb_crypt_fn_t, xts_crypt_fn_t): Remove.
(_gcry_aes_armv8_ce_ocb_crypt, _gcry_aes_armv8_ce_xts_crypt): Remove
indirect function call; Return value from called function (allows tail
call optimization).
(_gcry_aes_armv8_ce_ocb_auth): Return value from called function (allows
tail call optimization).
(_gcry_aes_ecb_enc_armv8_ce, _gcry_aes_ecb_dec_armv8_ce)
(_gcry_aes_armv8_ce_ecb_crypt): New.
* cipher/rijndael-vaes-avx2-amd64.S
(_gcry_vaes_avx2_ecb_crypt_amd64): New.
* cipher/rijndael-vaes.c (_gcry_vaes_avx2_ecb_crypt_amd64)
(_gcry_aes_vaes_ecb_crypt): New.
* cipher/rijndael.c (_gcry_aes_aesni_ecb_crypt)
(_gcry_aes_vaes_ecb_crypt, _gcry_aes_armv8_ce_ecb_crypt): New.
(do_setkey): Setup ECB bulk function for x86 AESNI/VAES and ARM CE.

Benchmark on AMD Ryzen 9 7900X:

Before (OCB for reference):
AES | nanosecs/byte mebibytes/sec cycles/byte auto Mhz

ECB enc |     0.128 ns/B      7460 MiB/s     0.720 c/B      5634±1
ECB dec |     0.134 ns/B      7103 MiB/s     0.753 c/B      5608
OCB enc |     0.029 ns/B     32930 MiB/s     0.163 c/B      5625
OCB dec |     0.029 ns/B     32738 MiB/s     0.164 c/B      5625

After:
AES | nanosecs/byte mebibytes/sec cycles/byte auto Mhz

ECB enc |     0.028 ns/B     33761 MiB/s     0.159 c/B      5625
ECB dec |     0.028 ns/B     33917 MiB/s     0.158 c/B      5625
  • GnuPG-bug-id: T6242
  • Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>