目前在AM62X平台发现opnessl使用硬件引擎devcrypto进行加密操作,比不使用硬件引擎加密时间更长、CPU使用率更高。
不使用硬件引擎,对aes-128-cbc算法进行测速测试,并使用该算法对一个200多M的文件加密测试,输出如下:
root@starcharge:/media/mmcblk0p1# time -v openssl speed -evp aes-128-cbc ... The 'numbers' are in 1000s of bytes per second processed. type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes AES-128-CBC 91351.90k 282958.93k 574506.89k 815835.14k 934024.99k 940124.84k Command being timed: "openssl speed -evp aes-128-cbc" User time (seconds): 17.98 System time (seconds): 0.01 Percent of CPU this job got: 99% Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 18.02s ... root@starcharge:/media/mmcblk0p1# time -v openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456 *** WARNING : deprecated key derivation used. Using -iter or -pbkdf2 would be better. Command being timed: "openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456" User time (seconds): 0.60 System time (seconds): 2.13 Percent of CPU this job got: 14% Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 19.50s root@starcharge:/media/mmcblk0p1# time -v openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456 *** WARNING : deprecated key derivation used. Using -iter or -pbkdf2 would be better. Command being timed: "openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456" User time (seconds): 0.49 System time (seconds): 2.23 Percent of CPU this job got: 13% Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 19.53s
使用硬件引擎,对aes-128-cbc算法进行测试,并使用该算法对一个200多M的文件加密,输出如下:
root@starcharge:/media/mmcblk0p1# time -v openssl speed -evp aes-128-cbc -engine devcrypto Engine "devcrypto" set. ... The 'numbers' are in 1000s of bytes per second processed. type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes AES-128-CBC 15280.00k 35717.33k 189169.78k 5755494.40k 8781004.80k 34666905.60k Command being timed: "openssl speed -evp aes-128-cbc -engine devcrypto" User time (seconds): 0.35 System time (seconds): 7.46 Percent of CPU this job got: 42% Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 18.38s ... root@starcharge:/media/mmcblk0p1# time -v openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456 -engine devcrypto Engine "devcrypto" set. *** WARNING : deprecated key derivation used. Using -iter or -pbkdf2 would be better. Command being timed: "openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456 -engine devcrypto" User time (seconds): 0.76 System time (seconds): 4.58 Percent of CPU this job got: 24% Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 21.78s ... root@starcharge:/media/mmcblk0p1# time -v openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456 -engine devcrypto Engine "devcrypto" set. *** WARNING : deprecated key derivation used. Using -iter or -pbkdf2 would be better. Command being timed: "openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456 -engine devcrypto" User time (seconds): 0.71 System time (seconds): 4.57 Percent of CPU this job got: 22% Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 23.10s
可以看出使用硬件引擎比不使用硬件引擎加密时间更长、CPU使用率更高。同步测试了使用sha256算法计算文件的散列值,也是一样的现象,请帮忙确定这是正常的吗?