Skip to content

Commit 45bb14d

Browse files
committed
Recommend X509. Create EK/SRK if not read.
1 parent e09c5ba commit 45bb14d

File tree

3 files changed

+81
-40
lines changed

3 files changed

+81
-40
lines changed

articles/iot-edge/how-to-create-iot-edge-device.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,13 @@ To see more of the features of DPS, see the [Features section of the overview pa
138138

139139
## Choose an authentication method
140140

141-
### Symmetric keys attestation
142-
143-
Symmetric key attestation is a simple approach to authenticating a device. This attestation method represents a "Hello world" experience for developers who are new to device provisioning, or don't have strict security requirements.
144-
145-
When you create a new device identity in IoT Hub, the service creates two keys. You place one of the keys on the device, and it presents the key to IoT Hub when authenticating.
146-
147-
This authentication method is faster to get started but not as secure. Device provisioning using a TPM or X.509 certificates is more secure and should be used for solutions with more stringent security requirements.
148-
149141
### X.509 certificate attestation
150142

151-
Using X.509 certificates as an attestation mechanism is the recommended way to scale production and simplify device provisioning. Typically, X.509 certificates are arranged in a certificate chain of trust. Starting with a self-signed or trusted root certificate, each certificate in the chain signs the next lower certificate. This pattern creates a delegated chain of trust from the root certificate down through each intermediate certificate to the final "leaf" certificate installed on a device.
143+
Using X.509 certificates as an attestation mechanism is the recommended way to scale production and simplify device provisioning. Typically, X.509 certificates are arranged in a certificate chain of trust. Starting with a self-signed or trusted root certificate, each certificate in the chain signs the next lower certificate. This pattern creates a delegated chain of trust from the root certificate down through each intermediate certificate to the final "leaf" certificate installed on a device.
152144

153-
You create two X.509 identity certificates and place them on the device. When you create a new device identity in IoT Hub, you provide thumbprints from both certificates. When the device authenticates to IoT Hub, it presents one certificate and IoT Hub verifies that the certificate matches its thumbprint.
145+
You create two X.509 identity certificates and place them on the device. When you create a new device identity in IoT Hub, you provide thumbprints from both certificates. When the device authenticates to IoT Hub, it presents one certificate and IoT Hub verifies that the certificate matches its thumbprint. The X.509 keys on the device should be stored in a Hardware Security Module (HSM). E.g. PKCS#11 modules, ATECC, dTPM, etc.
154146

155-
This authentication method is more secure than symmetric keys and is recommended for production scenarios.
147+
This authentication method is more secure than symmetric keys and supports group enrollments which provides a simplified management experience for a high number of devices. This authentication method is recommended for production scenarios.
156148

157149
### Trusted platform module (TPM) attestation
158150

@@ -164,6 +156,14 @@ TPM 2.0 is required when you use TPM attestation with the device provisioning se
164156

165157
This authentication method is more secure than symmetric keys and is recommended for production scenarios.
166158

159+
### Symmetric keys attestation
160+
161+
Symmetric key attestation is a simple approach to authenticating a device. This attestation method represents a "Hello world" experience for developers who are new to device provisioning, or don't have strict security requirements.
162+
163+
When you create a new device identity in IoT Hub, the service creates two keys. You place one of the keys on the device, and it presents the key to IoT Hub when authenticating.
164+
165+
This authentication method is faster to get started but not as secure. Device provisioning using a TPM or X.509 certificates is more secure and should be used for solutions with more stringent security requirements.
166+
167167
## Next steps
168168

169169
You can use the table of contents to navigate to the appropriate end-to-end guide for creating an IoT Edge device for your IoT Edge solution's platform, provisioning, and authentication requirements.

articles/iot-edge/how-to-provision-devices-at-scale-linux-tpm.md

Lines changed: 67 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ A physical Linux device to be the IoT Edge device.
5454

5555
If you are a device manufacturer then refer to guidance on [integrating a TPM into the manufacturing process](../iot-dps/concepts-device-oem-security-practices.md#integrating-a-tpm-into-the-manufacturing-process).
5656

57-
This article assumes ownership of the TPM has been taken already and the endorsement key (EK) and storage root key (SRK) have been persisted. Follow the instructions relevant to your system to take ownership.
58-
5957
# [Virtual machine](#tab/virtual-machine)
6058

6159
A Windows development machine with [Hyper-V enabled](/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v). This article uses Windows 10 running an Ubuntu Server VM.
@@ -143,6 +141,31 @@ After the installation is finished and you've signed back in to your VM, you're
143141

144142
---
145143

144+
<!-- iotedge-1.4 -->
145+
:::moniker range=">=iotedge-1.4"
146+
147+
### Install the TPM2 Tools
148+
1. Sign in to your device, and install the `tpm2-tools` package.
149+
150+
# [Ubuntu / Debian / Raspberry Pi OS](#tab/ubuntu+debian+rpios)
151+
152+
153+
```bash
154+
sudo apt-get install tpm2-tools
155+
```
156+
157+
# [Red Hat Enterprise Linux](#tab/rhel)
158+
159+
160+
```bash
161+
sudo yum install tpm2-tools
162+
```
163+
164+
---
165+
166+
:::moniker-end
167+
<!-- end 1.4 -->
168+
146169
## Retrieve provisioning information for your TPM
147170

148171
<!-- 1.1 -->
@@ -174,42 +197,57 @@ In this section, you use the TPM2 software tools to retrieve the endorsement key
174197
> [!NOTE]
175198
> This article previously used the `tpm_device_provision` tool from the IoT C SDK to generate provisioning info. If you relied on that tool previously, then be aware the steps below generate a different registration ID for the same public endorsement key. If you need to recreate the registration ID as before then refer to how the C SDK's [tpm_device_provision tool](https://github.com/Azure/azure-iot-sdk-c/tree/main/provisioning_client/tools/tpm_device_provision) generates it. Be sure the registration ID for the individual enrollment in DPS matches the regisration ID the IoT Edge device is configured to use.
176199
177-
# [Ubuntu / Debian / Raspberry Pi OS](#tab/ubuntu+debian+rpios)
178-
179-
1. Sign in to your device, and install the `tpm2-tools` package.
200+
1. Run the script below to read the endorsement key, creating one if it does not already exist.
180201

181202
```bash
182-
sudo apt-get install tpm2-tools
183-
```
184-
185-
1. Run the following commands to read the endorsement key in your TPM and generate a unique registration ID. This assumes the endorsement key is at the default location of 0x81010001.
203+
#!/bin/sh
204+
if [ "$USER" != "root" ]; then
205+
SUDO="sudo "
206+
fi
207+
208+
$SUDO tpm2_readpublic -Q -c 0x81010001 -o ek.pub 2> /dev/null
209+
if [ $? -gt 0 ]; then
210+
# Create the endorsement key (EK)
211+
$SUDO tpm2_createek -c ek.ctx > /dev/null
212+
$SUDO tpm2_evictcontrol -c ek.ctx 0x81010001 > /dev/null
213+
$SUDO tpm2_readpublic -c 0x81010001 -o ek.pub > /dev/null
214+
$SUDO tpm2_flushcontext -t > /dev/null
215+
216+
$SUDO tpm2_getcap handles-persistent >/dev/null | grep 0x81000001 > /dev/null
217+
if [ $? -gt 0 ]; then
218+
# Create a storage root key (SRK)
219+
$SUDO tpm2_startauthsession --policy-session -S session.ctx > /dev/null
220+
$SUDO tpm2_policysecret -S session.ctx -c 0x4000000B > /dev/null
221+
$SUDO tpm2_create -C 0x81010001 \
222+
-G rsa2048 \
223+
-a 'restricted|decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth' \
224+
-u srk.pub -r srk.priv \
225+
-P session:session.ctx > /dev/null
226+
$SUDO tpm2_flushcontext --transient-object > /dev/null
227+
228+
# store the key
229+
$SUDO tpm2_startauthsession -S session.ctx --policy-session > /dev/null
230+
$SUDO tpm2_policysecret -S session.ctx -c 0x4000000B > /dev/null
231+
$SUDO tpm2_load -C 0x81010001 \
232+
-u srk.pub -r srk.priv \
233+
-P session:session.ctx \
234+
-c srk.ctx > /dev/null
235+
236+
# make the SRK persistent
237+
$SUDO tpm2_evictcontrol -c srk.ctx 0x81000001 > /dev/null
238+
239+
# clean up
240+
$SUDO rm session.ctx srk.pub srk.priv srk.ctx ek.ctx 2> /dev/null
241+
fi
242+
fi
186243

187-
```bash
188-
tpm2_readpublic -Q -c 0x81010001 -o ek.pub
189244
printf "Gathering the registration information...\n\nRegistration Id:\n%s\n\nEndorsement Key:\n%s\n" $(sha256sum -b ek.pub | cut -d' ' -f1 | sed -e 's/[^[:alnum:]]//g') $(base64 -w0 ek.pub)
190-
```
191-
192-
1. The output window displays the device's **Endorsement key** and a unique **Registration ID**. Copy these values for use later when you create an individual enrollment for your device in the device provisioning service.
193-
194-
# [Red Hat Enterprise Linux](#tab/rhel)
195245

196-
1. Sign in to your device, and install the `tpm2-tools` package.
197-
198-
```bash
199-
sudo yum install tpm2-tools
200-
```
201-
202-
1. Run the following commands to read the endorsement key in your TPM and generate a unique registration ID. This assumes the endorsement key is at the default location of 0x81010001.
203-
204-
```bash
205-
tpm2_readpublic -Q -c 0x81010001 -o ek.pub
206-
printf "Gathering the registration information...\n\nRegistration Id:\n%s\n\nEndorsement Key:\n%s\n" $(sha256sum -b ek.pub | cut -d' ' -f1 | sed -e 's/[^[:alnum:]]//g') $(base64 -w0 ek.pub)
246+
$SUDO rm ek.pub 2> /dev/null
207247
```
208248

209249
1. The output window displays the device's **Endorsement key** and a unique **Registration ID**. Copy these values for use later when you create an individual enrollment for your device in the device provisioning service.
210250
211-
---
212-
213251
:::moniker-end
214252
<!-- end iotedge-1.4 -->
215253

articles/iot-edge/how-to-provision-devices-at-scale-linux-x509.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ The tasks are as follows:
2424

2525
Using X.509 certificates as an attestation mechanism is an excellent way to scale production and simplify device provisioning. Typically, X.509 certificates are arranged in a certificate chain of trust. Starting with a self-signed or trusted root certificate, each certificate in the chain signs the next lower certificate. This pattern creates a delegated chain of trust from the root certificate down through each intermediate certificate to the final "leaf" certificate installed on a device.
2626

27+
> [!TIP]
28+
> If your device has a Hardware Security Module (HSM) such as a TPM 2.0, then we recommend storing the X.509 keys securely in the HSM. Learn more about how to implement the zero-touch provisioning at scale described in [this blueprint](https://azure.microsoft.com/en-us/blog/the-blueprint-to-securely-solve-the-elusive-zerotouch-provisioning-of-iot-devices-at-scale) with the [https://aka.ms/iotedge-tpm2cloud](https://aka.ms/iotedge-tpm2cloud) sample.
29+
2730
## Prerequisites
2831

2932
<!-- Cloud resources prerequisites H3 and content -->

0 commit comments

Comments
 (0)