Skip to content

Commit 0e65af6

Browse files
yamtxiaoxiang781216
authored andcommitted
mbedtls: Add an option to build ssl_client2 test program
Signed-off-by: YAMAMOTO Takashi <[email protected]>
1 parent 71ce94a commit 0e65af6

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

crypto/mbedtls/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/mbedtls
2+
/mbedtls-framework
23
/*.zip

crypto/mbedtls/Kconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,31 @@ config MBEDTLS_APP_SELFTEST_STACKSIZE
788788

789789
endif # MBEDTLS_APP_SELFTEST
790790

791+
config MBEDTLS_APP_SSL_CLIENT2
792+
bool "Mbed TLS ssl_client2 sample program"
793+
default n
794+
---help---
795+
Enable the Mbed TLS ssl_client2
796+
797+
if MBEDTLS_APP_SSL_CLIENT2
798+
799+
config MBEDTLS_APP_SSL_CLIENT2_PROGNAME
800+
string "Program name"
801+
default "ssl_client2"
802+
---help---
803+
This is the name of the program that will be used when the NSH ELF
804+
program is installed.
805+
806+
config MBEDTLS_APP_SSL_CLIENT2_PRIORITY
807+
int "ssl_client2 task priority"
808+
default 100
809+
810+
config MBEDTLS_APP_SSL_CLIENT2_STACKSIZE
811+
int "ssl_client2 stack size"
812+
default MBEDTLS_DEFAULT_TASK_STACKSIZE
813+
814+
endif # MBEDTLS_APP_SSL_CLIENT2
815+
791816
endif # MBEDTLS_APPS
792817

793818
endif # CRYPTO_MBEDTLS

crypto/mbedtls/Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ UNPACK ?= unzip -q -o
3737
MBEDTLS_UNPACKLIBDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)library
3838
MBEDTLS_UNPACKPROGDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)programs
3939

40+
MBEDTLS_FRAMEWORK_URL ?= "https://github.com/Mbed-TLS/mbedtls-framework/archive"
41+
42+
MBEDTLS_FRAMEWORK_VERSION = df3307f2b4fe512def60886024f7be8fd1523ccd
43+
MBEDTLS_FRAMEWORK_ZIP = $(MBEDTLS_FRAMEWORK_VERSION).zip
44+
45+
MBEDTLS_FRAMEWORK_UNPACKNAME = mbedtls-framework
46+
4047
# This lets Mbed TLS better use some of the POSIX features we have
4148
CFLAGS += ${DEFINE_PREFIX}unix
4249

@@ -64,6 +71,10 @@ $(MBEDTLS_ZIP):
6471
@echo "Downloading: $(MBEDTLS_URL)/$(MBEDTLS_ZIP)"
6572
$(Q) curl -O -L $(MBEDTLS_URL)/$(MBEDTLS_ZIP)
6673

74+
$(MBEDTLS_FRAMEWORK_ZIP):
75+
@echo "Downloading: $(MBEDTLS_FRAMEWORK_URL)/$(MBEDTLS_FRAMEWORK_ZIP)"
76+
$(Q) curl -O -L $(MBEDTLS_FRAMEWORK_URL)/$(MBEDTLS_FRAMEWORK_ZIP)
77+
6778
$(MBEDTLS_UNPACKNAME): $(MBEDTLS_ZIP)
6879
@echo "Unpacking: $(MBEDTLS_ZIP) -> $(MBEDTLS_UNPACKNAME)"
6980
$(Q) $(UNPACK) $(MBEDTLS_ZIP)
@@ -73,6 +84,11 @@ $(MBEDTLS_UNPACKNAME): $(MBEDTLS_ZIP)
7384
$(Q) patch -p1 -d $(MBEDTLS_UNPACKNAME) < 0003-Fix-MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT-warning.patch
7485
$(Q) touch $(MBEDTLS_UNPACKNAME)
7586

87+
$(MBEDTLS_FRAMEWORK_UNPACKNAME): $(MBEDTLS_FRAMEWORK_ZIP)
88+
@echo "Unpacking: $(MBEDTLS_ZIP) -> $(MBEDTLS_FRAMEWORK_UNPACKNAME)"
89+
$(Q) $(UNPACK) $(MBEDTLS_FRAMEWORK_ZIP)
90+
$(Q) mv mbedtls-framework-$(MBEDTLS_FRAMEWORK_VERSION) $(MBEDTLS_FRAMEWORK_UNPACKNAME)
91+
7692
# Download and unpack tarball if no git repo found
7793
ifeq ($(wildcard $(MBEDTLS_UNPACKNAME)/.git),)
7894
context:: $(MBEDTLS_UNPACKNAME)
@@ -106,6 +122,33 @@ STACKSIZE += $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE)
106122
MAINSRC += $(MBEDTLS_UNPACKPROGDIR)/test/selftest.c
107123
endif
108124

125+
ifeq ($(CONFIG_MBEDTLS_APP_SSL_CLIENT2),y)
126+
127+
PROGNAME += $(CONFIG_MBEDTLS_APP_SSL_CLIENT2_PROGNAME)
128+
PRIORITY += $(CONFIG_MBEDTLS_APP_SSL_CLIENT2_PRIORITY)
129+
STACKSIZE += $(CONFIG_MBEDTLS_APP_SSL_CLIENT2_STACKSIZE)
130+
131+
MAINSRC += $(MBEDTLS_UNPACKPROGDIR)/ssl/ssl_client2.c
132+
CSRCS += $(MBEDTLS_UNPACKPROGDIR)/ssl/ssl_test_lib.c
133+
CSRCS += $(MBEDTLS_UNPACKPROGDIR)/test/query_config.c
134+
CSRCS += $(MBEDTLS_UNPACKNAME)/tests/src/certs.c
135+
CSRCS += $(MBEDTLS_FRAMEWORK_UNPACKNAME)/tests/src/helpers.c
136+
CSRCS += $(MBEDTLS_FRAMEWORK_UNPACKNAME)/tests/src/psa_crypto_helpers.c
137+
CFLAGS += ${INCDIR_PREFIX}$(MBEDTLS_UNPACKLIBDIR)
138+
CFLAGS += ${INCDIR_PREFIX}$(MBEDTLS_UNPACKNAME)/tests/include
139+
CFLAGS += ${INCDIR_PREFIX}$(MBEDTLS_FRAMEWORK_UNPACKNAME)/tests/include
140+
CFLAGS += ${INCDIR_PREFIX}$(MBEDTLS_FRAMEWORK_UNPACKNAME)/tests/programs
141+
endif
142+
143+
# Download and unpack tarball if no git repo found
144+
ifeq ($(wildcard $(MBEDTLS_FRAMEWORK_UNPACKNAME)/.git),)
145+
context:: $(MBEDTLS_FRAMEWORK_UNPACKNAME)
146+
147+
distclean::
148+
$(call DELDIR, $(MBEDTLS_FRAMEWORK_UNPACKNAME))
149+
$(call DELFILE, $(MBEDTLS_FRAMEWORK_ZIP))
150+
endif
151+
109152
endif
110153

111154
# Configuration alternative implementation

0 commit comments

Comments
 (0)