Selaa lähdekoodia

1. Modify the component structure
2. Update Sconscript and README.md

chenyong 8 vuotta sitten
vanhempi
sitoutus
b5a67fd5a9

+ 8 - 1
README.md

@@ -18,7 +18,7 @@ mbedTLS(前称PolarSSL)是一个ARM公司授权的开源的SSL库,主要
 ### 3.1 获取示例
 
 menuconfig path:`RT-Thread online packages/security/mbedtls/Enable a client example`   
-配置获取示例选项,配置包版本选为最新版`latest_version`,示例代码位置`mbedtls/tls_app_test.c`
+配置获取示例选项,配置包版本选为最新版`latest_version`,示例代码位置`examples/tls_app_test.c`
 
 ![](./docs/image/mbedtls.jpg)
 
@@ -62,6 +62,13 @@ menuconfig path:`RT-Thread online packages/security/mbedtls/Enable a clie
 原因:测试其他TLS网站时,若输入域名不符合证书的Common Name(CN)出现CN验证失败问题   
 解决方法:检查输入域名和证书中CN是否匹配或输入IP地址
 
+### 4.4 IAR编译错误
+
+    Fatal Error "MBEDTLS_CONFIG_FILE" expected a file name 
+
+原因:SConscript中预定义语法IAR编辑器不支持  
+解决方法:删除SConscript中预定义语法(CPPDEFINES = ['MBEDTLS_CONFIG_FILE=\\"tls_config.h\\"']),拷贝`mbedtls-port/inc/tls_config.h`内容到`mbedtls/include/mbedtls/config.h`中
+
 ## 5、参考资料
 
 - mbedTLS官方网站:https://tls.mbed.org/

+ 6 - 81
SConscript

@@ -2,94 +2,19 @@ from building import *
 Import('RTT_ROOT')
 
 cwd = GetCurrentDir()
-src = Split('''
-mbedtls/library/havege.c
-mbedtls/library/ssl_cookie.c
-mbedtls/library/md5.c
-mbedtls/library/certs.c
-mbedtls/library/ssl_ciphersuites.c
-mbedtls/library/camellia.c
-mbedtls/library/threading.c
-mbedtls/library/aesni.c
-mbedtls/library/bignum.c
-mbedtls/library/arc4.c
-mbedtls/library/cipher_wrap.c
-mbedtls/library/aes.c
-mbedtls/library/xtea.c
-mbedtls/library/base64.c
-mbedtls/library/sha512.c
-mbedtls/library/pkcs11.c
-mbedtls/library/asn1write.c
-mbedtls/library/oid.c
-mbedtls/library/ecjpake.c
-mbedtls/library/ssl_tls.c
-mbedtls/library/debug.c
-mbedtls/library/ecdh.c
-mbedtls/library/ssl_srv.c
-mbedtls/library/ecdsa.c
-mbedtls/library/md2.c
-mbedtls/library/memory_buffer_alloc.c
-mbedtls/library/gcm.c
-mbedtls/library/version.c
-mbedtls/library/pem.c
-mbedtls/library/padlock.c
-mbedtls/library/asn1parse.c
-mbedtls/library/ssl_cli.c
-mbedtls/library/pkwrite.c
-mbedtls/library/ssl_cache.c
-mbedtls/library/sha256.c
-mbedtls/library/md_wrap.c
-mbedtls/library/entropy.c
-mbedtls/library/md.c
-mbedtls/library/rsa.c
-mbedtls/library/ripemd160.c
-mbedtls/library/version_features.c
-mbedtls/library/cipher.c
-mbedtls/library/dhm.c
-mbedtls/library/error.c
-mbedtls/library/ssl_ticket.c
-mbedtls/library/blowfish.c
-mbedtls/library/ecp.c
-mbedtls/library/md4.c
-mbedtls/library/pkparse.c
-mbedtls/library/pkcs5.c
-mbedtls/library/ccm.c
-mbedtls/library/pkcs12.c
-mbedtls/library/ecp_curves.c
-mbedtls/library/pk_wrap.c
-mbedtls/library/ctr_drbg.c
-mbedtls/library/platform.c
-mbedtls/library/pk.c
-mbedtls/library/des.c
-mbedtls/library/hmac_drbg.c
-mbedtls/library/sha1.c
-mbedtls/library/x509_crl.c
-mbedtls/library/x509_create.c
-mbedtls/library/x509.c
-mbedtls/library/x509_csr.c
-mbedtls/library/x509write_crt.c
-mbedtls/library/x509write_csr.c
-mbedtls/library/x509_crt.c
-mbedtls/library/entropy_poll.c
-mbedtls/library/timing.c
-timing_alt.c
-tls_net.c
-tls_hardware.c
-tls_certificate.c
-tls_client.c
-''')
+src = Glob('mbedtls/library/*.c')
+SrcRemove(src, 'net_sockets.c')
+
+src += Glob('mbedtls-port/src/*.c')
 
 if GetDepend(['PKG_USING_MBEDTLS_EXAMPLE']):
-    src += Glob('tls_app_test.c')
+    src += Glob('examples/*.c')
     
-# port/timing.c
-# mbedtls/library/net_sockets.c
-
 CPPPATH = [
 cwd,
-cwd + '/port/include',
 cwd + '/mbedtls/include',
 cwd + '/mbedtls/include/mbedtls',
+cwd + '/mbedtls-port/inc',
 ]
 CPPPATH += [RTT_ROOT + '/include/libc']
 

+ 6 - 1
tls_app_test.c → examples/tls_app_test.c

@@ -27,10 +27,15 @@
 
 #include <rtthread.h>
 
-#include <mbedtls/ssl.h>
 #include "tls_certificate.h"
 #include "tls_client.h"
 
+#if !defined(MBEDTLS_CONFIG_FILE)
+#include "mbedtls/config.h"
+#else
+#include MBEDTLS_CONFIG_FILE
+#endif
+
 #define malloc  tls_malloc
 #define free    tls_free
 #define rt_kprintf rt_kprintf("[tls]");rt_kprintf

+ 0 - 0
timing_alt.h → mbedtls-port/inc/timing_alt.h


+ 0 - 0
tls_certificate.h → mbedtls-port/inc/tls_certificate.h


+ 0 - 16
tls_client.h → mbedtls-port/inc/tls_client.h

@@ -27,22 +27,6 @@
 #include "mbedtls/ctr_drbg.h"
 #include "mbedtls/certs.h"
 
-#include <rtthread.h>
-
-#ifdef RT_USING_PSRAM
-#include <drv_sdram.h>
-
-#define tls_malloc  sdram_malloc
-#define tls_free    sdram_free
-#define tls_realloc sdram_realloc
-#define tls_calloc  sdram_calloc
-#else
-#define tls_malloc  malloc
-#define tls_free    free
-#define tls_realloc realloc
-#define tls_calloc  calloc
-#endif
-
 typedef struct MbedTLSSession
 {
     char* host;

+ 8 - 0
tls_config.h → mbedtls-port/inc/tls_config.h

@@ -2716,4 +2716,12 @@
 
 #include "check_config.h"
 
+/* the memory allocation method configurations */
+#include <rtthread.h>
+
+#define tls_malloc  rt_malloc
+#define tls_free    rt_free
+#define tls_realloc rt_realloc
+#define tls_calloc  rt_calloc
+
 #endif /* MBEDTLS_CONFIG_H */

+ 0 - 0
tls_net.h → mbedtls-port/inc/tls_net.h


+ 0 - 0
timing_alt.c → mbedtls-port/src/timing_alt.c


+ 0 - 0
tls_certificate.c → mbedtls-port/src/tls_certificate.c


+ 5 - 0
tls_client.c → mbedtls-port/src/tls_client.c

@@ -25,6 +25,11 @@
 #include "tls_client.h"
 #include "tls_certificate.h"
 
+#if !defined(MBEDTLS_CONFIG_FILE)
+#include "mbedtls/config.h"
+#else
+#include MBEDTLS_CONFIG_FILE
+#endif
 
 #define rt_kprintf rt_kprintf("[tls]");rt_kprintf
  

+ 0 - 0
tls_hardware.c → mbedtls-port/src/tls_hardware.c


+ 0 - 0
tls_net.c → mbedtls-port/src/tls_net.c