Skip to content

Commit b2bd92a

Browse files
Migrate to the new simpler demo from FreeRTOS upstream and use mbedTLS V4
1 parent fc234d2 commit b2bd92a

87 files changed

Lines changed: 3645 additions & 22907 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.doc/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ actions but are otherwise not accessible. The following GitHub Secrets need to b
99

1010
GitHub Secret | Enables *AWS IoT Thing* Connection
1111
:------------------------------|:---------------------------------------
12+
`IOT_THING_NAME` | Client (device) name
13+
`MQTT_BROKER_ENDPOINT` | MQTT broker host name
14+
`ROOT_CA_PEM` | Server (host) root CA certificate
1215
`CLIENT_CERTIFICATE_PEM` | Client (device) certificate
1316
`CLIENT_PRIVATE_KEY_PEM` | Client (device) private key
14-
`IOT_THING_NAME` | Client (device) name
15-
`MQTT_BROKER_ENDPOINT` | MQTT broker host name
1617

1718
## Format of GitHub Secrets
1819

@@ -22,6 +23,7 @@ GitHub Secret name | Original or issued format | Github Se
2223
:------------------------------|:------------------------------------|:---------------------------------------
2324
`IOT_THING_NAME` | Single line string without quotes | Single line string without quotes i.e. `myIoT_thing_name`
2425
`MQTT_BROKER_ENDPOINT` | Single line string without quotes | Single line string without quotes i.e. `random-string.abcd.xyz.amazonaws.com`
26+
`ROOT_CA_PEM` | Multiline string. See **F1**. | Single line string with double quotes and additional new-lines. See **F2**.
2527
`CLIENT_CERTIFICATE_PEM` | Multiline string. See **F1**. | Single line string with double quotes and additional new-lines. See **F2**.
2628
`CLIENT_PRIVATE_KEY_PEM` | Multiline string. See **F3**. | Single line string with double quotes and additional new-lines. See **F4**.
2729

@@ -38,7 +40,7 @@ GitHub Secret name | Original or issued format | Github Se
3840
**F2**: The expected Certificate format must be a double-quoted singleline string. i.e.
3941

4042
```txt
41-
"-----BEGIN CERTIFICATE-----\n\::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::==\n-----END CERTIFICATE-----\n"
43+
"-----BEGIN CERTIFICATE-----\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::==\n-----END CERTIFICATE-----\n"
4244
```
4345

4446
**F3**: The issued Private Key format is a multiline string like:
@@ -53,5 +55,5 @@ GitHub Secret name | Original or issued format | Github Se
5355
**F4**: The expected Private Key format must be a double-quoted singleline string. i.e.
5456

5557
```txt
56-
"-----BEGIN RSA PRIVATE KEY-----\n\::::::::::::::::::::::::::::::::::::::::::::::\n-----END RSA PRIVATE KEY-----\n"
58+
"-----BEGIN RSA PRIVATE KEY-----\n::::::::::::::::::::::::::::::::::::::::::::::\n-----END RSA PRIVATE KEY-----\n"
5759
```

.github/workflows/AWS_MQTT-ci.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,31 @@ jobs:
4343
- name: Configure AWS IoT Thing Credentials
4444
env:
4545
# Get the secrets from the Github
46-
MQTT_BROKER_ENDPOINT: ${{ secrets.MQTT_BROKER_ENDPOINT }}
4746
IOT_THING_NAME: ${{ secrets.IOT_THING_NAME }}
47+
MQTT_BROKER_ENDPOINT: ${{ secrets.MQTT_BROKER_ENDPOINT }}
48+
ROOT_CA_PEM: ${{ secrets.ROOT_CA_PEM }}
4849
CLIENT_CERTIFICATE_PEM: ${{ secrets.CLIENT_CERTIFICATE_PEM }}
4950
CLIENT_PRIVATE_KEY_PEM: ${{ secrets.CLIENT_PRIVATE_KEY_PEM }}
5051

