Initial commit: CCU621_M firmware project with BLE debug link support.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#ifndef BS_TLS_MBED_H
|
||||
#define BS_TLS_MBED_H
|
||||
|
||||
#include "publicdata/public_define.h"
|
||||
|
||||
#if (BS_TLS_MBEDTLS_EN)
|
||||
|
||||
/* 仅在启用 TLS 时才编译 mbedtls 相关代码,避免未下载库时报错 */
|
||||
|
||||
#include "mbedtls/platform.h"
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/error.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mbedtls_net_context net_ctx; /* 绑定的底层 TCP socket fd */
|
||||
mbedtls_ssl_context ssl;
|
||||
mbedtls_ssl_config conf;
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
mbedtls_entropy_context entropy;
|
||||
U8_T inited; /* 0=未初始化 1=已初始化 */
|
||||
} BS_TLS_CTX;
|
||||
|
||||
/*
|
||||
* 初始化 TLS 上下文(不包含握手),fd 由上层创建 TCP 后传入
|
||||
* host 用于 SNI/证书校验
|
||||
*/
|
||||
int bs_tls_client_connect(BS_TLS_CTX *ctx, int fd, const char *host);
|
||||
|
||||
/* TLS 封装的发送/接收接口,返回值语义与 mbedtls_ssl_write/read 一致 */
|
||||
int bs_tls_client_send(BS_TLS_CTX *ctx, const unsigned char *buf, size_t len);
|
||||
int bs_tls_client_recv(BS_TLS_CTX *ctx, unsigned char *buf, size_t len);
|
||||
|
||||
/* 关闭 TLS 会话并释放资源,但不主动关闭底层 fd(交由上层统一处理) */
|
||||
void bs_tls_client_close(BS_TLS_CTX *ctx);
|
||||
|
||||
#endif /* BS_TLS_MBEDTLS_EN */
|
||||
|
||||
#endif /* BS_TLS_MBED_H */
|
||||
|
||||
Reference in New Issue
Block a user