Skip to content

Commit b1d05ac

Browse files
authored
Merge pull request #363 from cconlon/se050_tls_example
SE050: add demo SSL/TLS client applications
2 parents a363898 + f67f403 commit b1d05ac

File tree

18 files changed

+1179
-22
lines changed

18 files changed

+1179
-22
lines changed

SE050/README.md

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,56 @@ running these examples.
1616
## Installing Example Applications
1717

1818
These instructions assume that the SE050 middleware has already been installed
19-
in Raspbian and is located at `/home/pi/se_mw/simw-top`.
19+
in Raspbian and is located at `/home/pi/se_mw/simw-top`. Also that wolfSSL has
20+
been built and installed. See instructions in the wolfSSL repository at
21+
`wolfcrypt/src/port/nxp/README_SE050.md`.
2022

21-
Before building these demo, the "wolfssl" folder which contains these demos
22-
should be copied into the SE05x middleware source tree at:
23+
Example SE050 Pi installation steps:
2324

25+
```sh
26+
$ cd se_mw/simw-top
27+
$ mkdir build && cd build
28+
$ ccmake .
29+
# Make sure the following are set:
30+
# `Host OS` to `Raspbian`
31+
# `Host Crypto` to `None` (see HostCrypto section below)
32+
# `SMCOM` to `T1oI2C`
33+
$ c # to configure
34+
$ g # to generate
35+
$ q
36+
$ cmake --build .
37+
$ sudo make install
2438
```
25-
/home/pi/se_mw/simw-top/demos/wolfssl
39+
40+
Example wolfSSL installation:
41+
2642
```
43+
./configure --with-se050=/home/pi/se_mw/simw-top/ --enable-keygen --enable-cryptocb \
44+
--disable-examples --disable-crypttests
45+
make
46+
sudo make install
47+
```
48+
49+
Before building these demos, the "wolfssl" folder which contains these demos
50+
should be copied into the SE05x middleware source tree at: `~/se_mw/simw-top/demos/wolfssl`.
51+
Example: `cp -r wolfssl ~/se_mw/simw-top/demos/`
2752

2853
This will mean the wolfSSL demo applications will be at:
2954

3055
```
31-
/home/pi/se_mw/simw-top/demos/wolfssl/wolfcrypt_benchmark
32-
/home/pi/se_mw/simw-top/demos/wolfssl/wolfcrypt_generate_csr
33-
/home/pi/se_mw/simw-top/demos/wolfssl/wolfcrypt_key_cert_insert
34-
/home/pi/se_mw/simw-top/demos/wolfssl/wolfcrypt_test
56+
~/se_mw/simw-top/demos/wolfssl/wolfcrypt_benchmark
57+
~/se_mw/simw-top/demos/wolfssl/wolfcrypt_generate_csr
58+
~/se_mw/simw-top/demos/wolfssl/wolfcrypt_key_cert_insert
59+
~/se_mw/simw-top/demos/wolfssl/wolfcrypt_test
60+
~/se_mw/simw-top/demos/wolfssl/wolfssl_client
61+
~/se_mw/simw-top/demos/wolfssl/wolfssl_client_cert_key
3562
```
3663

3764
The 'wolfssl' demo directory needs to be tied into the CMake build system. Open
3865
the following file:
3966

4067
```
41-
/home/pi/se_mw/simw-top/demos/CMakeLists.txt
68+
~/se_mw/simw-top/demos/CMakeLists.txt
4269
```
4370

4471
Add the following at the bottom of this file:
@@ -50,9 +77,9 @@ ADD_SUBDIRECTORY(wolfssl)
5077
If the SE05x middleware has not yet been set up for compilation:
5178

