Skip to content

Commit 70a9c0e

Browse files
committed
Minor updates
1 parent 45bb14d commit 70a9c0e

File tree

1 file changed

+48
-58
lines changed

1 file changed

+48
-58
lines changed

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

Lines changed: 48 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -141,31 +141,6 @@ After the installation is finished and you've signed back in to your VM, you're
141141

142142
---
143143

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-
169144
## Retrieve provisioning information for your TPM
170145

171146
<!-- 1.1 -->
@@ -192,12 +167,31 @@ In this section, you build a tool that you can use to retrieve the registration
192167
<!-- iotedge-1.4 -->
193168
:::moniker range=">=iotedge-1.4"
194169

195-
In this section, you use the TPM2 software tools to retrieve the endorsement key for your TPM and then generate a unique registration ID. This section corresponds with [Step 3: Device has firmware and software installed](../iot-dps/concepts-device-oem-security-practices.md#step-3-device-has-firmware-and-software-installed) in the process for [integrating a TPM into the manufacturing process](../iot-dps/concepts-device-oem-security-practices.md#integrating-a-tpm-into-the-manufacturing-process).
196-
197170
> [!NOTE]
198171
> 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.
199172
200-
1. Run the script below to read the endorsement key, creating one if it does not already exist.
173+
In this section, you use the TPM2 software tools to retrieve the endorsement key for your TPM and then generate a unique registration ID. This section corresponds with [Step 3: Device has firmware and software installed](../iot-dps/concepts-device-oem-security-practices.md#step-3-device-has-firmware-and-software-installed) in the process for [integrating a TPM into the manufacturing process](../iot-dps/concepts-device-oem-security-practices.md#integrating-a-tpm-into-the-manufacturing-process).
174+
175+
### Install the TPM2 Tools
176+
Sign in to your device, and install the `tpm2-tools` package.
177+
178+
# [Ubuntu / Debian / Raspberry Pi OS](#tab/ubuntu+debian+rpios)
179+
180+
181+
```bash
182+
sudo apt-get install tpm2-tools
183+
```
184+
185+
# [Red Hat Enterprise Linux](#tab/rhel)
186+
187+
188+
```bash
189+
sudo yum install tpm2-tools
190+
```
191+
192+
---
193+
194+
Run the following script to read the endorsement key, creating one if it does not already exist.
201195

202196
```bash
203197
#!/bin/sh
@@ -213,50 +207,46 @@ In this section, you use the TPM2 software tools to retrieve the endorsement key
213207
$SUDO tpm2_readpublic -c 0x81010001 -o ek.pub > /dev/null
214208
$SUDO tpm2_flushcontext -t > /dev/null
215209

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
210+
# Create a storage root key (SRK)
211+
$SUDO tpm2_startauthsession --policy-session -S session.ctx > /dev/null
212+
$SUDO tpm2_policysecret -S session.ctx -c 0x4000000B > /dev/null
213+
$SUDO tpm2_create -C 0x81010001 \
214+
-G rsa2048 \
215+
-a 'restricted|decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth' \
216+
-u srk.pub -r srk.priv \
217+
-P session:session.ctx > /dev/null
218+
$SUDO tpm2_flushcontext --transient-object > /dev/null
219+
220+
# store the key
221+
$SUDO tpm2_startauthsession -S session.ctx --policy-session > /dev/null
222+
$SUDO tpm2_policysecret -S session.ctx -c 0x4000000B > /dev/null
223+
$SUDO tpm2_load -C 0x81010001 \
224+
-u srk.pub -r srk.priv \
225+
-P session:session.ctx \
226+
-c srk.ctx > /dev/null
227+
228+
# make the SRK persistent
229+
$SUDO tpm2_evictcontrol -c srk.ctx 0x81000001 > /dev/null
230+
231+
# clean up
232+
$SUDO rm session.ctx srk.pub srk.priv srk.ctx ek.ctx 2> /dev/null
242233
fi
243234

244235
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)
245236

246237
$SUDO rm ek.pub 2> /dev/null
247238
```
248239

249-
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.
240+
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.
250241

251242
:::moniker-end
252243
<!-- end iotedge-1.4 -->
253244

245+
After you have your registration ID and endorsement key, you're ready to continue.
246+
254247
> [!TIP]
255248
> If you don't want to use the TPM2 software tools to retrieve the information, you need to find another way to obtain the provisioning information. The endorsement key, which is unique to each TPM chip, is obtained from the TPM chip manufacturer associated with it. You can derive a unique registration ID for your TPM device. For example, as shown above you can create an SHA-256 hash of the endorsement key.
256249
257-
258-
After you have your registration ID and endorsement key, you're ready to continue.
259-
260250
<!-- Create an enrollment for your device using TPM provisioning information H2 and content -->
261251
[!INCLUDE [tpm-create-a-device-provision-service-enrollment.md](../../includes/tpm-create-a-device-provision-service-enrollment.md)]
262252

0 commit comments

Comments
 (0)