5152
run: |
52-
pushd amazon-freertos/demos/include/
53-
# Add the Client-Certificate Client-Private-Key in aws_clientcredential_keys.h
54-
cp aws_clientcredential_keys.h aws_clientcredential_keys.h.in
55-
sed -i 's|\(#define keyCLIENT_CERTIFICATE_PEM \).*NULL|\1 ${CLIENT_CERTIFICATE_PEM}|' aws_clientcredential_keys.h.in
56-
sed -i 's|\(#define keyCLIENT_PRIVATE_KEY_PEM \).*NULL|\1 ${CLIENT_PRIVATE_KEY_PEM}|' aws_clientcredential_keys.h.in
57-
envsubst < aws_clientcredential_keys.h.in > aws_clientcredential_keys.h
53+
DEMO_CONFIG="FreeRTOS-Plus/Demo/Config/demo_config.h"
54+
55+
cp "$DEMO_CONFIG" "${DEMO_CONFIG}.in"
56+
57+
# Activate the define by replacing the placeholder with the actual value.
58+
activate_define() {
59+
local define_name="$1"
60+
local define_value="$2"
61+
sed -i "/^[[:space:]]*\* #define ${define_name}/{N;s|^[[:space:]]*\* #define .*\n[[:space:]]*\*/| */\n#define ${define_name} ${define_value}|;}" "${DEMO_CONFIG}.in"
62+
}
5863
59-
# Add the Client-Credentials in aws_clientcredential.h
60-
cp aws_clientcredential.h aws_clientcredential.h.in
61-
sed -i 's|\(#define clientcredentialMQTT_BROKER_ENDPOINT \).*""|\1 "${MQTT_BROKER_ENDPOINT}"|' aws_clientcredential.h.in
62-
sed -i 's|\(#define clientcredentialIOT_THING_NAME \).*""|\1 "${IOT_THING_NAME}"|' aws_clientcredential.h.in
63-
envsubst < aws_clientcredential.h.in > aws_clientcredential.h
64+
activate_define democonfigCLIENT_IDENTIFIER '"${IOT_THING_NAME}"'
65+
activate_define democonfigMQTT_BROKER_ENDPOINT '"${MQTT_BROKER_ENDPOINT}"'
66+
activate_define democonfigROOT_CA_PEM '${ROOT_CA_PEM}'
67+
activate_define democonfigCLIENT_CERTIFICATE_PEM '${CLIENT_CERTIFICATE_PEM}'
68+
activate_define democonfigCLIENT_PRIVATE_KEY_PEM '${CLIENT_PRIVATE_KEY_PEM}'
6469
65-
popd
70+
envsubst < "${DEMO_CONFIG}.in" > "$DEMO_CONFIG"
6671
6772
# Build the executable
6873
- name: Build executable
@@ -91,7 +96,7 @@ jobs:
9196
- name: Analyze results
9297
run: |
9398
echo "Checking if a MQTT packet has been received"
94-
if [ "$(grep -c "\[iot_thread\] \[INFO\] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess." ./out/Demo/AWS_MQTT_Demo.log)" -eq 0 ]
99+
if [ "$(grep -c "Incoming Publish Message : Hello World!" ./out/Demo/AWS_MQTT_Demo.log)" -eq 0 ]
95100
then
96101
exit 1
97102
else

Demo.cproject.yml

Lines changed: 31 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
project:
22
packs:
33
- pack: ARM::CMSIS@^6.1.0
4-
- pack: ARM::CMSIS-FreeRTOS@^11.1.0
5-
- pack: ARM::CMSIS-Compiler@^2.1.0
6-
- pack: ARM::CMSIS-View@^1.2.0
7-
- pack: ARM::mbedTLS@1.7.0
8-
- pack: AWS::backoffAlgorithm@^4.1.1
9-
- pack: AWS::coreMQTT@^4.0.0
10-
- pack: AWS::coreMQTT_Agent@^4.0.0
11-
- pack: AWS::corePKCS11@^4.0.1
12-
- pack: AWS::FreeRTOS-Plus-TCP@^5.0.0
13-
- pack: Arm-Packs::PKCS11@^1.0.0
4+
- pack: ARM::CMSIS-FreeRTOS@^11.2.0
5+
- pack: ARM::mbedTLS@^4.0.0
6+
- pack: AWS::backoffAlgorithm@^4.1.0
7+
- pack: AWS::coreMQTT@^5.0.0
148
- pack: MDK-Packs::IoT_Socket@^1.4.0
159

1610
connections:
@@ -23,21 +17,14 @@ project:
2317
- STDOUT
2418
- Heap: 65536
2519

