<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[【DIY教程】D1 SDK可支持openssl对接CE硬件加解密模块]]></title><description><![CDATA[<p dir="auto">D1 SDK可支持openssl对接CE，验证方法如下：</p>
<p dir="auto">① tina/package加入补丁</p>
<pre><code>diff --git a/libs/openssl/Makefile b/libs/openssl/Makefile
index c755f8adf..dbb608fdf 100755
--- a/libs/openssl/Makefile
+++ b/libs/openssl/Makefile
@@ -137,7 +137,7 @@ define Package/libopenssl-afalg
   $(call Package/openssl/Default)
   SUBMENU:=SSL
   TITLE:=AFALG hardware acceleration engine
-  DEPENDS:=libopenssl @OPENSSL_ENGINE +@KERNEL_AIO @!LINUX_3_18 @LINUX_4_4||@LINUX_4_9
+  DEPENDS:=libopenssl @OPENSSL_ENGINE +@KERNEL_AIO @!LINUX_3_18 @LINUX_4_4||@LINUX_4_9||@LINUX_5_4
 endef

 define Package/libopenssl-padlock
@@ -210,7 +210,7 @@ ifdef CONFIG_OPENSSL_ENGINE
   ifndef CONFIG_PACKAGE_libopenssl-afalg
     OPENSSL_OPTIONS += no-afalgeng
   else
-    ifneq ($(CONFIG_PLATFORM_v5)$(CONFIG_PLATFORM_r328s2)$(CONFIG_PLATFORM_r328s3)$(CONFIG_PLATFORM_r18)$(CONFIG_PLATFORM_r329),)
+    ifneq ($(CONFIG_PLATFORM_v5)$(CONFIG_PLATFORM_r328s2)$(CONFIG_PLATFORM_r328s3)$(CONFIG_PLATFORM_r18)$(CONFIG_PLATFORM_r329)$(CONFIG_PLATFORM_r528)$(CONFIG_PLATFORM_d1),)
       OPENSSL_OPTIONS += -DSUPPORT_CE_V3_1
     else
       OPENSSL_OPTIONS += -DSUPPORT_CE_V3_2
</code></pre>
<p dir="auto">② tina配置，make menconfig</p>
<pre><code>Tina Configuration
    Libraries  ---&gt;
        SSL  ---&gt;
            -*- libopenssl........................... Open source SSL toolkit (libraries)  ---&gt;
[*]   Enable engine support
[*]     Support dynamic engine (NEW)
[*]   Support Zero-Copy mode to call kernel's algorithms
&lt;*&gt;   libopenssl-afalg...................... AFALG hardware acceleration engine
</code></pre>
<p dir="auto">说明： 可以将tina/lichee/linux-5.4/drivers/crypto/sunxi-ce/Makefile中的ccflags-y += -DDEBUG打开，这样每次调用CE时，就会产生debug打印。</p>
<p dir="auto">③ 内核配置 （参考显杨文档中的配置dts等），make kernel_menuconfig</p>
<pre><code>Linux/riscv 5.4.61 Kernel Configuration
[*] Networking support  ---&gt;
-*- Cryptographic API  ---&gt;
[*]   Disable run-time self tests
&lt;*&gt;   CBC support 
&lt;*&gt;   CFB support 
-*-   CTR support 
&lt;*&gt;   CTS support 
-*-   ECB support 
&lt;*&gt;   OFB support 
&lt;*&gt;   XTS support 
&lt;*&gt;   MD5 digest algorithm
&lt;*&gt;   SHA1 digest algorithm              
-*-   SHA224 and SHA256 digest algorithm 
&lt;*&gt;   SHA384 and SHA512 digest algorithms
-*-   AES cipher algorithms
&lt;*&gt;   User-space interface for hash algorithms                   
&lt;*&gt;   User-space interface for symmetric key cipher algorithms   
&lt;*&gt;   User-space interface for random number generator algorithms
&lt;*&gt;   User-space interface for AEAD cipher algorithms            
[*]   Hardware crypto devices  ---&gt;                              
&lt;*&gt;   Support for Allwinner Sunxi CryptoEngine
</code></pre>
<p dir="auto">④ 编译，将afalgtest程序adb push到设备上运行<br />
PC端： adb push tina/out/d1-nezha/compile_dir/target/openssl-1.1.0i/test/aflagtest /tmp/<br />
设备端： /tmp/aflagtest<br />
该测试程序会对当前已经对接好CE的算法（主要是AES与Hash）进行测试。</p>
<p dir="auto">大家可以参考tina/out/d1-nezha/compile_dir/target/openssl-1.1.0i/test/aflagtest.c进行编程即可使用CE加解密。</p>
]]></description><link>https://bbs.aw-ol.com/topic/321/diy教程-d1-sdk可支持openssl对接ce硬件加解密模块</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 05:06:26 GMT</lastBuildDate><atom:link href="https://bbs.aw-ol.com/topic/321.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 17 Aug 2021 06:34:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 【DIY教程】D1 SDK可支持openssl对接CE硬件加解密模块 on Fri, 31 Dec 2021 05:50:57 GMT]]></title><description><![CDATA[<p dir="auto">使用afalg小块性能非常拉胯，可能是受限于内核通信或硬件中断之类的吧。</p>
<pre><code>engine "afalg" set.
You have chosen to measure elapsed time instead of user CPU time.
Doing aes-128-cbc for 3s on 16 size blocks: 62569 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 64 size blocks: 57975 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 256 size blocks: 55735 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 1024 size blocks: 43987 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 8192 size blocks: 16572 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 16384 size blocks: 9685 aes-128-cbc's in 3.00s
OpenSSL 1.1.1m  14 Dec 2021
built on: Fri Dec 31 05:37:09 2021 UTC
options:bn(64,32) rc4(char) des(long) aes(partial) idea(int) blowfish(ptr) 
compiler: arm-linux-gnueabihf-gcc -fPIC -pthread -Wa,--noexecstack -Wall -O3 -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
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        333.70k     1236.80k     4756.05k    15014.23k    45252.61k    52893.01k
</code></pre>
<p dir="auto">不开afalg加速性能如下</p>
<pre><code>You have chosen to measure elapsed time instead of user CPU time.
Doing aes-128-cbc for 3s on 16 size blocks: 4299138 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 64 size blocks: 1332727 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 256 size blocks: 357553 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 1024 size blocks: 91071 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 8192 size blocks: 11447 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 16384 size blocks: 5724 aes-128-cbc's in 3.00s
OpenSSL 1.1.1m  14 Dec 2021
built on: Fri Dec 31 05:37:09 2021 UTC
options:bn(64,32) rc4(char) des(long) aes(partial) idea(int) blowfish(ptr) 
compiler: arm-linux-gnueabihf-gcc -fPIC -pthread -Wa,--noexecstack -Wall -O3 -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
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      22928.74k    28431.51k    30511.19k    31085.57k    31257.94k    31260.67k
</code></pre>
<p dir="auto">平台: R328-S3</p>
]]></description><link>https://bbs.aw-ol.com/post/3798</link><guid isPermaLink="true">https://bbs.aw-ol.com/post/3798</guid><dc:creator><![CDATA[mengxp]]></dc:creator><pubDate>Fri, 31 Dec 2021 05:50:57 GMT</pubDate></item></channel></rss>