-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
790e39b
commit d1a4355
Showing
13 changed files
with
130 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: "mbedtls-cxx: build-tests" | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [opened, synchronize, reopened, labeled] | ||
|
||
jobs: | ||
build_tls_cxx: | ||
if: contains(github.event.pull_request.labels.*.name, 'tls_cxx') || github.event_name == 'push' | ||
name: Build | ||
strategy: | ||
matrix: | ||
idf_ver: ["latest", "release-v5.2", "release-v5.1"] | ||
test: [ { app: client, path: "examples/tls_client" }, { app: udp, path: "examples/udp_mutual_auth" }, { app: test, path: "tests/uart_mutual_auth" } ] | ||
runs-on: ubuntu-20.04 | ||
container: espressif/idf:${{ matrix.idf_ver }} | ||
steps: | ||
- name: Checkout esp-protocols | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }} | ||
shell: bash | ||
run: | | ||
${IDF_PATH}/install.sh --enable-pytest | ||
. ${IDF_PATH}/export.sh | ||
python ./ci/build_apps.py ./components/mbedtls_cxx/${{ matrix.test.path }} -vv --preserve-all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# mbedtls_cxx | ||
|
||
This is a simplified C++ wrapper of mbedTLS for performing TLS and DTLS handshake a communication. This component allows for overriding low level IO functions (`send()` and `recv()`) and thus supporting TLS over various physical channels. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#pragma once | ||
|
||
#include "mbedtls_wrap.hpp" | ||
|
||
namespace test_certs { | ||
using pem_format = const unsigned char; | ||
extern pem_format cacert_start[] asm("_binary_ca_crt_start"); | ||
extern pem_format cacert_end[] asm("_binary_ca_crt_end"); | ||
extern pem_format clientcert_start[] asm("_binary_client_crt_start"); | ||
extern pem_format clientcert_end[] asm("_binary_client_crt_end"); | ||
extern pem_format clientkey_start[] asm("_binary_client_key_start"); | ||
extern pem_format clientkey_end[] asm("_binary_client_key_end"); | ||
extern pem_format servercert_start[] asm("_binary_srv_crt_start"); | ||
extern pem_format servercert_end[] asm("_binary_srv_crt_end"); | ||
extern pem_format serverkey_start[] asm("_binary_srv_key_start"); | ||
extern pem_format serverkey_end[] asm("_binary_srv_key_end"); | ||
|
||
enum class type { | ||
cacert, | ||
servercert, | ||
serverkey, | ||
clientcert, | ||
clientkey | ||
}; | ||
|
||
#define IF_BUF_TYPE(buf_type) \ | ||
if (t == type::buf_type) { \ | ||
return idf::mbedtls_cxx::const_buf{buf_type ## _start, buf_type ## _end - buf_type ## _start}; \ | ||
} | ||
|
||
static inline idf::mbedtls_cxx::const_buf get_buf(type t) | ||
{ | ||
IF_BUF_TYPE(cacert); | ||
IF_BUF_TYPE(servercert); | ||
IF_BUF_TYPE(serverkey); | ||
IF_BUF_TYPE(clientcert); | ||
IF_BUF_TYPE(clientkey); | ||
return idf::mbedtls_cxx::const_buf{}; | ||
} | ||
|
||
static inline const char *get_server_cn() | ||
{ | ||
return "espressif.local"; | ||
} | ||
|
||
} |
7 changes: 0 additions & 7 deletions
7
components/mbedtls_cxx/examples/uart_mutual_auth/main/CMakeLists.txt
This file was deleted.
Oops, something went wrong.
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
components/mbedtls_cxx/tests/uart_mutual_auth/main/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
idf_component_register(SRCS "uart_mutual.cpp" | ||
INCLUDE_DIRS ".") |
19 changes: 19 additions & 0 deletions
19
components/mbedtls_cxx/tests/uart_mutual_auth/main/Kconfig.projbuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
menu "Test Configuration" | ||
|
||
choice TEST_CONNECTION_METHOD | ||
prompt "Choose connection method" | ||
default TEST_TLS | ||
help | ||
Select type of connection. Either TLS or DTLS | ||
|
||
config TEST_TLS | ||
bool "TLS" | ||
help | ||
Use TLS method. | ||
config TEST_DTLS | ||
bool "DTLS" | ||
help | ||
Use DTLS method. | ||
endchoice # TEST_CONNECTION_METHOD | ||
|
||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
components/mbedtls_cxx/tests/uart_mutual_auth/sdkconfig.ci.dtls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONFIG_TEST_DTLS=y | ||
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y | ||
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=8192 |
1 change: 1 addition & 0 deletions
1
...mples/uart_mutual_auth/sdkconfig.defaults → ...x/tests/uart_mutual_auth/sdkconfig.ci.tls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
CONFIG_TEST_TLS=y | ||
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y | ||
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=8192 |
3 changes: 3 additions & 0 deletions
3
components/mbedtls_cxx/tests/uart_mutual_auth/sdkconfig.defaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONFIG_IDF_TARGET="esp32" | ||
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y | ||
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=8192 |