20+
define:
21+
- MBEDTLS_CONFIG_FILE: \"app_mbedtls_config.h\"
22+
- TF_PSA_CRYPTO_CONFIG_FILE: \"app_crypto_config.h\"
23+
2624
add-path:
27-
- ./config_files
28-
- ./amazon-freertos/demos/include
29-
- ./amazon-freertos/demos/network_manager
30-
- ./amazon-freertos/demos/common/pkcs11_helpers
31-
- ./amazon-freertos/libraries/3rdparty/mbedtls_config
32-
- ./amazon-freertos/libraries/logging/include
33-
- ./amazon-freertos/libraries/abstractions/platform/include
34-
- ./amazon-freertos/libraries/abstractions/platform/freertos/include
35-
- ./amazon-freertos/libraries/abstractions/secure_sockets/include
36-
- ./amazon-freertos/libraries/abstractions/transport/secure_sockets
37-
- ./amazon-freertos/libraries/c_sdk/standard/common/include
38-
- ./amazon-freertos/libraries/c_sdk/standard/common/include/private
39-
- ./amazon-freertos/libraries/freertos_plus/standard/crypto/include
40-
- ./amazon-freertos/libraries/freertos_plus/standard/tls/include
25+
- FreeRTOS-Plus/Source/Utilities/logging
26+
- FreeRTOS-Plus/Source/Application-Protocols/network_transport
27+
- FreeRTOS-Plus/Source/Application-Protocols/network_transport/tcp_sockets_wrapper/include
4128

4229
components:
4330
- component: ARM::CMSIS:OS Tick:SysTick
@@ -46,81 +33,34 @@ project:
4633
- component: ARM::RTOS&FreeRTOS:Config&CMSIS RTOS2
4734
- component: ARM::RTOS&FreeRTOS:Core&Cortex-M
4835
- component: ARM::RTOS&FreeRTOS:Event Groups
49-
- component: ARM::RTOS&FreeRTOS:Heap&Heap_5
36+
- component: ARM::RTOS&FreeRTOS:Heap&Heap_4
5037
- component: ARM::RTOS&FreeRTOS:Stream Buffer
5138
- component: ARM::RTOS&FreeRTOS:Timers
5239

5340
- component: ARM::Security:mbed TLS
54-
define:
55-
- MBEDTLS_CONFIG_FILE: \"aws_mbedtls_config.h\"
5641

5742
- component: AWS::FreeRTOS:backoffAlgorithm
5843
- component: AWS::FreeRTOS:coreMQTT
59-
- component: AWS::FreeRTOS:coreMQTT Agent
60-
61-
- component: AWS::FreeRTOS:corePKCS11:Core Library
62-
- component: AWS::FreeRTOS:corePKCS11:Portable Abstraction Layer&Custom
63-
- component: AWS::FreeRTOS:corePKCS11:Utilities
64-
- component: AWS::Security:PKCS11:corePKCS11
65-
define:
66-
- MBEDTLS_CONFIG_FILE: \"aws_mbedtls_config.h\"
6744

