Skip to content

Commit 15b6bdd

Browse files
ankk-cssying-cssrestyled-commits
authored
Support for Hardware Secure Module (HSM) using Infineon OPTIGA Trust M (project-chip#32771) (project-chip#32905)
* 1)Added Crypto Function provided by Infineon HSM OPTIGA Trust M * Fix Lint code base error and remove unnecessary comments. * Restyled by whitespace * Apply restyled changes. * - Tidy up the code and the printouts. - Updated the trustm_Open() to add init settings. * - Clear the trustm_isOpen flag when trustm_close() is called. * Apply restyled patch * 1)Updated README.md * Restyled by prettier-markdown * 1)Tidy Up the code --------- Co-authored-by: ying-css <71699179+ying-css@users.noreply.github.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 5bb5c9e commit 15b6bdd

33 files changed

+4689
-9
lines changed

.github/.wordlist.txt

+5
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,8 @@ HomePods
643643
hostapd
644644
hostname
645645
href
646+
HSM
647+
hsm
646648
HTTPS
647649
HW
648650
hwadr
@@ -964,6 +966,7 @@ objcopy
964966
OccupancySensing
965967
OctetString
966968
OECORE
969+
OID
967970
ol
968971
Onboarding
969972
onboardingcodes
@@ -985,6 +988,7 @@ openweave
985988
OperationalCredentials
986989
operationalDataset
987990
opkg
991+
OPTIGA
988992
optionMask
989993
optionOverride
990994
optionsMask
@@ -1428,6 +1432,7 @@ transitionTime
14281432
TransportMgrBase
14291433
TriggerEffect
14301434
TRNG
1435+
trustm
14311436
TrustedRootCertificates
14321437
tsan
14331438
TSG

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,9 @@
324324
path = third_party/infineon/psoc6/psoc6_sdk/libs/lwip-network-interface-integration
325325
url = https://github.com/Infineon/lwip-network-interface-integration.git
326326
platforms = infineon
327+
[submodule "third_party/infineon/trustm/optiga-trust-m"]
328+
path = third_party/infineon/trustm/optiga-trust-m
329+
url = https://github.com/Infineon/optiga-trust-m.git
330+
branch = matter_support
331+
platforms = infineon
332+

