Skip to content

Commit 0c81eb4

Browse files
umbynosubidefeo
andcommitted
Apply suggestions from code review
Co-authored-by: Ubi de Feo <me@ubidefeo.com>
1 parent 2a220eb commit 0c81eb4

File tree

1 file changed

+13
-11
lines changed
  • content/hardware/04.pro/boards/portenta-h7/tutorials/secure-boot

1 file changed

+13
-11
lines changed

content/hardware/04.pro/boards/portenta-h7/tutorials/secure-boot/secure-boot.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 'Secure Boot'
2+
title: 'Secure Boot on Portenta H7'
33
description: 'Learn how to use secure boot on the Arduino Portenta H7.'
44
tags:
55
- Secure Boot
@@ -14,7 +14,7 @@ software:
1414
---
1515

1616
## Introduction
17-
This short tutorial will teach how to enable the secure boot on the Portenta H7, how to generate custom security keys, and how you can use them with MCUBoot bootloader.
17+
This short tutorial will guide the user through enabling the secure boot on the Portenta H7, generating custom security keys, and using them with the MCUboot bootloader.
1818

1919
## Hardware & Software Required
2020
- [Portenta H7](https://store.arduino.cc/portenta-h7)
@@ -25,16 +25,16 @@ This short tutorial will teach how to enable the secure boot on the Portenta H7,
2525
## Instructions
2626

2727
### Flashing the Latest Bootloader
28-
In order to have secureboot enabled you have to update the bootloader and use [MCUBoot](https://www.mcuboot.com/). You can find more info on how to perform the update in [this other tutorial](../por-ard-bl/content.md).
28+
In order to have secure boot enabled you must update the bootloader on your Portenta H7 and use [MCUboot](https://www.mcuboot.com/). You can find more info on how to perform the update in [this other tutorial](../por-ard-bl/content.md).
2929

3030
### Use Default Security Keys
31-
Once The bootloader has been updated to MCUBoot, it's possible to use [secure boot](https://www.keyfactor.com/blog/what-is-secure-boot-its-where-iot-security-starts/) to have an addition layer of security. From now on it's required to upload a compiled sketch with the Custom Board Option **"Security settings"** set to **"Signature + Encryption"** (the option can be found under **Tools > Security settings** in the IDE when selecting Portenta H7 as board, or you can use `--board-options security=sien` if using the Arduino CLI). Otherwise the board will not start the compiled sketch because is not trusted.
31+
Once The bootloader has been updated to MCUboot, it's possible to use [secure boot](https://www.keyfactor.com/blog/what-is-secure-boot-its-where-iot-security-starts/) to have an additional layer of security. From that point on it is required to upload a compiled sketch with the Custom Board Option **"Security settings"** set to **"Signature + Encryption"** (the option can be found under **Tools > Security settings** in the IDE when selecting Portenta H7 as board, or you can use `--board-options security=sien` if using the Arduino CLI). Failing to provide such option will cause the bootloader not to run the compiled sketch because it is not trusted.
3232

3333
If no operation is performed the default security keys are used.
34-
They are embedded in the example sketch `STM32H747_updateBootloader` that can be found in **Files > Examples > STM32H747_System > STM32H747_updateBootloader**. A private 256bit [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm) key is used for the encryption (`ecdsa-p256-encrypt-key.h`), while a public key is used for the signing (`ecdsa-p256-signing-key.h`). These two keys are the ones the bootloader uses to verify if a sketch is valid or not, before starting it. The default private keys used after compiling a sketch to sign and encrypt it, are located in `Arduino15/packages/arduino/hardware/mbed_portenta/<version>/libraries/MCUboot/default_keys/`.
34+
These keys are embedded in the example sketch `STM32H747_updateBootloader` which can be found in **Files > Examples > STM32H747_System > STM32H747_updateBootloader**. A private 256bit [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm) key is used for the encryption (`ecdsa-p256-encrypt-key.h`), while a public key is used for the signing (`ecdsa-p256-signing-key.h`). These two keys are the ones the bootloader uses to verify if a sketch is valid or not, before starting it for the first time. The default private keys used after compiling a sketch to sign and encrypt it are located in `Arduino15/packages/arduino/hardware/mbed_portenta/<version>/libraries/MCUboot/default_keys/`.
3535

3636
### 1. Generate Custom Cecurity Keys
37-
The default keys that comes with the mbed platform are obviously only intended for development purposes. In a production environment it's suggested to generate a new key pair (public and private key).
37+
The default keys provided with the mbed platform are obviously only intended for development purposes. In a production environment it is advised to generate a new key pair (public and private key).
3838
This can be done with [**imgtool**](https://github.com/arduino/imgtool-packing/releases/latest). You can download and install it directly from the release section.
3939

4040
***Pro tip: imgtool is already installed by the mbed platform and can be found in the `Arduino15/packages/arduino/tools/imgtool` directory.***
@@ -46,7 +46,7 @@ imgtool keygen --key my-encrypt-keyfile.pem -t ecdsa-p256
4646
```
4747
This command line will generate two private PEM encoded security keys and save them in the current directory with `my-sign-keyfile.pem`and `my-encrypt-keyfile.pem` names. The algorithm used to generate the keys is ECDSA 256bit.
4848

49-
Remember to **save the keys in a secure place** and don't loose them.
49+
Remember to **save the keys to a secure location** and not to lose them.
5050

5151
### 2. Upload the Custom Keys to the Board
5252
Once the keys have been generated they have to be uploaded on the Portenta. This procedure has to be done only once, because it's persistent. To extract the public\private key and encode it in to a "C" byte array inside a `.h` header file you can use:
@@ -55,16 +55,18 @@ imgtool getpriv -k my-encrypt-keyfile.pem > ecsda-p256-encrypt-key.h
5555
imgtool getpub -k my-sign-keyfile.pem > ecsda-p256-signing-key.h
5656
```
5757

58-
Now you have to replace the keys in the sketch to update the bootloader(**STM32H747_updateBootloader**).
58+
Now you have to replace the keys inside the Sketch to update the bootloader(**STM32H747_updateBootloader**).
5959
To do so just save the sketch to another location and replace the `ecsda-p256-encrypt-key.h` and `ecsda-p256-signing-key.h` files with the newly generated ones and then [update the bootloader](../por-ard-bl/content.md) again.
6060

61-
### 3. Use the Custom Keys when Compiling
62-
Since the default keys have been changed in favour of newly generated custom ones, The new ones have to be used when compiling and uploading a sketch, because the compiled sketch is signed and encrypted with them.
61+
***NOTE: In case the keys are compromised, this process can be performed again with a new set of keys, but any firmware signed with the previous pair will no longer work.***
62+
63+
### 3. Use the Custom Keys when Compiling
64+
Since the default keys have been changed in favour of custom generated ones, the new ones have to be used when compiling and uploading a sketch, because the compiled sketch is signed and encrypted using such keys.
6365

6466
To override the security keys used during the compile you have to use the Arduino CLI and specify the keys with:
6567
```
6668
arduino-cli compile -b arduino:mbed_portenta:envie_m7 --board-options security=sien --keys-keychain <path-to-your-keys> --sign-key ecsdsa-p256-signing-key.pem --encrypt-key ecsdsa-p256-encrypt-key.pem /home/user/Arduino/MySketch
6769
```
6870

6971
## Learn More
70-
If you want to implement secure boot for your platform [this](https://arduino.github.io/arduino-cli/latest/guides/secure-boot/) should be helpful .
72+
If you want to implement secure boot for your platform [this](https://arduino.github.io/arduino-cli/latest/guides/secure-boot/) should be helpful.

0 commit comments

Comments
 (0)