MT7628 AES硬件加密引擎测试

mt7628支持mtk_aes硬件加密引擎,在Padavan的3.4内核中使用/dev/crypto用户接口实现。Openssl的cryptodev可以使用该接口。

测试机型:HC5861B
首先测试纯软件计算:

HC5861B:/home/root # openssl version -a
OpenSSL 1.0.2q  20 Nov 2018
built on: reproducible build, date unspecified
platform: linux-mipsel
options:  bn(64,32) rc4(ptr,char) des(idx,cisc,2,long) blowfish(ptr) 
compiler: /opt/rt-n56u/toolchain-mipsel/toolchain-3.4.x/bin/mipsel-linux-uclibc-gcc -mips32r2 -march=mips32r2 -I. -I.. -I../include  -fPIC -DOPENSSL_PIC -Os -fomit-frame-pointer -pipe -DEMBED -I/opt/rt-n56u/trunk/stage/include -Dlinux -D__linux__ -Dunix -Wall -Wno-trigraphs -Wno-strict-aliasing -Wno-format-security -Wno-unused-but-set-variable -fno-tree-slsr -Wno-pointer-sign -ffunction-sections -fdata-sections -ffunction-sections -fdata-sections -I/opt/rt-n56u/trunk/stage/include -DOPENSSL_USE_IPV6=1 -DOPENSSL_SMALL_FOOTPRINT -DHAVE_CRYPTODEV -DOPENSSL_NO_ERR -O2 -fomit-frame-pointer -Wall -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DAES_ASM
OPENSSLDIR: "/etc/ssl"

HC5861B:/home/root # openssl speed -evp aes-256-ecb -elapsed
You have chosen to measure elapsed time instead of user CPU time.
Doing aes-256-ecb for 3s on 16 size blocks: 1160640 aes-256-ecb's in 3.00s
Doing aes-256-ecb for 3s on 64 size blocks: 309012 aes-256-ecb's in 3.00s
Doing aes-256-ecb for 3s on 256 size blocks: 79025 aes-256-ecb's in 3.00s
Doing aes-256-ecb for 3s on 1024 size blocks: 19839 aes-256-ecb's in 3.00s
Doing aes-256-ecb for 3s on 8192 size blocks: 2481 aes-256-ecb's in 3.00s
OpenSSL 1.0.2q  20 Nov 2018
built on: reproducible build, date unspecified
options:bn(64,32) rc4(ptr,char) des(idx,cisc,2,long) aes(partial) blowfish(ptr) 
compiler: /opt/rt-n56u/toolchain-mipsel/toolchain-3.4.x/bin/mipsel-linux-uclibc-gcc -mips32r2 -march=mips32r2 -I. -I.. -I../include  -fPIC -DOPENSSL_PIC -Os -fomit-frame-pointer -pipe -DEMBED -I/opt/rt-n56u/trunk/stage/include -Dlinux -D__linux__ -Dunix -Wall -Wno-trigraphs -Wno-strict-aliasing -Wno-format-security -Wno-unused-but-set-variable -fno-tree-slsr -Wno-pointer-sign -ffunction-sections -fdata-sections -ffunction-sections -fdata-sections -I/opt/rt-n56u/trunk/stage/include -DOPENSSL_USE_IPV6=1 -DOPENSSL_SMALL_FOOTPRINT -DHAVE_CRYPTODEV -DOPENSSL_NO_ERR -O2 -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
aes-256-ecb       6190.08k     6592.26k     6743.47k     6771.71k     6774.78k

HC5861B:/home/root # openssl speed -evp aes-256-cbc -elapsed
You have chosen to measure elapsed time instead of user CPU time.
Doing aes-256-cbc for 3s on 16 size blocks: 996344 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 64 size blocks: 271735 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 256 size blocks: 69520 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 1024 size blocks: 17379 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 8192 size blocks: 2188 aes-256-cbc's in 3.00s
OpenSSL 1.0.2q  20 Nov 2018
built on: reproducible build, date unspecified
options:bn(64,32) rc4(ptr,char) des(idx,cisc,2,long) aes(partial) blowfish(ptr) 
compiler: /opt/rt-n56u/toolchain-mipsel/toolchain-3.4.x/bin/mipsel-linux-uclibc-gcc -mips32r2 -march=mips32r2 -I. -I.. -I../include  -fPIC -DOPENSSL_PIC -Os -fomit-frame-pointer -pipe -DEMBED -I/opt/rt-n56u/trunk/stage/include -Dlinux -D__linux__ -Dunix -Wall -Wno-trigraphs -Wno-strict-aliasing -Wno-format-security -Wno-unused-but-set-variable -fno-tree-slsr -Wno-pointer-sign -ffunction-sections -fdata-sections -ffunction-sections -fdata-sections -I/opt/rt-n56u/trunk/stage/include -DOPENSSL_USE_IPV6=1 -DOPENSSL_SMALL_FOOTPRINT -DHAVE_CRYPTODEV -DOPENSSL_NO_ERR -O2 -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
aes-256-cbc       5313.83k     5797.01k     5932.37k     5932.03k     5974.70k