docs/guides/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [ASR - Getting Started Guide](./asr_getting_started_guide.md)
88
- [Espressif (ESP32) - Getting Started Guide](./esp32/README.md)
99
- [Infineon PSoC6 - Software Update](./infineon_psoc6_software_update.md)
10+
- [Infineon Trust M Provisioning](./infineon_trustm_provisioning.md)
1011
- [Linux - Simulated Devices](./simulated_device_linux.md)
1112
- [mbedOS - Adding a new target](./mbedos_add_new_target.md)
1213
- [mbedOS - Commissioning](./mbedos_commissioning.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Infineon OPTIGA&trade; Trust M Provisioning for Matter
2+
3+
To use Infineon OPTIGA&trade; Trust M for device attestation, Provisioning for
4+
OPTIGA&trade; Trust M with Matter test device Attestation certificate is needed.
5+
6+
## Hardware setup:
7+
8+
[Raspberry Pi 4](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/)
9+
10+
[OPTIGA™ Trust M MTR](https://www.infineon.com/cms/en/product/evaluation-boards/trust-m-mtr-shield/)
11+
12+
[Shield2Go Adapter for Raspberry Pi](https://www.infineon.com/cms/en/product/evaluation-boards/s2go-adapter-rasp-pi-iot/)
13+
or Jumping Wire
14+
15+
## Provisioning for OPTIGA&trade; Trust M
16+
17+
The
18+
[Linux Tools for OPTIGA&trade; Trust M ](https://github.com/Infineon/linux-optiga-trust-m)
19+
can be used to perform provisioning by following the steps mentioned below.
20+
21+
- Set up chip-tool on Raspberry Pi 4 by following the instruction listed at
22+
[Building chip-tool on Raspberry Pi ](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/BUILDING.md#installing-prerequisites-on-raspberry-pi-4)
23+
- Clone the repo from Infineon Public GitHub
24+
25+
```
26+
$ git clone --recurse-submodules https://github.com/Infineon/linux-optiga-trust-m.git
27+
```
28+
29+
- Build the Linux tools for OPTIGA&trade; Trust M
30+
31+
```
32+
$ cd linux-optiga-trust-m/
33+
$ ./trustm_installation_aarch64_script.sh
34+
```
35+
36+
- Run the script to generate Matter test DAC for lock-app using the public key
37+
extracted from the Infineon pre-provisioned Certificate and store it into
38+
0xE0E0
39+
40+
```
41+
$ cd scripts/matter_provisioning/
42+
$ ./matter_dac_provisioning.sh
43+
```
44+
45+
_Note:_
46+
47+
_By running this example matter_dac_provisioning.sh, the steps shown below are
48+
executed:_
49+
50+
_Step1: Extract the public key from the Infineon pre-provisioned
51+
Certificate(0xE0E0) using openssl command._
52+
53+
_Step2: Generate DAC test certificate using the extracted public key, Signed by
54+
[Matter test PAI](https://github.com/project-chip/connectedhomeip/blob/v1.1-branch/credentials/development/attestation/Matter-Development-PAI-FFF1-noPID-Cert.pem)_.
55+
Please note that production devices cannot re-use these test keys/certificates.
56+
57+
_Step3: Write DAC test certificate into OPTIGA&trade; Trust M certificate slot
58+
0xE0E0_
59+
60+
\_Step4: Write Matter test PAI into OPTIGA&trade; Trust M certificate slot
61+
0xE0E8 and test CD into OPTIGA&trade; Trust M Arbitrary OID 0xF1E0.

examples/lock-app/infineon/psoc6/BUILD.gn

+16-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
import("//build_overrides/build.gni")
1616
import("//build_overrides/chip.gni")
1717
import("//build_overrides/psoc6.gni")
18-
1918
import("${build_root}/config/defaults.gni")
19+
import("${chip_root}/src/crypto/crypto.gni")
20+
import("${chip_root}/src/platform/Infineon/crypto/infineon_crypto.gni")
2021
import("${chip_root}/src/platform/device.gni")
22+
import("${chip_root}/third_party/infineon/trustm/trustm_config.gni")
2123
import("${psoc6_sdk_build_root}/psoc6_executable.gni")
2224
import("${psoc6_sdk_build_root}/psoc6_sdk.gni")
2325

@@ -117,6 +119,19 @@ psoc6_executable("lock_app") {
117119
"${psoc6_project_dir}/include",
118120
]
119121

122+
if (chip_crypto == "platform") {
123+
include_dirs += [ "${chip_root}/third_party/infineon/trustm" ]
124+
include_dirs += [ "${chip_root}/examples/platform/infineon/trustm" ]
125+
include_dirs += [ "${chip_root}/src/platform/Infineon/crypto/trustm" ]
126+
127+
defines = [ "ENABLE_DEVICE_ATTESTATION=1" ]
128+
129+
public_deps += [
130+
"${chip_root}/src/platform/Infineon/crypto/${infineon_crypto_impl}:infineon_crypto_lib",
131+
"${chip_root}/third_party/infineon/trustm:optiga-trust-m",
132+
]
133+
}
134+
120135
sources = [
121136
"${examples_plat_dir}/LEDWidget.cpp",
122137
"${examples_plat_dir}/init_psoc6Platform.cpp",

examples/lock-app/infineon/psoc6/README.md

+48-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ An example showing the use of Matter on the Infineon CY8CKIT-062S2-43012 board.
1414
- [Notes](#notes)
1515
- [Cluster control](#cluster-control)
1616
- [Factory Reset](#factory-reset)
17+
- [Building with Optiga Trust M as HSM](#building-with-optiga-trust-m-as-hsm)
18+
- [Optiga Trust M Provisioning](#optiga-trust-m-provisioning)
1719
- [OTA Software Update](#ota-software-update)
1820

1921
<hr>
@@ -55,6 +57,11 @@ will then join the network.
5557
$ cd ~/connectedhomeip
5658
$ rm -rf out/
5759

60+
_To build with Infineon Hardware Security Module-OPTIGA™ Trust M for Device
61+
attestation and other security use cases, please refer to the
62+
[Building with OPTIGA™ Trust M as HSM](#building-with-optiga-trust-m-as-hsm) for
63+
more instructions_
64+
5865
## Flashing the Application
5966

6067
- Put CY8CKIT-062S2-43012 board on KitProg3 CMSIS-DAP Mode by pressing the
@@ -128,10 +135,50 @@ commands. These power cycle the BlueTooth hardware and disable BR/EDR mode.
128135
on the board. All the data configured on the device during the initial
129136
commissioning will be deleted and device will be ready for commissioning
130137
again.
131-
132138
- Pressing the button again within 5 seconds will cancel the factory reset of
133139
the board.
134140

141+
## Building with Optiga Trust M as HSM
142+
143+
Infineon Hardware Security Module-OPTIGA™ Trust M is a high-end security
144+
solution that provides an anchor of trust for connecting IoT devices to the
145+
cloud, giving every IoT device its own unique identity.
146+
147+
- Supported hardware setup:
148+
[CY8CKIT-062S2-43012](https://www.cypress.com/CY8CKIT-062S2-43012)
149+
150+
[OPTIGA™ Trust M MTR](https://www.infineon.com/cms/en/product/evaluation-boards/trust-m-mtr-shield/)
151+
152+
[OPTIGA™ Trust Adapter](https://www.infineon.com/cms/en/product/evaluation-boards/optiga-trust-adapter/)
153+
154+
- Building:
155+
156+
Follow the steps to build with OPTIGA™ Trust M for device attestation use
157+
case:
158+
159+
```
160+
$ source scripts/activate.sh
161+
$ scripts/build/build_examples.py --no-log-timestamps --target 'infineon-psoc6-lock-trustm' build
162+
```
163+
164+
- To delete generated executable, libraries and object files use:
165+
166+
$ cd ~/connectedhomeip
167+
$ rm -rf out/
168+
169+
- Proceed to OPTIGA™ Trust M Provisioning section to complete the credential
170+
storage into HSM.
171+
172+
### Optiga Trust M Provisioning
173+
174+
For the description of OPTIGA™ Trust M Provisioning with test DAC generation and
175+
PAI and CD storage, please refer to
176+
[Infineon OPTIGA™ Trust M Provisioning](../../../../docs/guides/infineon_trustm_provisioning.md)
177+
178+
After completing OPTIGA™ Trust M Provisioning, proceed to
179+
[Flashing the Application](#flashing-the-application) section to continue with
180+
subsequent steps.
181+
135182
## OTA Software Update
136183
137184
For the description of Software Update process with infineon PSoC6 example

examples/lock-app/infineon/psoc6/args.gni

+3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
import("//build_overrides/chip.gni")
1616
import("//build_overrides/pigweed.gni")
1717
import("${chip_root}/config/standalone/args.gni")
18+
import("${chip_root}/src/crypto/crypto.gni")
1819
import("${chip_root}/src/platform/Infineon/PSOC6/args.gni")
1920

2021
psoc6_target_project =
2122
get_label_info(":lock_app_sdk_sources", "label_no_toolchain")
23+
24+
import("${chip_root}/src/platform/Infineon/crypto/trustm/args.gni")

examples/lock-app/infineon/psoc6/src/AppTask.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
#include <app/clusters/door-lock-server/door-lock-server.h>
4646
#include <app/clusters/identify-server/identify-server.h>
4747

48+
#if ENABLE_DEVICE_ATTESTATION
49+
#include <DeviceAttestationCredsExampleTrustM.h>
50+
#endif
51+
4852
/* OTA related includes */
4953
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
5054
#include <app/clusters/ota-requestor/BDXDownloader.h>
@@ -157,7 +161,12 @@ static void InitServer(intptr_t context)
157161
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);
158162

159163
// Initialize device attestation config
164+
#if ENABLE_DEVICE_ATTESTATION
165+
SetDeviceAttestationCredentialsProvider(Examples::GetExampleTrustMDACProvider());
166+
#else
160167
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
168+
#endif
169+
161170
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
162171
GetAppTask().InitOTARequestor();
163172
#endif

scripts/build/build/targets.py

+1
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ def BuildInfineonTarget():
409409
# modifiers
410410
target.AppendModifier('ota', enable_ota_requestor=True)
411411
target.AppendModifier('updateimage', update_image=True)
412+
target.AppendModifier('trustm', enable_trustm=True)
412413

413414
return target
414415

scripts/build/builders/infineon.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def __init__(self,
8080
app: InfineonApp = InfineonApp.LOCK,
8181
board: InfineonBoard = InfineonBoard.PSOC6BOARD,
8282
enable_ota_requestor: bool = False,
83-
update_image: bool = False):
83+
update_image: bool = False,
84+
enable_trustm: bool = False):
8485
super(InfineonBuilder, self).__init__(
8586
root=app.BuildRoot(root),
8687
runner=runner)
@@ -92,6 +93,10 @@ def __init__(self,
9293
self.extra_gn_options.append('chip_enable_ota_requestor=true')
9394
if update_image:
9495
self.extra_gn_options.append('build_update_image=true')
96+
if enable_trustm:
97+
self.extra_gn_options.append('chip_crypto=\"platform\"')
98+
if enable_trustm is False:
99+
self.extra_gn_options.append('chip_crypto=\"mbedtls\"')
95100

96101
def GnBuildArgs(self):
97102
return self.extra_gn_options

scripts/build/testdata/all_targets_linux_x64.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ linux-fake-tests[-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-ossfuz
1313
linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,thermostat,java-matter-controller,kotlin-matter-controller,minmdns,light,lock,shell,ota-provider,ota-requestor,simulated-app1,simulated-app2,python-bindings,tv-app,tv-casting-app,bridge,tests,chip-cert,address-resolve-tool,contact-sensor,dishwasher,microwave-oven,refrigerator,rvc,air-purifier,lit-icd,air-quality-sensor,network-manager,energy-management}[-nodeps][-nlfaultinject][-platform-mdns][-minmdns-verbose][-libnl][-same-event-loop][-no-interactive][-ipv6only][-no-ble][-no-wifi][-no-thread][-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-ossfuzz][-coverage][-dmalloc][-clang][-test][-rpc][-with-ui][-evse-test-event]
1414
linux-x64-efr32-test-runner[-clang]
1515
imx-{chip-tool,lighting-app,thermostat,all-clusters-app,all-clusters-minimal-app,ota-provider-app}[-release]
16-
infineon-psoc6-{lock,light,all-clusters,all-clusters-minimal}[-ota][-updateimage]
16+
infineon-psoc6-{lock,light,all-clusters,all-clusters-minimal}[-ota][-updateimage][-trustm]
1717
rw61x-{all-clusters-app,thermostat,laundry-washer}[-ota][-wifi][-thread][-factory-data][-matter-shell]
1818
k32w-{k32w0,k32w1}-{light,shell,lock,contact}[-se05x][-no-ble][-no-ota][-low-power][-nologs][-crypto-platform][-tokenizer][-openthread-ftd]
1919
mbed-cy8cproto_062_4343w-{lock,light,all-clusters,all-clusters-minimal,pigweed,ota-requestor,shell}[-release][-develop][-debug]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
declare_args() {
16+
infineon_crypto_impl = ""
17+
infineon_crypto_root = ""
18+
}
19+
assert(infineon_crypto_impl != "", "infineon_crypto_impl should be defined")
20+
assert(infineon_crypto_root != "", "infineon_crypto_root should be defined")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/chip.gni")
16+
import("//build_overrides/nlassert.gni")
17+
import("${chip_root}/build/chip/buildconfig_header.gni")
18+
import("${chip_root}/src/crypto/crypto.gni")
19+
import("${chip_root}/src/platform/Infineon/crypto/trustm/args.gni")
20+
21+
if (chip_crypto == "platform") {
22+
import("//build_overrides/mbedtls.gni")
23+
}
24+
25+
source_set("public_headers") {
26+
sources = []
27+
28+
public_deps = [
29+
"${chip_root}/src/crypto",
30+
"${chip_root}/src/lib/asn1",
31+
"${chip_root}/src/lib/core",
32+
"${chip_root}/src/lib/support",
33+
"${nlassert_root}:nlassert",
34+
]
35+
}
36+
37+
static_library("infineon_crypto_lib") {
38+
sources = [
39+
"CHIPCryptoPALHost.cpp",
40+
"CHIPCryptoPALHsm_HKDF_trustm.cpp",
41+
"CHIPCryptoPALHsm_HMAC_trustm.cpp",
42+
"CHIPCryptoPALHsm_P256_trustm.cpp",
43+
"CHIPCryptoPALHsm_rng_trustm.cpp",
44+
"CHIPCryptoPALHsm_utils_trustm.cpp",
45+
"CHIPCryptoPAL_HostFallBack.cpp",
46+
"DeviceAttestationCredsExampleTrustM.cpp",
47+
]
48+
49+
public_deps = [ ":public_headers" ]
50+
public_configs = []
51+
public_deps += [ "${chip_root}/third_party/infineon/trustm:optiga-trust-m" ]
52+
public_configs += [ "${chip_root}/third_party/infineon/trustm:trustm_config" ]
53+
deps = [ "${chip_root}/${infineon_crypto_root}:optiga-trust-m" ]
54+
external_mbedtls = current_os == "zephyr"
55+
56+
if (!external_mbedtls) {
57+
public_deps += [ "${mbedtls_root}:mbedtls" ]
58+
}
59+
include_dirs = [
60+
".",
61+
"${chip_root}/src/crypto",
62+
"${chip_root}/src/platform/Infineon/crypto/trustm",
63+
]
64+
}

0 commit comments

Comments
 (0)