Skip to content

Commit 27bb621

Browse files
authored
Merge pull request #346 from cconlon/se050
Add NXP SE050 EdgeLock examples for use on Raspberry Pi
2 parents c349132 + 05efd4a commit 27bb621

File tree

20 files changed

+1776
-0
lines changed

20 files changed

+1776
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,16 @@ This directory contains a wolfCrypt benchmark test application for i.MX RT1060-E
283283
Please see the [RT1060/README.md](RT1060/README.md) for further usage and details.
284284

285285

286+
<br />
287+
288+
#### NXP SE050
289+
290+
This directory contains example applications for NXP's SE050. The examples
291+
have been tested on a Raspberry Pi with SE050 EdgeLock.
292+
293+
Please see the [SE050/README.md](SE050/README.md) for further details.
294+
295+
286296
<br />
287297

288298
#### SGX_Linux (Linux Enclave)

SE050/README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# wolfSSL NXP SE050 Examples
2+
3+
wolfSSL includes support for the NXP SE050 Plug & Trust Secure Element. For
4+
details about the NXP SE050, see [NXP's SE050 page](https://www.nxp.com/products/security-and-authentication/authentication/edgelock-se050-plug-trust-secure-element-family-enhanced-iot-security-with-maximum-flexibility:SE050).
5+
6+
This directory contains wolfSSL examples for NXP SE050. The examples have been
7+
written for and tested on a Raspberry Pi with NXP SE050 EdgeLock development
8+
kit.
9+
10+
For complete details on wolfSSL's support for NXP SE050, see
11+
[README_SE050.md](https://www.github.com/wolfssl/wolfssl/wolfcrypt/src/port/nxp/README_SE050.md).
12+
That document also describes how to download, build, and compile the SE05x
13+
Middleware. It should be followed first before moving on to installing and
14+
running these examples.
15+
16+
## Installing Example Applications
17+
18+
These instructions assume that the SE050 middleware has already been installed
19+
in Raspbian and is located at `/home/pi/se_mw/simw-top`.
20+
21+
Before building these demo, the "wolfssl" folder which contains these demos
22+
should be copied into the SE05x middleware source tree at:
23+
24+
```
25+
/home/pi/se_mw/simw-top/demos/wolfssl
26+
```
27+
28+
This will mean the wolfSSL demo applications will be at:
29+
30+
```
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
35+
```
36+
37+
The 'wolfssl' demo directory needs to be tied into the CMake build system. Open
38+
the following file:
39+
40+
```
41+
/home/pi/se_mw/simw-top/demos/CMakeLists.txt
42+
```
43+
44+
Add the following at the bottom of this file:
45+
46+
```
47+
ADD_SUBDIRECTORY(wolfssl)
48+
```
49+
50+
If the SE05x middleware has not yet been set up for compilation:
51+
52+
```
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
56+
$ ccmake .
57+
< adjust options to match SE050 dev kit >
58+
< 'c', to configure >
59+
< 'g', to generate >
60+
$ cmake --build .
61+
```
62+
63+
This will build the SE05x middleware along with demos, including the wolfCrypt
64+
test application.
65+
66+
**IMPORTANT:** Note that the wolfCrypt test and benchmark application examples
67+
included here need benchmark.c, benchmark.h, test.c, and test.h copied over
68+
from a valid wolfSSL source tree. See notes in those example README.md files
69+
for more information.
70+
71+
## NXP SE050 EdgeLock Configuration
72+
73+
wolfSSL most recently tested these examples on a Raspberry Pi with NXP
74+
EdgeLock development kit. The following CMake options were used. This uses
75+
OpenSSL as the HostCrypto Provider and enables SCP03 authentication.
76+
77+
![CMake Configuration](images/se05x_middleware_cmake_openssl_scp03.png)
78+
79+
## Example Applications
80+
81+
### wolfCrypt Test Application
82+
83+
This application will run the wolfCrypt test application, running cryptography
84+
test vectors through all algorithms enabled in wolfSSL. For details, see
85+
[README.md](./wolfssl/wolfcrypt_test/README.md).
86+
87+
### wolfCrypt Benchmark Application
88+
89+
This application will run the wolfCrypt benchmark application, benchmarking
90+
all enabled algorithms in wolfSSL. For details, see
91+
[README.md](./wolfssl/wolfcrypt_benchmark/README.md).
92+
93+
### wolfCrypt SE050 Key and Certificate Insertion and Use Example
94+
95+
This example inserts and uses certificates and keys into the SE050. It does an
96+
ECDSA verify operation of an ASCII-encoded {R,S} signature, reads back out the
97+
RSA and ECC certificates imported and verifies they match the original ones,
98+
then erases keys and certificates that were imported into the SE050. For
99+
details, see [README.md](./wolfssl/wolfcrypt_key_cert_insert/README.md).
100+
101+
### wolfCrypt CSR Generation Example
102+
103+
This example generates a Certificate Signing Request (CSR) using a key
104+
generated and stored in the SE050. This examples requires that wolfSSL be
105+
compiled with `--enable-certgen --enable-certreq`. For details, see
106+
[README.md](./wolfssl/wolfcrypt_generate_csr/README.md).
107+
108+
## Support
109+
110+
For support questions and issues, please email wolfSSL at support@wolfssl.com.
111+
190 KB
Loading

SE050/wolfssl/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ADD_SUBDIRECTORY(wolfcrypt_benchmark)
2+
ADD_SUBDIRECTORY(wolfcrypt_test)
3+
ADD_SUBDIRECTORY(wolfcrypt_key_cert_insert)
4+
ADD_SUBDIRECTORY(wolfcrypt_generate_csr)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
PROJECT(wolfcrypt_benchmark)
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_WOLFCRYPTBENCHMARK NO_MAIN_DRIVER BENCH_EMBEDDED 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: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# wolfCrypt Benchmark Demo Application
2+
3+
This demo application runs the wolfCrypt benchmark app. It benchmarks all
4+
algorithms enabled in wolfCrypt. It has been tested using a Raspberry Pi
5+
and SE050 EdgeLock development kit.
6+
7+
## Building the Demo
8+
9+
Before building this demo, follow initial setup instructions in the parent
10+
[README.md](../../README.md).
11+
12+
**IMPORTANT:** This example requires the benchmark.c and benchmark.h files from
13+
a wolfSSL source package be copied into this directory before compiling and
14+
running the example. There are stub files included in this example directory
15+
that should be overwritten:
16+
17+
```
18+
$ cp wolfssl-X.X.X/wolfcrypt/benchmark/benchmark.c ./
19+
$ cp wolfssl-X.X.X/wolfcrypt/benchmark/benchmark.h ./
20+
```
21+
22+
Once this example directory has been copied into the SE05x middleware directory
23+
tree in the correct location, compiling the middleware will also compile this
24+
demo application:
25+
26+
```
27+
$ cd /home/pi/se_mw/simw-top_build/raspbian_native_se050_t1oi2c
28+
$ cmake --build .
29+
```
30+
31+
## Running the Demo
32+
33+
To run the demo:
34+
35+
```
36+
$ cd /home/pi/se_mw/simw-top_build/raspbian_native_se050_t1oi2c/bin
37+
$ ./wolfcrypt_benchmark
38+
```
39+
40+
On successful run, output similar to the following will print out:
41+
42+
```
43+
App :INFO :PlugAndTrust_v04.02.00_20220524
44+
App :INFO :Running ./wolfcrypt_benchmark
45+
App :INFO :If you want to over-ride the selection, use ENV=EX_SSS_BOOT_SSS_PORT or pass in command line arguments.
46+
sss :INFO :atr (Len=35)
47+
00 A0 00 00 03 96 04 03 E8 00 FE 02 0B 03 E8 08
48+
01 00 00 00 00 64 00 00 0A 4A 43 4F 50 34 20 41
49+
54 50 4F
50+
sss :WARN :Communication channel is Plain.
51+
sss :WARN :!!!Not recommended for production use.!!!
52+
App :INFO :running setconfig
53+
App :INFO :Ran setconfig successfully
54+
wolfCrypt Benchmark (block bytes 1024, min 1.0 sec each)
55+
RNG 12 MiB took 1.001 seconds, 11.928 MiB/s
56+
AES-128-CBC-enc 20 MiB took 1.000 seconds, 19.724 MiB/s
57+
AES-128-CBC-dec 19 MiB took 1.001 seconds, 19.438 MiB/s
58+
AES-192-CBC-enc 17 MiB took 1.001 seconds, 16.982 MiB/s
59+
AES-192-CBC-dec 17 MiB took 1.001 seconds, 16.612 MiB/s
60+
AES-256-CBC-enc 15 MiB took 1.001 seconds, 14.755 MiB/s
61+
AES-256-CBC-dec 15 MiB took 1.001 seconds, 14.580 MiB/s
62+
AES-128-GCM-enc 10 MiB took 1.002 seconds, 9.967 MiB/s
63+
AES-128-GCM-dec 10 MiB took 1.002 seconds, 9.965 MiB/s
64+
AES-192-GCM-enc 9 MiB took 1.002 seconds, 9.208 MiB/s
65+
AES-192-GCM-dec 9 MiB took 1.000 seconds, 9.202 MiB/s
66+
AES-256-GCM-enc 8 MiB took 1.001 seconds, 8.492 MiB/s
67+
AES-256-GCM-dec 8 MiB took 1.000 seconds, 8.495 MiB/s
68+
AES-128-GCM-enc-no_AAD 10 MiB took 1.001 seconds, 9.975 MiB/s
69+
AES-128-GCM-dec-no_AAD 10 MiB took 1.002 seconds, 10.035 MiB/s
70+
AES-192-GCM-enc-no_AAD 9 MiB took 1.001 seconds, 9.269 MiB/s
71+
AES-192-GCM-dec-no_AAD 9 MiB took 1.002 seconds, 9.262 MiB/s
72+
AES-256-GCM-enc-no_AAD 9 MiB took 1.002 seconds, 8.554 MiB/s
73+
AES-256-GCM-dec-no_AAD 9 MiB took 1.003 seconds, 8.545 MiB/s
74+
GMAC Table 4-bit 22 MiB took 1.000 seconds, 21.581 MiB/s
75+
AES-128-ECB-enc 15 MiB took 1.000 seconds, 14.996 MiB/s
76+
AES-128-ECB-dec 15 MiB took 1.000 seconds, 14.983 MiB/s
77+
AES-192-ECB-enc 13 MiB took 1.000 seconds, 13.356 MiB/s
78+
AES-192-ECB-dec 13 MiB took 1.000 seconds, 13.240 MiB/s
79+
AES-256-ECB-enc 12 MiB took 1.000 seconds, 11.929 MiB/s
80+
AES-256-ECB-dec 12 MiB took 1.000 seconds, 11.921 MiB/s
81+
CHACHA 38 MiB took 1.000 seconds, 37.518 MiB/s
82+
CHA-POLY 26 MiB took 1.000 seconds, 26.211 MiB/s
83+
MD5 129 MiB took 1.000 seconds, 129.068 MiB/s
84+
POLY1305 118 MiB took 1.000 seconds, 118.446 MiB/s
85+
SHA 66 MiB took 1.000 seconds, 66.223 MiB/s
86+
SHA-256 31 MiB took 1.001 seconds, 31.328 MiB/s
87+
SHA-384 16 MiB took 1.000 seconds, 15.918 MiB/s
88+
SHA-512 16 MiB took 1.000 seconds, 15.914 MiB/s
89+
HMAC-MD5 127 MiB took 1.000 seconds, 126.965 MiB/s
90+
HMAC-SHA 65 MiB took 1.000 seconds, 65.453 MiB/s
91+
HMAC-SHA256 31 MiB took 1.001 seconds, 30.983 MiB/s
92+
HMAC-SHA384 16 MiB took 1.000 seconds, 15.551 MiB/s
93+
HMAC-SHA512 16 MiB took 1.001 seconds, 15.653 MiB/s
94+
PBKDF2 4 KiB took 1.002 seconds, 3.618 KiB/s
95+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
96+
sss :WARN :Could not delete Key id FFFF
97+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
98+
sss :WARN :Could not delete Key id 10000
99+
RSA 1024 key gen 2 ops took 1.377 sec, avg 688.364 ms, 1.453 ops/sec
100+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
101+
sss :WARN :Could not delete Key id 10001
102+
RSA 2048 key gen 1 ops took 7.441 sec, avg 7440.538 ms, 0.134 ops/sec
103+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
104+
sss :WARN :Could not delete Key id 10002
105+
RSA 2048 public 10 ops took 1.133 sec, avg 113.271 ms, 8.828 ops/sec
106+
RSA 2048 private 6 ops took 1.278 sec, avg 212.942 ms, 4.696 ops/sec
107+
DH 2048 key gen 46 ops took 1.002 sec, avg 21.780 ms, 45.915 ops/sec
108+
DH 2048 agree 22 ops took 1.027 sec, avg 46.693 ms, 21.416 ops/sec
109+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
110+
sss :WARN :Could not delete Key id 10003
111+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
112+
sss :WARN :Could not delete Key id 10004
113+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
114+
sss :WARN :Could not delete Key id 10005
115+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
116+
sss :WARN :Could not delete Key id 10006
117+
ECC [ SECP256R1] 256 key gen 4 ops took 1.149 sec, avg 287.259 ms, 3.481 ops/sec
118+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
119+
sss :WARN :Could not delete Key id 10007
120+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
121+
sss :WARN :Could not delete Key id 10008
122+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
123+
sss :WARN :Could not delete Key id 10009
124+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
125+
sss :WARN :Could not delete Key id 1000A
126+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
127+
sss :WARN :Could not delete Key id 1000B
128+
sss :WARN :nxEnsure:'ret == SM_OK' failed. At Line:6971 Function:sss_se05x_TXn
129+
sss :WARN :Could not delete Key id 1000C
130+
ECDHE [ SECP256R1] 256 agree 4 ops took 1.710 sec, avg 427.612 ms, 2.339 ops/sec
131+
ECDSA [ SECP256R1] 256 sign 10 ops took 1.010 sec, avg 100.953 ms, 9.906 ops/sec
132+
ECDSA [ SECP256R1] 256 verify 10 ops took 1.010 sec, avg 100.998 ms, 9.901 ops/sec
133+
Benchmark complete
134+
```
135+
136+
## Demo Notes
137+
138+
The `benchmark.c` and `benchmark.h` file in this directory have been copied
139+
directly from the wolfSSL download directory, at:
140+
141+
```
142+
wolfssl-X.X.X/wolfcrypt/benchmark/benchmark.c
143+
wolfssl-X.X.X/wolfcrypt/benchmark/benchmark.h
144+
```
145+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* benchmark.c
2+
*
3+
* Copyright (C) 2006-2022 wolfSSL Inc.
4+
*
5+
* This file is part of wolfSSL.
6+
*
7+
* wolfSSL is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfSSL is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+
*/
21+
22+
#error "Overwrite this file with wolfcrypt/benchmark/benchmark.c from wolfSSL"
23+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* benchmark.h
2+
*
3+
* Copyright (C) 2006-2022 wolfSSL Inc.
4+
*
5+
* This file is part of wolfSSL.
6+
*
7+
* wolfSSL is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfSSL is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+
*/
21+
22+
#error "Overwrite this file with wolfcrypt/benchmark/benchmark.h from wolfSSL"
23+

0 commit comments

Comments
 (0)