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倍以上速度。
后面, 待续……