Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Mbedtls
提交
c8797c6d
T
Third Party Mbedtls
项目概览
OpenHarmony
/
Third Party Mbedtls
9 个月 前同步成功
通知
0
Star
19
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Mbedtls
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
c8797c6d
编写于
8月 03, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 03, 2023
浏览文件
操作
浏览文件
下载
差异文件
!90 LITEOS只支持IPv4类型的连接
Merge pull request !90 from maosiping/master
上级
de3a6678
77b67554
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
48 addition
and
7 deletion
+48
-7
BUILD.gn
BUILD.gn
+13
-0
library/net_sockets.c
library/net_sockets.c
+16
-0
mbedtls.gni
mbedtls.gni
+11
-1
port/BUILD.gn
port/BUILD.gn
+2
-1
port/include/mbedtls_log.h
port/include/mbedtls_log.h
+0
-1
port/include/tls_client.h
port/include/tls_client.h
+4
-1
port/src/tls_client.c
port/src/tls_client.c
+2
-3
未找到文件。
BUILD.gn
浏览文件 @
c8797c6d
...
...
@@ -27,10 +27,23 @@ MBEDTLS_SOURCES += [
"library/x509write_csr.c",
]
if (defined(ohos_lite)) {
MBEDTLS_SOURCES -= [ "library/ssl_srv.c" ]
}
if (defined(ohos_lite)) {
import("//build/lite/config/component/lite_component.gni")
import("//build/lite/ndk/ndk.gni")
if (ohos_kernel_type != "liteos_m") {
MBEDTLS_SOURCES += [ "library/ssl_srv.c" ]
MBEDTLS_SOURCES -= [
"$MBEDTLSDIR/library/ssl_srv.c",
"$MBEDTLSDIR/port/src/tls_client.c",
"$MBEDTLSDIR/port/src/tls_certificate.c",
]
}
config("mbedtls_config") {
include_dirs = MBEDTLS_INLCUDE_DIRS
if (ohos_kernel_type == "liteos_m") {
...
...
library/net_sockets.c
浏览文件 @
c8797c6d
...
...
@@ -193,8 +193,15 @@ int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host,
ret
=
MBEDTLS_ERR_NET_UNKNOWN_HOST
;
for
(
cur
=
addr_list
;
cur
!=
NULL
;
cur
=
cur
->
ai_next
)
{
#ifdef LITEOS_VERSION
if
(
cur
->
ai_family
!=
AF_INET
||
cur
->
ai_socktype
!=
SOCK_STREAM
)
{
continue
;
}
ctx
->
fd
=
(
int
)
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
#else
ctx
->
fd
=
(
int
)
socket
(
cur
->
ai_family
,
cur
->
ai_socktype
,
cur
->
ai_protocol
);
#endif
if
(
ctx
->
fd
<
0
)
{
ret
=
MBEDTLS_ERR_NET_SOCKET_FAILED
;
...
...
@@ -575,8 +582,12 @@ int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len )
ret
=
check_fd
(
fd
,
0
);
if
(
ret
!=
0
)
return
(
ret
);
#ifdef LITEOS_VERSION
ret
=
(
int
)
recv
(
fd
,
buf
,
len
,
0
);
#else
ret
=
(
int
)
read
(
fd
,
buf
,
len
);
#endif
if
(
ret
<
0
)
{
...
...
@@ -658,7 +669,12 @@ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len )
if
(
ret
!=
0
)
return
(
ret
);
#ifdef LITEOS_VERSION
ret
=
(
int
)
send
(
fd
,
buf
,
len
,
0
);
#else
ret
=
(
int
)
write
(
fd
,
buf
,
len
);
#endif
if
(
ret
<
0
)
{
...
...
mbedtls.gni
浏览文件 @
c8797c6d
...
...
@@ -24,7 +24,7 @@
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
MBEDTLSDIR = "//third_party/mbedtls/"
KERNELDIR = "//kernel/liteos_m/"
...
...
@@ -129,3 +129,13 @@ MBEDTLS_INLCUDE_DIRS = [
"$MBEDTLSDIR/include/mbedtls",
"$MBEDTLSDIR/tests/include",
]
if (defined(ohos_lite)) {
MBEDTLS_SOURCES += [
"$MBEDTLSDIR/library/ssl_srv.c",
"$MBEDTLSDIR/port/src/tls_client.c",
"$MBEDTLSDIR/port/src/tls_certificate.c",
]
MBEDTLS_INLCUDE_DIRS += [ "$MBEDTLSDIR/port/include" ]
}
port/BUILD.gn
浏览文件 @
c8797c6d
...
...
@@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
import("//build/lite/config/component/lite_component.gni")
...
...
@@ -22,6 +22,7 @@ if (ohos_build_type == "debug") {
"//third_party/mbedtls/include",
"//commonlibrary/utils_lite/include",
"//third_party/bounds_checking_function/include",
"//third_party/mbedtls/port/include",
]
}
...
...
port/include/mbedtls_log.h
浏览文件 @
c8797c6d
...
...
@@ -30,7 +30,6 @@
#ifndef OHOS_DEBUG
#define DECORATOR_HILOG(op, fmt, args...) \
do
{
\
op
(
LOG_CORE
,
fmt
,
##
args
);
\
}
while
(
0
)
#else
#define DECORATOR_HILOG(op, fmt, args...) \
...
...
port/include/tls_client.h
浏览文件 @
c8797c6d
...
...
@@ -17,7 +17,7 @@
#define MBEDTLS_CLIENT_H
#include "mbedtls/platform.h"
#include "mbedtls/net_sockets"
#include "mbedtls/net_sockets
.h
"
#include "mbedtls/ssl.h"
#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
...
...
@@ -25,6 +25,9 @@
#define RET_ERROR -1;
#define RET_EOK 0
#ifndef LOG_CORE
#define LOG_CORE 3
#endif
typedef
struct
MbedTLSSession
{
char
*
host
;
...
...
port/src/tls_client.c
浏览文件 @
c8797c6d
...
...
@@ -90,7 +90,7 @@ int MbedtlsClientContext(MbedTLSSession *session)
int
ret
=
mbedtls_x509_crt_parse
(
&
session
->
cacert
,
(
const
unsigned
char
*
)
G_MBEDTLS_ROOT_CERTIFICATE
,
G_MBEDTLS_ROOT_CERTIFICATE_LEN
);
if
(
ret
<
0
)
{
LOG
E
(
"mbedtls_x509_crt_parse error, return -0x%x."
,
-
ret
);
LOG
D
(
"mbedtls_x509_crt_parse error, return -0x%x."
,
-
ret
);
return
ret
;
}
...
...
@@ -135,7 +135,7 @@ int MbedtlsClientConnect(MbedTLSSession *session)
if
(
session
==
NULL
)
{
return
-
RET_ERROR
;
}
LOG
I
(
"connect: host:%s, port: %s"
,
session
->
host
,
session
->
port
);
LOG
D
(
"connect: host:%s, port: %s"
,
session
->
host
,
session
->
port
);
int
ret
=
mbedtls_net_connect
(
&
session
->
server_fd
,
session
->
host
,
session
->
port
,
MBEDTLS_NET_PROTO_TCP
);
if
(
ret
!=
0
)
{
...
...
@@ -145,7 +145,6 @@ int MbedtlsClientConnect(MbedTLSSession *session)
LOGD
(
"Connected %s:%s fd:%d, success..."
,
session
->
host
,
session
->
port
,
session
->
server_fd
.
fd
);
mbedtls_ssl_set_bio
(
&
session
->
ssl
,
&
session
->
server_fd
,
mbedtls_net_send
,
mbedtls_net_recv
,
NULL
);
LOGD
(
"ssl state=%d"
,
session
->
ssl
.
state
);
while
((
ret
=
mbedtls_ssl_handshake
(
&
session
->
ssl
))
!=
0
)
{
LOGD
(
"mbedtls_ssl_handshake ret=0x%x."
,
-
ret
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录