6845
groups:
6946
- group: Documentation
7047
files:
71-
- file: ./README.md
72-
- group: main
73-
files:
74-
- file: ./app_main.c
75-
- group: config_files
48+
- file: README.md
49+
- group: Main
7650
files:
77-
- file: ./config_files/aws_demo_config.h
78-
- file: ./config_files/aws_iot_network_config.h
79-
- file: ./config_files/aws_mbedtls_config.h
80-
- file: ./config_files/core_mqtt_config.h
81-
- file: ./config_files/core_pkcs11_config.h
82-
- file: ./config_files/iot_config.h
83-
- file: ./config_files/iot_secure_sockets_config.h
84-
- file: ./config_files/mqtt_demo_mutual_auth_config.h
85-
- group: demos_include
51+
- file: FreeRTOS-Plus/Demo/app_main.c
52+
- file: FreeRTOS-Plus/Demo/MutualAuthMQTTExample.c
53+
- group: Config
8654
files:
87-
- file: ./amazon-freertos/demos/include/aws_clientcredential.h
88-
- file: ./amazon-freertos/demos/include/aws_clientcredential_keys.h
89-
- file: ./amazon-freertos/demos/include/aws_demo.h
90-
- file: ./amazon-freertos/demos/include/aws_iot_metrics.h
91-
- file: ./amazon-freertos/demos/include/iot_config_common.h
92-
- file: ./amazon-freertos/demos/include/iot_demo_logging.h
93-
- file: ./amazon-freertos/demos/include/iot_demo_runner.h
94-
- group: demos
55+
- file: FreeRTOS-Plus/Demo/Config/demo_config.h
56+
- file: FreeRTOS-Plus/Demo/Config/core_mqtt_config.h
57+
- file: FreeRTOS-Plus/Demo/Config/app_mbedtls_config.h
58+
- file: FreeRTOS-Plus/Demo/Config/app_crypto_config.h
59+
- group: Network Transport
9560
files:
96-
- file: ./amazon-freertos/demos/demo_runner/iot_demo_runner.c
97-
- file: ./amazon-freertos/demos/demo_runner/iot_demo_freertos.c
98-
- file: ./amazon-freertos/demos/coreMQTT/mqtt_demo_mutual_auth.c
99-
- file: ./amazon-freertos/demos/network_manager/aws_iot_network_manager.c
100-
- file: ./amazon-freertos/demos/common/pkcs11_helpers/pkcs11_helpers.c
101-
- group: libraries
102-
define:
103-
- MBEDTLS_CONFIG_FILE: \"aws_mbedtls_config.h\"
104-
files:
105-
- file: ./amazon-freertos/libraries/c_sdk/standard/common/iot_device_metrics.c
106-
- file: ./amazon-freertos/libraries/c_sdk/standard/common/iot_init.c
107-
- file: ./amazon-freertos/libraries/c_sdk/standard/common/iot_static_memory_common.c
108-
- file: ./amazon-freertos/libraries/c_sdk/standard/common/taskpool/iot_taskpool.c
109-
- file: ./amazon-freertos/libraries/c_sdk/standard/common/taskpool/iot_taskpool_static_memory.c
110-
- file: ./amazon-freertos/libraries/abstractions/platform/freertos/iot_threads_freertos.c
111-
- file: ./amazon-freertos/libraries/abstractions/platform/freertos/iot_clock_freertos.c
112-
- file: ./amazon-freertos/libraries/abstractions/secure_sockets/iot_socket/iot_secure_sockets.c
113-
- file: ./amazon-freertos/libraries/abstractions/transport/secure_sockets/transport_secure_sockets.c
114-
- file: ./amazon-freertos/libraries/freertos_plus/standard/crypto/src/iot_crypto.c
115-
- file: ./amazon-freertos/libraries/freertos_plus/standard/tls/src/iot_tls.c
116-
- file: ./amazon-freertos/libraries/logging/iot_logging.c
117-
- file: ./amazon-freertos/libraries/logging/iot_logging_task_dynamic_buffers.c
118-
- group: ports
119-
files:
120-
- file: ./amazon-freertos/ports/pkcs11/core_pkcs11_pal.c
121-
- file: ./amazon-freertos/ports/mbedtls/entropy_poll_hw.c
122-
define:
123-
- MBEDTLS_CONFIG_FILE: \"aws_mbedtls_config.h\"
61+
- file: FreeRTOS-Plus/Source/Application-Protocols/network_transport/transport_mbedtls.c
62+
- file: FreeRTOS-Plus/Source/Application-Protocols/network_transport/mbedtls_bio_tcp_sockets_wrapper.c
63+
- file: FreeRTOS-Plus/Source/Application-Protocols/network_transport/tcp_sockets_wrapper/ports/iot_socket/tcp_sockets_wrapper.c
12464

12565
layers:
12666
- layer: $Shield-Layer$
@@ -131,3 +71,9 @@ project:
13171

13272
- layer: $Board-Layer$
13373
type: Board
74+
75+
output:
76+
type:
77+
- elf
78+
- hex
79+
- map

Demo.csolution.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
solution:
22
description: AWS Cloud Connector Example
3-
created-for: CMSIS-Toolbox@2.6.0
3+
created-for: CMSIS-Toolbox@2.13.0
44
cdefault:
55

66
select-compiler:
@@ -11,10 +11,10 @@ solution:
1111

