public:the_performance_of_sha256_and_sha512_algorithms_as_implemented_by_openssl
The performance of SHA256 and SHA512 algorithms as implemented by OpenSSL
SHA256 and SHA512 are both cryptographic hash algorithms. They are used for detecting whether data had been modified. The digest size SHA256 and SHA512 are 256 bit and 512 bit respectively. SHA512 is more resistant to attacks compared to SHA256. However, interestingly enough, under x86-64 architecture, it is faster to compute SHA512 compared to SHA256. The reason is detailed in this paper.
Below are the performance metrics from some of the machines I have. If you are not on x86-64, it is faster to use SHA256.
$ uname -a; grep -m 1 'model name' /proc/cpuinfo; openssl speed -evp sha256 sha512 Linux smithsonian 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux model name : Intel(R) Core(TM) i7-4900MQ CPU @ 2.80GHz Doing sha512 for 3s on 16 size blocks: 9287059 sha512's in 3.00s Doing sha512 for 3s on 64 size blocks: 9403957 sha512's in 3.00s Doing sha512 for 3s on 256 size blocks: 4061733 sha512's in 3.00s Doing sha512 for 3s on 1024 size blocks: 1572993 sha512's in 3.00s Doing sha512 for 3s on 8192 size blocks: 232897 sha512's in 3.00s Doing sha512 for 3s on 16384 size blocks: 117928 sha512's in 3.00s Doing sha256 for 3s on 16 size blocks: 10277529 sha256's in 3.00s Doing sha256 for 3s on 64 size blocks: 6593538 sha256's in 3.00s Doing sha256 for 3s on 256 size blocks: 3487247 sha256's in 3.00s Doing sha256 for 3s on 1024 size blocks: 1177638 sha256's in 3.00s Doing sha256 for 3s on 8192 size blocks: 164907 sha256's in 3.00s Doing sha256 for 3s on 16384 size blocks: 79201 sha256's in 3.00s OpenSSL 1.1.1d 10 Sep 2019 built on: Mon Apr 20 20:23:01 2020 UTC options:bn(64,64) rc4(16x,int) des(int) aes(partial) blowfish(ptr) compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -fdebug-prefix-map=/build/openssl-8Ocme2/openssl-1.1.1d=. -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2 The 'numbers' are in 1000s of bytes per second processed. type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes sha256 54813.49k 140662.14k 297578.41k 401967.10k 450306.05k 432543.06k sha512 49530.98k 200617.75k 346601.22k 536914.94k 635964.07k 644044.12k
$ uname -a; grep -m 1 'model name' /proc/cpuinfo; openssl speed -evp sha256 sha512 Linux gabriel 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux model name : Intel(R) Atom(TM) CPU N2800 @ 1.86GHz Doing sha512 for 3s on 16 size blocks: 1802470 sha512's in 2.93s Doing sha512 for 3s on 64 size blocks: 1999076 sha512's in 2.96s Doing sha512 for 3s on 256 size blocks: 813357 sha512's in 2.97s Doing sha512 for 3s on 1024 size blocks: 294403 sha512's in 2.98s Doing sha512 for 3s on 8192 size blocks: 41516 sha512's in 2.97s Doing sha512 for 3s on 16384 size blocks: 21836 sha512's in 2.99s Doing sha256 for 3s on 16 size blocks: 1525305 sha256's in 2.96s Doing sha256 for 3s on 64 size blocks: 1117491 sha256's in 2.99s Doing sha256 for 3s on 256 size blocks: 608597 sha256's in 2.94s Doing sha256 for 3s on 1024 size blocks: 222215 sha256's in 2.90s Doing sha256 for 3s on 8192 size blocks: 32397 sha256's in 2.98s Doing sha256 for 3s on 16384 size blocks: 16463 sha256's in 2.98s OpenSSL 1.1.1d 10 Sep 2019 built on: Mon Apr 20 20:23:01 2020 UTC options:bn(64,64) rc4(16x,int) des(int) aes(partial) blowfish(ptr) compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -fdebug-prefix-map=/build/openssl-8Ocme2/openssl-1.1.1d=. -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2 The 'numbers' are in 1000s of bytes per second processed. type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes sha256 8244.89k 23919.54k 52993.48k 78464.88k 89059.14k 90513.35k sha512 9842.84k 43223.26k 70107.54k 101163.98k 114511.47k 119652.52k
$ uname -a; grep -m 1 'model name' /proc/cpuinfo; openssl speed -evp sha256 sha512 Linux hawkeye 5.4.51+ #1333 Mon Aug 10 16:38:02 BST 2020 armv6l GNU/Linux model name : ARMv6-compatible processor rev 7 (v6l) Doing sha512 for 3s on 16 size blocks: 122782 sha512's in 1.28s Doing sha512 for 3s on 64 size blocks: 141168 sha512's in 1.47s Doing sha512 for 3s on 256 size blocks: 50787 sha512's in 1.47s Doing sha512 for 3s on 1024 size blocks: 16403 sha512's in 1.41s Doing sha512 for 3s on 8192 size blocks: 2238 sha512's in 1.42s Doing sha512 for 3s on 16384 size blocks: 1148 sha512's in 1.43s Doing sha256 for 3s on 16 size blocks: 175136 sha256's in 1.46s Doing sha256 for 3s on 64 size blocks: 137710 sha256's in 1.41s Doing sha256 for 3s on 256 size blocks: 88038 sha256's in 1.48s Doing sha256 for 3s on 1024 size blocks: 28676 sha256's in 1.24s Doing sha256 for 3s on 8192 size blocks: 5448 sha256's in 1.60s Doing sha256 for 3s on 16384 size blocks: 2430 sha256's in 1.47s OpenSSL 1.1.1d 10 Sep 2019 built on: Mon Apr 27 09:55:40 2020 UTC options:bn(64,32) rc4(char) des(long) aes(partial) blowfish(ptr) compiler: gcc -fPIC -pthread -Wa,--noexecstack -Wall -D__ARM_MAX_ARCH__=7 -Wa,--noexecstack -g -O2 -fdebug-prefix-map=/home/pi/work/new=. -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2 The 'numbers' are in 1000s of bytes per second processed. type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes sha256 1919.30k 6250.67k 15228.19k 23680.83k 27893.76k 27083.76k sha512 1534.78k 6146.09k 8844.54k 11912.53k 12911.05k 13153.03k
# uname -a; grep -m 1 'model' /proc/cpuinfo; openssl speed -evp sha256 sha512 Linux windranger 4.9.120 #0 Thu Aug 16 07:51:15 2018 mips GNU/Linux cpu model : MIPS 74Kc V4.12 Doing sha512 for 3s on 16 size blocks: 115217 sha512's in 2.91s Doing sha512 for 3s on 64 size blocks: 114340 sha512's in 2.92s Doing sha512 for 3s on 256 size blocks: 39213 sha512's in 2.85s Doing sha512 for 3s on 1024 size blocks: 13437 sha512's in 2.92s Doing sha512 for 3s on 8192 size blocks: 1866 sha512's in 2.92s Doing sha256 for 3s on 16 size blocks: 343958 sha256's in 2.93s Doing sha256 for 3s on 64 size blocks: 236151 sha256's in 2.92s Doing sha256 for 3s on 256 size blocks: 120511 sha256's in 2.89s Doing sha256 for 3s on 1024 size blocks: 40789 sha256's in 2.88s Doing sha256 for 3s on 8192 size blocks: 5696 sha256's in 2.95s OpenSSL 1.0.2p 14 Aug 2018 built on: reproducible build, date unspecified options:bn(64,32) rc4(ptr,char) des(idx,cisc,2,long) aes(partial) blowfish(ptr) compiler: mips-openwrt-linux-musl-gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DZLIB_SHARED -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -I/build/openwrt-18.06/slaves/phase2/mips_24kc/build/sdk/staging_dir/target-mips_24kc_musl/usr/include -I/build/openwrt-18.06/slaves/phase2/mips_24kc/build/sdk/staging_dir/target-mips_24kc_musl/include -I/build/openwrt-18.06/slaves/phase2/mips_24kc/build/sdk/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/usr/include -I/build/openwrt-18.06/slaves/phase2/mips_24kc/build/sdk/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/include/fortify -I/build/openwrt-18.06/slaves/phase2/mips_24kc/build/sdk/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/include -znow -zrelro -DOPENSSL_SMALL_FOOTPRINT -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS -DOPENSSL_NO_ERR -DTERMIOS -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -iremap/build/openwrt-18.06/slaves/phase2/mips_24kc/build/sdk/build_dir/target-mips_24kc_musl/openssl-1.0.2p:openssl-1.0.2p -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -fpic -I/build/openwrt-18.06/slaves/phase2/mips_24kc/build/sdk/feeds/base/package/libs/openssl/include -ffunction-sections -fdata-sections -fomit-frame-pointer -Wall -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DAES_ASM The 'numbers' are in 1000s of bytes per second processed. type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes sha256 1878.27k 5175.91k 10675.02k 14502.76k 15817.50k sha512 633.50k 2506.08k 3522.29k 4712.15k 5235.02k
# uname -a; grep -m 1 'model' /proc/cpuinfo; openssl speed -evp sha256 sha512 Linux Aether 4.14.195 #0 SMP Sun Sep 6 16:19:39 2020 mips GNU/Linux cpu model : MIPS 34Kc V5.6 Doing sha512 for 3s on 16 size blocks: 88913 sha512's in 2.96s Doing sha512 for 3s on 64 size blocks: 90304 sha512's in 3.00s Doing sha512 for 3s on 256 size blocks: 31356 sha512's in 2.99s Doing sha512 for 3s on 1024 size blocks: 10574 sha512's in 2.99s Doing sha512 for 3s on 8192 size blocks: 1471 sha512's in 2.99s Doing sha512 for 3s on 16384 size blocks: 740 sha512's in 3.00s Doing sha256 for 3s on 16 size blocks: 152011 sha256's in 3.00s Doing sha256 for 3s on 64 size blocks: 128152 sha256's in 2.99s Doing sha256 for 3s on 256 size blocks: 76662 sha256's in 3.00s Doing sha256 for 3s on 1024 size blocks: 29636 sha256's in 2.99s Doing sha256 for 3s on 8192 size blocks: 4303 sha256's in 2.89s Doing sha256 for 3s on 16384 size blocks: 2125 sha256's in 2.81s OpenSSL 1.1.1g 21 Apr 2020 built on: Sat Sep 19 17:48:27 2020 UTC options:bn(64,32) rc4(char) des(long) aes(partial) blowfish(ptr) compiler: mips-openwrt-linux-musl-gcc -fPIC -pthread -mabi=32 -Wa,--noexecstack -Wall -O3 -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -fpic -ffunction-sections -fdata-sections -znow -zrelro -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DAES_ASM -DNDEBUG -DOPENSSL_PREFER_CHACHA_OVER_GCM -DOPENSSL_SMALL_FOOTPRINT The 'numbers' are in 1000s of bytes per second processed. type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes sha256 810.73k 2743.05k 6541.82k 10149.59k 12197.29k 12390.04k sha512 480.61k 1926.49k 2684.66k 3621.33k 4030.24k 4041.39k
public/the_performance_of_sha256_and_sha512_algorithms_as_implemented_by_openssl.txt · Last modified: 2020/09/23 10:36 by fangfufu