openssl 的加密速度測試

 openssl測試方法

最近發現很多人都不知道openssl 自帶了一個評測加密速度的功能,就簡單寫一個方法。以此爲依照,也方便FPGA開發者作爲自己板子性能的基準對比。

openssl speed (加密算法)

AES 加密測試   不啓用intel 硬件加密

sh-3.2# openssl speed aes-256-ige
Doing aes-256 ige for 3s on 16 size blocks: 17498121 aes-256 ige's in 2.99s
Doing aes-256 ige for 3s on 64 size blocks: 4448218 aes-256 ige's in 3.00s
Doing aes-256 ige for 3s on 256 size blocks: 1126024 aes-256 ige's in 2.99s
Doing aes-256 ige for 3s on 1024 size blocks: 268594 aes-256 ige's in 2.97s
Doing aes-256 ige for 3s on 8192 size blocks: 32667 aes-256 ige's in 3.00s
OpenSSL 1.0.2h  3 May 2016
built on: reproducible build, date unspecified
options:bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) aes(partial) idea(int) blowfish(idx) 
compiler: /usr/bin/clang -I. -I.. -I../include  -fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS 
\-D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 
\-DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM 
\-DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
aes-256 ige      93635.43k    94895.32k    96408.74k    92606.15k    89202.69k

測試過程意義如下:

Doing aes-256 ige for 3s on 16 size blocks: 17498121 aes-256 ige's in 2.99s

1.  按字符串從 16 bytes 到 8192bytes ,5種長度字符串,每個大小數據塊處理跑3秒, 輸出處理的總次數。上文中16bytes,3秒內完成了17498121次

The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
aes-256 ige      93635.43k    94895.32k    96408.74k    92606.15k    89202.69k

2. 第三列中結果意義是, 每秒完成處理的數據量是多少KB ,比如8182bytes的數據塊 每秒處理能力是 89202.69kb,注意,這是的單位不是完成次數,而是數據塊大小。 the 'numbers' are in 1000s,不是指 1000秒內完成次數,而是指 數值以 1000爲單位進行縮寫,這是很多人容易搞錯的地方。


AES 加密測試   啓用intel 硬件加密


現在的aes  evp封裝後,會自動識別intel aes-ni硬件存在,如果有,將會啓用硬件加密。

sh-3.2# openssl speed -evp AES256
Doing aes-256-cbc for 3s on 16 size blocks: 82868413 aes-256-cbc's in 2.93s
Doing aes-256-cbc for 3s on 64 size blocks: 21822974 aes-256-cbc's in 2.95s
Doing aes-256-cbc for 3s on 256 size blocks: 6149541 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 1024 size blocks: 1484973 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 8192 size blocks: 176388 aes-256-cbc's in 2.99s
OpenSSL 1.0.2h  3 May 2016
built on: reproducible build, date unspecified
options:bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) aes(partial) idea(int) blowfish(idx) 
compiler: /usr/bin/clang -I. -I.. -I../include  -fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
aes-256-cbc     452523.76k   473447.57k   524760.83k   506870.78k   483267.72k

可以看到處理數據加密速度增加了。64bytes數據塊的數據流從  94895k 飆升473447k ,提升了5倍以上速度。

後面, 待續……



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章