1212
packs:
1313
- pack: ARM::V2M_MPS3_SSE_300_BSP@1.5.0
14-
# Add BSP pack to use a physical board
15-
# - pack: <BSP or DFP>.pack
16-
# Add pack with shield layers to support Arduino WiFi Shields
17-
# - pack: ARM::CMSIS-Driver@2.10.0
14+
# Add BSP pack to use a physical board
15+
# - pack: <BSP or DFP>.pack
16+
# Add pack with shield layers to support Arduino WiFi Shields
17+
# - pack: ARM::CMSIS-Driver@2.10.0
1818

1919
build-types:
2020
- type: Debug
@@ -25,21 +25,20 @@ solution:
2525
optimize: balanced
2626

2727
target-types:
28-
# This target is a AVH-FVP simulation model that does not require hardware
28+
# This target is a AVH-FVP simulation model that does not require hardware
2929
- type: AVH
3030
board: ARM::V2M-MPS3-SSE-300-FVP
3131
variables:
3232
- Board-Layer: $SolutionDir()$/Board/AVH_MPS3_Corstone-300/Board.clayer.yml
3333
- Shield-Layer: ""
3434
- Socket-Layer: $SolutionDir()$/Socket/VSocket/Socket.clayer.yml
35-
36-
# Add a target hardware to use the example on physical hardware
37-
# - type: MyBoard
38-
# board: <board name>
39-
# variables:
40-
# - Board-Layer: ""
41-
# - Shield-Layer: ""
42-
# - Socket-Layer: ""
35+
# Add a target hardware to use the example on physical hardware
36+
# - type: MyBoard
37+
# board: <board name>
38+
# variables:
39+
# - Board-Layer: ""
40+
# - Shield-Layer: ""
41+
# - Socket-Layer: ""
4342

4443
projects:
45-
- project: ./Demo.cproject.yml
44+
- project: Demo.cproject.yml
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* PSA crypto configuration template
3+
*/
4+
/*
5+
* Copyright The Mbed TLS Contributors
6+
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7+
*/
8+
9+
#define TF_PSA_CRYPTO_CONFIG_VERSION 0x01000000
10+
11+
/* Cryptographic mechanism selection (PSA API) */
12+
#define PSA_WANT_ALG_ECDH 1
13+
#define PSA_WANT_ALG_ECDSA 1
14+
#define PSA_WANT_ALG_GCM 1
15+
#define PSA_WANT_ALG_HMAC 1
16+
#define PSA_WANT_ALG_RSA_OAEP 1
17+
#define PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1
18+
#define PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1
19+
#define PSA_WANT_ALG_RSA_PSS 1
20+
#define PSA_WANT_ALG_SHA_1 1
21+
#define PSA_WANT_ALG_SHA_256 1
22+
#define PSA_WANT_ALG_TLS12_PRF 1
23+
#define PSA_WANT_ECC_SECP_R1_256 1
24+
#define PSA_WANT_KEY_TYPE_HMAC 1
25+
#define PSA_WANT_KEY_TYPE_AES 1
26+
#define PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
27+
#define PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1
28+
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC 1
29+
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT 1
30+
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT 1
31+
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE 1
32+
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE 1
33+
#define PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC 1
34+
#define PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT 1
35+
#define PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT 1
36+
37+
/* Platform abstraction layer */
38+
#define MBEDTLS_PLATFORM_C
39+
#define MBEDTLS_SELF_TEST
40+
41+
/* Cryptographic mechanism selection (extended API) */
42+
#define MBEDTLS_MD_C
43+
#define MBEDTLS_PK_C
44+
#define MBEDTLS_PK_PARSE_C
45+
#define MBEDTLS_PK_PARSE_EC_EXTENDED
46+
#define MBEDTLS_PK_PARSE_EC_COMPRESSED
47+
48+
/* Data format support */
49+
#define MBEDTLS_ASN1_PARSE_C
50+
#define MBEDTLS_ASN1_WRITE_C
51+
#define MBEDTLS_BASE64_C
52+
#define MBEDTLS_PEM_PARSE_C
53+
54+
/* PSA core */
55+
#define MBEDTLS_CTR_DRBG_C
56+
#define MBEDTLS_PSA_CRYPTO_C
57+
#define MBEDTLS_PSA_DRIVER_GET_ENTROPY
58+
59+
/* Builtin drivers */
60+
#define MBEDTLS_AES_ROM_TABLES
61+
#define MBEDTLS_ECP_NIST_OPTIM

0 commit comments

Comments
 (0)