Home GnuPG

twofish: accelerate XTS and ECB modes

Description

twofish: accelerate XTS and ECB modes

* cipher/twofish-amd64.S (_gcry_twofish_amd64_blk3): New.
* cipher/twofish-avx2-amd64.S (_gcry_twofish_avx2_blk16): New.
(_gcry_twofish_xts_crypt, _gcry_twofish_ecb_crypt)
(_gcry_twofish_avx2_blk16, _gcry_twofish_amd64_blk3)
(twofish_crypt_blk1_16, twofish_encrypt_blk1_16)
(twofish_decrypt_blk1_16): New.
(twofish_setkey): Setup XTS and ECB bulk functions.

Benchmark on AMD Ryzen 9 7900X:

Before:
TWOFISH | nanosecs/byte mebibytes/sec cycles/byte auto Mhz

ECB enc |      2.52 ns/B     378.2 MiB/s     14.18 c/B      5625
ECB dec |      2.51 ns/B     380.2 MiB/s     14.11 c/B      5625
XTS enc |      2.65 ns/B     359.9 MiB/s     14.91 c/B      5625
XTS dec |      2.63 ns/B     362.0 MiB/s     14.60 c/B      5541

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

ECB enc |      1.60 ns/B     594.8 MiB/s      9.02 c/B      5625
ECB dec |      1.60 ns/B     594.8 MiB/s      9.02 c/B      5625
XTS enc |      1.66 ns/B     573.9 MiB/s      9.35 c/B      5625
XTS dec |      1.67 ns/B     569.6 MiB/s      9.41 c/B      5619±2
  • GnuPG-bug-id: T6242
  • Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>