加载cryptodev模块并查看引擎信息:

HC5861B:/home/root # modprobe cryptodev
HC5861B:/home/root # openssl engine -c -t 
(cryptodev) BSD cryptodev engine
 [RSA, DSA, DH, AES-128-CBC, AES-192-CBC, AES-256-CBC, AES-128-ECB, AES-192-ECB, AES-256-ECB]
     [ available ]
(dynamic) Dynamic engine loading support
     [ unavailable ]

加载模块后再次测试:

HC5861B:/home/root # openssl speed -evp aes-256-ecb -engine cryptodev -elapsed
engine "cryptodev" set.
You have chosen to measure elapsed time instead of user CPU time.
Doing aes-256-ecb for 3s on 16 size blocks: 386312 aes-256-ecb's in 3.00s
Doing aes-256-ecb for 3s on 64 size blocks: 355617 aes-256-ecb's in 3.00s
Doing aes-256-ecb for 3s on 256 size blocks: 309646 aes-256-ecb's in 3.00s
Doing aes-256-ecb for 3s on 1024 size blocks: 197916 aes-256-ecb's in 3.00s
Doing aes-256-ecb for 3s on 8192 size blocks: 40173 aes-256-ecb's in 3.00s
OpenSSL 1.0.2q  20 Nov 2018
built on: reproducible build, date unspecified
options:bn(64,32) rc4(ptr,char) des(idx,cisc,2,long) aes(partial) blowfish(ptr) 
compiler: /opt/rt-n56u/toolchain-mipsel/toolchain-3.4.x/bin/mipsel-linux-uclibc-gcc -mips32r2 -march=mips32r2 -I. -I.. -I../include  -fPIC -DOPENSSL_PIC -Os -fomit-frame-pointer -pipe -DEMBED -I/opt/rt-n56u/trunk/stage/include -Dlinux -D__linux__ -Dunix -Wall -Wno-trigraphs -Wno-strict-aliasing -Wno-format-security -Wno-unused-but-set-variable -fno-tree-slsr -Wno-pointer-sign -ffunction-sections -fdata-sections -ffunction-sections -fdata-sections -I/opt/rt-n56u/trunk/stage/include -DOPENSSL_USE_IPV6=1 -DOPENSSL_SMALL_FOOTPRINT -DHAVE_CRYPTODEV -DOPENSSL_NO_ERR -O2 -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
aes-256-ecb       2060.33k     7586.50k    26423.13k    67555.33k   109699.07k

HC5861B:/home/root # openssl speed -evp aes-256-cbc -engine cryptodev -elapsed
engine "cryptodev" set.
You have chosen to measure elapsed time instead of user CPU time.
Doing aes-256-cbc for 3s on 16 size blocks: 376354 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 64 size blocks: 348704 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 256 size blocks: 305777 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 1024 size blocks: 194917 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 8192 size blocks: 39748 aes-256-cbc's in 3.00s
OpenSSL 1.0.2q  20 Nov 2018
built on: reproducible build, date unspecified
options:bn(64,32) rc4(ptr,char) des(idx,cisc,2,long) aes(partial) blowfish(ptr) 
compiler: /opt/rt-n56u/toolchain-mipsel/toolchain-3.4.x/bin/mipsel-linux-uclibc-gcc -mips32r2 -march=mips32r2 -I. -I.. -I../include  -fPIC -DOPENSSL_PIC -Os -fomit-frame-pointer -pipe -DEMBED -I/opt/rt-n56u/trunk/stage/include -Dlinux -D__linux__ -Dunix -Wall -Wno-trigraphs -Wno-strict-aliasing -Wno-format-security -Wno-unused-but-set-variable -fno-tree-slsr -Wno-pointer-sign -ffunction-sections -fdata-sections -ffunction-sections -fdata-sections -I/opt/rt-n56u/trunk/stage/include -DOPENSSL_USE_IPV6=1 -DOPENSSL_SMALL_FOOTPRINT -DHAVE_CRYPTODEV -DOPENSSL_NO_ERR -O2 -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
aes-256-cbc       2007.22k     7439.02k    26092.97k    66531.67k   108538.54k

可以看到在小block下,硬件计算的速度还不如软件计算,所以在Padavan中默认不会加载cryptodev模块。

你可能感兴趣的:(MT7628 AES硬件加密引擎测试)