5279
```
53-
$ cd /home/pi/se_mw/simw-top/scripts
54-
$ ./create_cmake_projects.py rpi
55-
$ cd /home/pi/se_mw/simw-top_build/raspbian_native_se050_t1oi2c
80+
$ cd ~/se_mw/simw-top/scripts
81+
$ python ./create_cmake_projects.py rpi
82+
$ cd ~/se_mw/simw-top_build/raspbian_native_se050_t1oi2c
5683
$ ccmake .
5784
< adjust options to match SE050 dev kit >
5885
< 'c', to configure >
@@ -68,6 +95,13 @@ included here need benchmark.c, benchmark.h, test.c, and test.h copied over
6895
from a valid wolfSSL source tree. See notes in those example README.md files
6996
for more information.
7097

98+
```
99+
cp ~/wolfssl/wolfcrypt/benchmark/benchmark.c ./wolfssl/wolfcrypt_benchmark/
100+
cp ~/wolfssl/wolfcrypt/benchmark/benchmark.h ./wolfssl/wolfcrypt_benchmark/
101+
cp ~/wolfssl/wolfcrypt/test/test.c ./wolfssl/wolfcrypt_test/
102+
cp ~/wolfssl/wolfcrypt/test/test.h ./wolfssl/wolfcrypt_test/
103+
```
104+
71105
## NXP SE050 EdgeLock Configuration
72106

73107
wolfSSL most recently tested these examples on a Raspberry Pi with NXP
@@ -105,6 +139,22 @@ generated and stored in the SE050. This examples requires that wolfSSL be
105139
compiled with `--enable-certgen --enable-certreq`. For details, see
106140
[README.md](./wolfssl/wolfcrypt_generate_csr/README.md).
107141

142+
### wolfSSL SSL/TLS Client Example
143+
144+
This example demonstrates a simple SSL/TLS client, using hardware-based
145+
cryptography supported inside the SE050. It loads and uses a certificate
146+
and private key from C arrays/buffers. For a more advanced demo which uses
147+
the private key directly from the SE050, see the following example. For details,
148+
see [README.md](./wolfssl/wolfssl_client/README.md).
149+
150+
### wolfSSL SSL/TLS Client Example with Cert and Private Key in SE050
151+
152+
This example demonstrates a simple SSL/TLS client, using hardware-based
153+
cryptography supported inside the SE050. It loads and uses a certificate
154+
and private key from C arrays/buffers into the SE050, then does all private key
155+
operations inside the SE050 for the TLS private key, based on a key ID.
156+
For details, see [README.md](./wolfssl/wolfssl_client_cert_key/README.md).
157+
108158
## Support
109159

110160
For support questions and issues, please email wolfSSL at [email protected].

SE050/wolfssl/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ ADD_SUBDIRECTORY(wolfcrypt_benchmark)
22
ADD_SUBDIRECTORY(wolfcrypt_test)
33
ADD_SUBDIRECTORY(wolfcrypt_key_cert_insert)
44
ADD_SUBDIRECTORY(wolfcrypt_generate_csr)
5+
ADD_SUBDIRECTORY(wolfssl_client)
6+
ADD_SUBDIRECTORY(wolfssl_client_cert_key)

SE050/wolfssl/wolfcrypt_benchmark/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ADD_EXECUTABLE(
1212

1313
TARGET_COMPILE_DEFINITIONS(
1414
${PROJECT_NAME}
15-
PRIVATE SIMW_DEMO_ENABLE__DEMO_WOLFCRYPTBENCHMARK NO_MAIN_DRIVER BENCH_EMBEDDED USE_CERT_BUFFERS_2048 USE_CERT_BUFFERS_256
15+
PRIVATE SIMW_DEMO_ENABLE__DEMO_WOLFCRYPTBENCHMARK NO_MAIN_DRIVER BENCH_EMBEDDED USE_CERT_BUFFERS_2048 USE_CERT_BUFFERS_256 USE_FLAT_BENCHMARK_H
1616
)
1717

1818
TARGET_INCLUDE_DIRECTORIES(

SE050/wolfssl/wolfcrypt_benchmark/benchmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* benchmark.c
22
*
3-
* Copyright (C) 2006-2022 wolfSSL Inc.
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*

SE050/wolfssl/wolfcrypt_benchmark/benchmark.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* benchmark.h
22
*
3-
* Copyright (C) 2006-2022 wolfSSL Inc.
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*

SE050/wolfssl/wolfcrypt_benchmark/wolfcrypt_benchmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* wolfcrypt_benchmark.c
22
*
3-
* Copyright (C) 2006-2022 wolfSSL Inc.
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*

SE050/wolfssl/wolfcrypt_generate_csr/wolfcrypt_generate_csr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* wolfcrypt_generate_csr.c
22
*
3-
* Copyright (C) 2006-2022 wolfSSL Inc.
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*

SE050/wolfssl/wolfcrypt_key_cert_insert/wolfcrypt_key_cert_insert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* wolfcrypt_key_cert_insert.c
22
*
3-
* Copyright (C) 2006-2022 wolfSSL Inc.
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*

SE050/wolfssl/wolfcrypt_test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ADD_EXECUTABLE(
1212

1313
TARGET_COMPILE_DEFINITIONS(
1414
${PROJECT_NAME}
15-
PRIVATE SIMW_DEMO_ENABLE__DEMO_WOLFCRYPTTEST NO_MAIN_DRIVER BENCH_EMBEDDED USE_CERT_BUFFERS_2048 USE_CERT_BUFFERS_256
15+
PRIVATE SIMW_DEMO_ENABLE__DEMO_WOLFCRYPTTEST NO_MAIN_DRIVER BENCH_EMBEDDED USE_CERT_BUFFERS_2048 USE_CERT_BUFFERS_256 USE_FLAT_TEST_H
1616
)
1717

1818
TARGET_INCLUDE_DIRECTORIES(

SE050/wolfssl/wolfcrypt_test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* test.c
22
*
3-
* Copyright (C) 2006-2022 wolfSSL Inc.
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*

SE050/wolfssl/wolfcrypt_test/test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* test.h
22
*
3-
* Copyright (C) 2006-2022 wolfSSL Inc.
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*

SE050/wolfssl/wolfcrypt_test/wolfcrypt_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* wolfcrypt_test.c
22
*
3-
* Copyright (C) 2006-2022 wolfSSL Inc.
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
PROJECT(wolfssl_client)
2+
FILE(
3+
GLOB
4+
files
5+
*.c
6+
)
7+
8+
ADD_EXECUTABLE(
9+
${PROJECT_NAME}
10+
${KSDK_STARTUP_FILE} ${files}
11+
)
12+
13+
TARGET_COMPILE_DEFINITIONS(
14+
${PROJECT_NAME}
15+
PRIVATE SIMW_DEMO_ENABLE__DEMO_WOLFSSL_CLIENT NO_MAIN_DRIVER USE_CERT_BUFFERS_2048 USE_CERT_BUFFERS_256
16+
)
17+
18+
TARGET_INCLUDE_DIRECTORIES(
19+
${PROJECT_NAME}
20+
PRIVATE ${SIMW_TOP_DIR}/sss/ex/inc /home/pi/se_mw/wolfssl
21+
)
22+
23+
TARGET_LINK_LIBRARIES(
24+
${PROJECT_NAME}
25+
SSS_APIs
26+
ex_common
27+
wolfssl
28+
)
29+
30+
CREATE_BINARY(${PROJECT_NAME})
31+
32+
IF(SSS_HAVE_HOST_LINUX_LIKE)
33+
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
34+
ENDIF()
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# wolfSSL SSL/TLS Client Demo Application
2+
3+
This demo application runs a wolfSSL TLS example client. It connects to the
4+
main wolfSSL example server (distributed with wolfSSL proper).
5+
6+
This example client uses SE050-based cryptography inside the module where
7+
supported. It does not load the client certificate and private key into the
8+
SE050 module. For a more advanced demo that does load these into the SE050
9+
and uses the private key directly from the module based on key ID, see the
10+
wolfSSL client demo located up a directory below, or read the associated
11+
[README.md](../wolfssl_client_cert_key/README.md) for that demo.
12+
13+
```
14+
wolfssl_client_cert_key/wolfssl_client_cert_key.c
15+
```
16+
17+
## Building the Demo
18+
19+
Before building this demo, follow initial setup instructions in the parent
20+
[README.md](../../README.md).
21+
22+
Compiling the middleware will also compile this demo application:
23+
24+
```
25+
$ cd /home/pi/se_mw/simw-top_build/raspbian_native_se050_t1oi2c
26+
$ cmake --build .
27+
```
28+
29+
## Running the Demo
30+
31+
To run the demo, first start the wolfSSL example server. This demo client
32+
assumes the server will be available at **127.0.0.1:11111**:
33+
34+
```
35+
$ cd <wolfssl_directory>
36+
$ ./examples/server/server
37+
```
38+
39+
Then, to run this demo:
40+
41+
```
42+
$ cd /home/pi/se_mw/simw-top_build/raspbian_native_se050_t1oi2c/bin
43+
$ ./wolfssl_client
44+
```
45+
46+
On successful run, output similar to the following will print out:
47+
48+
```
49+
App :INFO :PlugAndTrust_v04.02.00_20220524
50+
App :INFO :Running ./wolfssl_client
51+
App :INFO :If you want to over-ride the selection, use ENV=EX_SSS_BOOT_SSS_PORT or pass in command line arguments.
52+
sss :INFO :atr (Len=35)
53+
00 A0 00 00 03 96 04 03 E8 00 FE 02 0B 03 E8 08
54+
01 00 00 00 00 64 00 00 0A 4A 43 4F 50 34 20 41
55+
54 50 4F
56+
sss :WARN :Communication channel is Plain.
57+
sss :WARN :!!!Not recommended for production use.!!!
58+
App :INFO :wolfSSL example client
59+
60+
App :INFO :Running wc_se050_set_config()
61+
App :INFO :SE050 config successfully set in wolfSSL
62+
App :INFO :Created and configured socket
63+
App :INFO :Socket connected
64+
App :INFO :Created WOLFSSL_CTX
65+
App :INFO :Created WOLFSSL_CTX
66+
App :INFO :Loaded CA certs into CTX
67+
App :INFO :Loaded client certificate into CTX
68+
App :INFO :Loaded client private key into CTX
69+
App :INFO :Created new WOLFSSL
70+
App :INFO :Set wolfSSL fd
71+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
72+
sss :WARN :Could not delete Key id FFFF
73+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
74+
sss :WARN :Could not delete Key id 10000
75+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
76+
sss :WARN :Could not delete Key id 10001
77+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
78+
sss :WARN :Could not delete Key id 10002
79+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
80+
sss :WARN :Could not delete Key id 10003
81+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
82+
sss :WARN :Could not delete Key id 10004
83+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
84+
sss :WARN :Could not delete Key id 10005
85+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
86+
sss :WARN :Could not delete Key id 10006
87+
App :INFO :Sending message to server: GET /index.html HTTP/1.0
88+
89+
90+
91+
App :INFO :wolfSSL_write sent 28 bytes
92+
93+
App :INFO :Server response: I hear you fa shizzle!
94+
95+
App :INFO :TLS shutdown not complete
96+
App :INFO :TLS shutdown complete
97+
App :INFO :Done with sample app
98+
App :INFO :ex_sss Finished
99+
```
100+
101+
## Demo Notes
102+
103+
It is expected to see warning messages in the console log about failures to
104+
delete key ids. wolfCrypt internally tries to delete temporary/test keys,
105+
and if those keys have not been stored in the SE050 the debug logs will show
106+
these messages.
107+
108+
See the source code of the demo for more notes about wolfSSL API usage.
109+

0 commit comments

Comments
 (0)