Skip to content

Commit 57e641e

Browse files
Merge pull request #399 from gojimmypi/ESP32-DTLS13
Initial ESP32 DTLS 1.3 client and server examples
2 parents eb4a336 + 660590a commit 57e641e

61 files changed

Lines changed: 11523 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# The following lines of boilerplate have to be in your project's
2+
# CMakeLists in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.16)
4+
5+
# set(WOLFSSL_ROOT "~/workspace/wolfssl-other-source")
6+
7+
# This tag is used to include this file in the ESP Component Registry:
8+
# __ESP_COMPONENT_SOURCE__
9+
10+
# Optional WOLFSSL_CMAKE_SYSTEM_NAME detection to find
11+
# USE_MY_PRIVATE_CONFIG path for my_private_config.h
12+
#
13+
if(WIN32)
14+
# Windows-specific configuration here
15+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS")
16+
message("Detected Windows")
17+
endif()
18+
if(CMAKE_HOST_UNIX)
19+
message("Detected UNIX")
20+
endif()
21+
if(APPLE)
22+
message("Detected APPLE")
23+
endif()
24+
if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop")
25+
# Windows-specific configuration here
26+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL")
27+
message("Detected WSL")
28+
endif()
29+
if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32))
30+
# Windows-specific configuration here
31+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX")
32+
message("Detected Linux")
33+
endif()
34+
if(APPLE)
35+
# Windows-specific configuration here
36+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE")
37+
message("Detected Apple")
38+
endif()
39+
# End optional WOLFSSL_CMAKE_SYSTEM_NAME
40+
41+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
42+
43+
project(wolfssl_dtls13_client)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# The following lines of boilerplate have to be in your project's
2+
# CMakeLists in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.5)
4+
5+
# set(WOLFSSL_ROOT "~/workspace/wolfssl-other-source")
6+
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
7+
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
8+
9+
# This tag is used to include this file in the ESP Component Registry:
10+
# __ESP_COMPONENT_SOURCE__
11+
12+
# Optional WOLFSSL_CMAKE_SYSTEM_NAME detection to find
13+
# USE_MY_PRIVATE_CONFIG path for my_private_config.h
14+
#
15+
if(WIN32)
16+
# Windows-specific configuration here
17+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS")
18+
message("Detected Windows")
19+
endif()
20+
if(CMAKE_HOST_UNIX)
21+
message("Detected UNIX")
22+
endif()
23+
if(APPLE)
24+
message("Detected APPLE")
25+
endif()
26+
if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop")
27+
# Windows-specific configuration here
28+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL")
29+
message("Detected WSL")
30+
endif()
31+
if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32))
32+
# Windows-specific configuration here
33+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX")
34+
message("Detected Linux")
35+
endif()
36+
if(APPLE)
37+
# Windows-specific configuration here
38+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE")
39+
message("Detected Apple")
40+
endif()
41+
# End optional WOLFSSL_CMAKE_SYSTEM_NAME
42+
43+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
44+
45+
project(wolfssl_dtls13_server)
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# wolfSSL DTLS1.3 Project
2+
3+
This is an example minimally viable wolfSSL template to get started with your own project.
4+
5+
### Prerequisites
6+
7+
It is assumed the [ESP-IDF environment](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/) has been installed.
8+
9+
```
10+
gcc -o client-dtls13 client-dtls13.c -L/mnt/c/workspace/wolfssl-gojimmypi/src/.libs -I/mnt/c/workspace/wolfssl-gojimmypi/ -I/mnt/c/workspace/wolfssl-gojimmypi/include -DWOLFSSL_TLS13 -DWOLFSSL_DTLS -DWOLFSSL_DTLS13 -DWOLFSSL_USER_SETTINGS -lwolfssl -ldl -lm
11+
```
12+
13+
### Files Included
14+
15+
- [main.c](./main/main.c) with a simple call to an Espressif library (`ESP_LOGI`) and a call to a wolfSSL library (`esp_ShowExtendedSystemInfo`) .
16+
17+
- See [components/wolfssl/include](./components/wolfssl/include/user_settings.h) directory to edit the wolfSSL `user_settings.h`.
18+
19+
- Edit [main/CMakeLists.txt](./main/CMakeLists.txt) to add/remove source files.
20+
21+
- The [components/wolfssl/CMakeLists.txt](./components/wolfssl/CMakeLists.txt) typically does not need to be changed.
22+
23+
- Optional [VisualGDB Project](./VisualGDB/wolfssl_template_IDF_v5.1_ESP32.vgdbproj) for Visual Studio using ESP32 and ESP-IDF v5.1.
24+
25+
- Edit the project [CMakeLists.txt](./CMakeLists.txt) to optionally point this project's wolfSSL component source code at a different directory:
26+
27+
```
28+
set(WOLFSSL_ROOT "~/workspace/wolfssl-other-source")
29+
```
30+
31+
32+
## Getting Started:
33+
34+
Here's an example using the command-line [idf.py](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-py.html).
35+
36+
Edit your `WRK_IDF_PATH`to point to your ESP-IDF install directory.
37+
38+
```
39+
cd /mnt/C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF5/examples/wolfssl_dtls13_server
40+
41+
WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.1
42+
43+
echo "Run export.sh from ${WRK_IDF_PATH}"
44+
. ${WRK_IDF_PATH}/export.sh
45+
46+
# build the example:
47+
idf.py build
48+
49+
# flash the code onto the serial device at /dev/ttyS19
50+
idf.py flash -p /dev/ttyS19 -b 115200
51+
52+
# build, flash, and view UART output with one command:
53+
idf.py flash -p /dev/ttyS19 -b 115200 monitor
54+
55+
# erase
56+
idf.py erase-flash -p /dev/ttyS9 -b 115200
57+
58+
# save defaults
59+
idf.py save-defconfig
60+
```
61+
62+
Press `Ctrl+]` to exit `idf.py monitor`. See [additional monitor keyboard commands](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-monitor.html).
63+
64+
## Other Examples:
65+
66+
For examples, see:
67+
68+
- [TLS Client](../wolfssl_client/README.md)
69+
- [TLS Server](../wolfssl_server/README.md)
70+
- [Benchmark](../wolfssl_benchmark/README.md)
71+
- [Test](../wolfssl_test/README.md)
72+
- [wolfssl-examples](https://github.com/wolfSSL/wolfssl-examples/tree/master/ESP32)
73+
- [wolfssh-examples](https://github.com/wolfSSL/wolfssh-examples/tree/main/Espressif)
74+
75+
76+

0 commit comments

Comments
 (0)