Add Intel SHA Extensions accelerated SHA1 implementation
authorJussi Kivilinna <jussi.kivilinna@iki.fi>
Tue, 13 Feb 2018 18:22:41 +0000 (20:22 +0200)
committerJussi Kivilinna <jussi.kivilinna@iki.fi>
Fri, 16 Feb 2018 17:28:10 +0000 (19:28 +0200)
commitd02958bd300d2c80bc92b1e072103e95e256b297
tree07dd0fc52f3b1bed068bced26647b4d8230229d1
parentda58a62ac1b7a8d97b0895dcb41d15af531e45e5
Add Intel SHA Extensions accelerated SHA1 implementation

* cipher/Makefile.am: Add 'sha1-intel-shaext.c'.
* cipher/sha1-intel-shaext.c: New.
* cipher/sha1.c (USE_SHAEXT, _gcry_sha1_transform_intel_shaext): New.
(sha1_init) [USE_SHAEXT]: Use shaext implementation is supported.
(transform) [USE_SHAEXT]: Use shaext if enabled.
(transform): Only add ASM_EXTRA_STACK if returned burn length is not
zero.
* cipher/sha1.h (SHA1_CONTEXT): Add 'use_shaext'.
* configure.ac: Add 'sha1-intel-shaext.lo'.
(shaextsupport, gcry_cv_gcc_inline_asm_shaext): New.
* src/g10lib.h: Add HWF_INTEL_SHAEXT and reorder HWF flags.
* src/hwf-x86.c (detect_x86_gnuc): Detect SHA Extensions.
* src/hwfeatures.c (hwflist): Add 'intel-shaext'.
--

Benchmark on Intel Celeron J3455 (1500 Mhz, no turbo):

Before:
                |  nanosecs/byte   mebibytes/sec   cycles/byte
 SHA1           |      4.50 ns/B     211.7 MiB/s      6.76 c/B

After (4.0x faster):
                |  nanosecs/byte   mebibytes/sec   cycles/byte
 SHA1           |      1.11 ns/B     858.1 MiB/s      1.67 c/B

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
cipher/Makefile.am
cipher/sha1-intel-shaext.c [new file with mode: 0644]
cipher/sha1.c
cipher/sha1.h
configure.ac
src/g10lib.h
src/hwf-x86.c
src/hwfeatures.c