You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Put the .isr_vector section in `ISR_VECTOR`, all flash sections in `APPLI_region_ROM` and all RAM sections in `APPLI_region_RAM`.
82
85
83
86
To your SECTIONS, add the following:
84
87
@@ -164,7 +167,7 @@ void SystemInit(void)
164
167
165
168
```
166
169
167
-
5. Generating your projects encryption and signing keys.
170
+
5. Generating your project's encryption and signing keys and machine.txt file.
168
171
169
172
Use the make_keys.bat script under Scripts to call a Python tool to generate the AES encryption key (firmware confidentiality) and the ECDSA public verification and private signing keys (firmware authenticity). Example on Windows systems to place keys in a Keys directory:
170
173
@@ -178,11 +181,13 @@ Making ..\..\App\Project\DemoApp\DISCO-F769I\STM32CubeIDE\Keys/Signing_PrivKey_E
178
181
179
182
Run `make_keys <path to directory to contain key files>`
180
183
181
-
If youre not using Windows, then all you need to do is look inside make_keys.bat and run the Python scripts directly. The Keys directory is referenced by the postbuild.sh post-build command line in the IDE. This directory can be anywhere and called anything by adjusting the post-build command line.
184
+
If you're not using Windows, then all you need to do is look inside make_keys.bat and run the Python scripts directly. The Keys directory is referenced by the postbuild.sh post-build command line in the IDE. This directory can be anywhere and called anything by adjusting the post-build command line.
185
+
186
+
Ensure there is a file called `machine.txt` in the `Keys` dir. Add one line to it: `V7M` for all targets unless you're using a cortex-M0, then add `V6M` instead. `make_keys.bat` may have already created this file.
182
187
183
188
**Important Note**
184
189
185
-
These keys are also used by the bootloader to differentiate between compatible firmware loads! That is, the stm32-secure-patching-bootloader will attempt to update to any firmware that is presented that can be successfully decrypted and signature verified. There is no product ID field in the header. The keys are the product ID. Of course, the point of having this type of security is to prevent loading of firmware except for those loads you explicitly authorize by way of signing during the build (automatically done by postbuild.bat). But if you are running multiple products or even incompatible hardware revisions within the same product line, you must ensure to have unique keys setup for each STM32CubeIDE build project (the path to the keys is specified in the postbuild.sh post-build command line and in these examples is called Keys).
190
+
These keys are also used by the bootloader to differentiate between compatible firmware loads! That is, the stm32-secure-patching-bootloader will attempt to update to any firmware that is presented that can be successfully decrypted and signature verified. There is no 'product ID' field in the header. The keys are the product ID. Of course, the point of having this type of security is to prevent loading of firmware except for those loads you explicitly authorize by way of signing during the build (automatically done by postbuild.bat). But if you are running multiple products or even incompatible hardware revisions within the same product line, you must ensure to have unique keys setup for each STM32CubeIDE build project (the path to the keys is specified in the postbuild.sh post-build command line and in these examples is called Keys).
186
191
187
192
188
193
**That's it.** There is a bit to do here, but all things considered it is pretty minimal and your application sources and build procedure is virtually untouched by the addition of the stm32-secure-patching-bootloader.
@@ -210,9 +215,9 @@ Update binaries are for distribution to customers or to your apps and cloud serv
210
215
2. Secured in-field firmware full update file: `DemoApp_NUCLEO-L073RZ_v1.0.0.sfb` (full image)
211
216
3. Secured in-field firmware patch update file: `DemoApp_NUCLEO-L073RZ_v1.0.0_v1.1.0.sfbp` (patch - produced only if reference version v1.0.0 exists in `Binary\PatchRef`)
212
217
213
-
Note: the `<version>` appended to the file names is a direct copy of either the post-build command-line's to version, or else of the output of git decribe tags always dirty if the to version is in auto mode 0.0.0 or 0. When using the auto mode (recommended), use git tagging to set the version. A semantic version tag may be prepended with a v or not. Firmware Modules projects like to prepend versions with a v, so a tag might be v1.3.1. Either way works.
218
+
Note: the `<version>` appended to the file names is a direct copy of either the post-build command-line's 'to' version, or else of the output of `git decribe --tags --always --dirty` if the 'to' version is in auto mode '0.0.0' or '0'. When using the auto mode (recommended), use git tagging to set the version. A semantic version tag may be prepended with a 'v' or not. Firmware Modules projects like to prepend versions with a 'v', so a tag might be 'v1.3.1'. Either way works.
214
219
215
-
Also note: the firmware image header contains a 4-byte field for version and therefore cannot directly accommodate a non-semantic version such as v1.3.1-7-gc32667a that may arise during development load testing. The version generator embedded into the postbuild.sh script can safely handle this scenario by adding the number of commits since value to the build number, so v1.3.1-7 becomes 1.3.8 in the header.
220
+
Also note: the firmware image header contains a 4-byte field for version and therefore cannot directly accommodate a non-semantic version such as v1.3.1-7-gc32667a that may arise during development load testing. The version generator embedded into the postbuild.sh script can safely handle this scenario by adding the *number of commits since* value to the build number, so v1.3.1-7 becomes 1.3.8 in the header.
216
221
217
222
### Notes
218
223
@@ -232,10 +237,10 @@ Also note: the firmware image header contains a 4-byte field for version and the
232
237
233
238
* The stm32-secure-patching-bootloader strikes a balance between ease of integration, broad platform support and selection of security features that are enabled.
234
239
235
-
* The bootloader system is designed so that your products and firmware update files can be distributed into uncontrolled environments. This means firmware confidentiality is ensured through AES encryption, and firmware and device integrity are ensured through ECDSA (digital signatures). The AES encryption and the ECDSA public verification keys are stored in your devices internal flash. The AES encryption and ECDSA private signing key are typically stored in your firmware development repository (e.g. on GitHub, your developers and build PCs).
240
+
* The bootloader system is designed so that your products and firmware update files can be distributed into uncontrolled environments. This means firmware confidentiality is ensured through AES encryption, and firmware and device integrity are ensured through ECDSA (digital signatures). The AES encryption and the ECDSA public verification keys are stored in your device's internal flash. The AES encryption and ECDSA private signing key are typically stored in your firmware development repository (e.g. on GitHub, your developer's and build PCs).
236
241
237
242
* Those that would attempt to undermine your products and solutions know that these keys exist. Thus, protection of these keys is paramount. You must create a root of trust on each of the devices you deploy by way of enabling RDP Level 2 through the stm32-secure-patching-bootloader production build (you get this build when you register the bootloader at firmwaremodules.com). This build will automatically check and enable RDP Level 2 on each boot to help mitigate potential RDP regression attack vectors (yes these do exist). Note that when RDP Level 2 is enabled, you permanently forfeit the ability to connect a debugger to your devices (a good thing when security is concerned).
238
243
239
-
* The bootloader system is not designed to protect your device and secrets from your own firmware application. If you dont trust your application or the way it works (e.g. you think it might offer a way for an attacker to read out contents of memory) then this bootloader system is not for you, or at least you must be aware that internal protections such as proprietary readout protection (PCROP) or firewalls are not implemented. These are by no means foolproof even when enabled. Dont offer a command-line interface that has memory peek and poke commands.
244
+
* The bootloader system is not designed to protect your device and secrets from your own firmware application. If you don't trust your application or the way it works (e.g. you think it might offer a way for an attacker to read out contents of memory) then this bootloader system is not for you, or at least you must be aware that internal protections such as proprietary readout protection (PCROP) or firewalls are not implemented. These are by no means foolproof even when enabled. Don't offer a command-line interface that has memory peek and poke commands.
240
245
241
-
* Finally, you should assume that if an attacker has physical access to your device and is determined enough (time and resources) then your secrets will eventually be extracted. You need to weigh the expense and effort someone (or some group) would go to obtain your firmware update AES encryption key and public signature verification key, and the payoff that may be associated with that effort.
246
+
* Finally, you should assume that if an attacker has physical access to your device and is determined enough (time and resources) then your secrets will eventually be extracted. You need to weigh the expense and effort someone (or some group) would go to obtain your firmware update AES encryption key and public signature verification key, and the 'payoff' that may be associated with that effort.
0 commit comments