Skip to content

Commit 06f4beb

Browse files
umbynosper1234
andcommitted
Apply suggestions from code review
Co-authored-by: per1234 <accounts@perglass.com>
1 parent 2ed7002 commit 06f4beb

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

docs/guides/secure-boot.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
### Secure Boot
22

3-
Some boards supports the secure boot. Basically the compiled sketch can be signed and encrypted with a
4-
[tool](../platform-specification.md#tools) before being flashed to the target board. The bootloader of the board is then
5-
responsible for starting the compiled sketch if the matching keys are used.
3+
A "secure boot" capability may be offered by Arduino boards platforms.
4+
5+
The compiled sketch is signed and encrypted by a [tool](../platform-specification.md#tools) before being flashed to the
6+
target board. The bootloader of the board is then responsible for starting the compiled sketch only if the matching keys
7+
are used.
68

79
To be able to correctly carry out all the operations at the end of the build we can leverage the
810
[post build hooks](../platform-specification.md#pre-and-post-build-hooks-since-arduino-ide-165) to sign and encrypt a
911
binary by using `recipe.hooks.objcopy.postobjcopy.NUMBER.pattern` key in
10-
[`platform.txt`](../platform-specification.md#platformtxt). The security keys used are defined in the boards file, this
11-
way there could be different keys for different boards.
12+
[`platform.txt`](../platform-specification.md#platformtxt). The security keys used are defined in the
13+
[`boards.txt`](../platform-specification.md#boardstxt) file, this way there could be different keys for different
14+
boards.
1215

1316
```
1417
[...]
15-
## Create output secure image (bin file)
18+
## Create secure image (bin file)
1619
recipe.hooks.objcopy.postobjcopy.1.pattern={build.postbuild.cmd}
20+
1721
#
1822
# IMGTOOL
1923
#
20-
2124
tools.imgtool.cmd=imgtool
2225
tools.imgtool.build.pattern=sign --key "{build.keys.keychain}/{build.keys.sign_key}" --encrypt "{build.keys.keychain}/{build.keys.encrypt_key}" "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.bin" --align {build.alignment} --max-align {build.alignment} --version {build.version} --header-size {build.header_size} --pad-header --slot-size {build.slot_size}
2326
[...]
@@ -38,17 +41,15 @@ envie_m7.menu.security.sien=Signature + Encryption
3841
envie_m7.menu.security.sien.build.postbuild.cmd="{tools.imgtool.cmd}" {tools.imgtool.build.pattern}
3942
envie_m7.menu.security.none.build.postbuild.cmd="{tools.imgtool.cmd}" exit
4043
41-
envie_m7.menu.security.sien.build.keys.type=public_keys
4244
envie_m7.menu.security.sien.build.keys.keychain={runtime.hardware.path}/Default_Keys
4345
envie_m7.menu.security.sien.build.keys.sign_key=default-signing-key.pem
4446
envie_m7.menu.security.sien.build.keys.encrypt_key=default-encrypt-key.pem
4547
[...]
4648
```
4749

48-
Currently we support the secure boot only with `build.keys.type=public_keys` but in the future other ways can be added.
4950
The security keys can be added with:
5051

51-
- `keys.keychain` indicates the path of the dir where to search for the custom keys to sign and encrypt a binary.
52-
- `keys.sign_key` indicates the name of the custom signing key to use to sign a binary during the compile process.
53-
- `keys.encrypt_key` indicates the name of the custom encryption key to use to encrypt a binary during the compile
52+
- `build.keys.keychain` indicates the path of the dir where to search for the custom keys to sign and encrypt a binary.
53+
- `build.keys.sign_key` indicates the name of the custom signing key to use to sign a binary during the compile process.
54+
- `build.keys.encrypt_key` indicates the name of the custom encryption key to use to encrypt a binary during the compile
5455
process.

docs/platform-specification.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ the name of the architecture is set as well.
155155

156156
There are some other **{build.xxx}** properties available, that are explained in the boards.txt section of this guide.
157157

158-
Some of them allows to specify trusted security credentials (sign and encryption keys) that can be used for the secure
159-
boot:
158+
Some of them allow specifying trusted security credentials (signing and encryption keys) that can be used by a
159+
["secure boot" system](guides/secure-boot.md):
160160

161161
- `build.keys.keychain`: for the directory containing the keys
162162
- `build.keys.sign_key`: for the signing key

legacy/builder/setup_build_properties.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,10 @@ func (s *SetupBuildProperties) Run(ctx *types.Context) error {
127127

128128
buildProperties.Merge(ctx.PackageManager.CustomGlobalProperties)
129129

130-
if !buildProperties.ContainsKey("build.keys.type") {
131-
buildProperties.Set("build.keys.type", "public_keys") // The default is "pubblic_keys" for now
132-
}
133130
keychainProp := buildProperties.ContainsKey("build.keys.keychain")
134131
signProp := buildProperties.ContainsKey("build.keys.sign_key")
135132
encryptProp := buildProperties.ContainsKey("build.keys.encrypt_key")
136-
// we verify that all the properties for the secure boot keys are defined or nono of them is defined.
133+
// we verify that all the properties for the secure boot keys are defined or none of them is defined.
137134
if !(keychainProp || signProp || encryptProp) && (keychainProp && signProp && encryptProp) {
138135
return errors.Errorf("%s core does not specify correctly default sign and encryption keys", ctx.BuildCore)
139136
}

test/testdata/platform_with_secure_boot/boards.local.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ uno.menu.security.sien=Signature + Encryption
66
uno.menu.security.sien.build.postbuild.cmd="{tools.imgtool.cmd}" {tools.imgtool.build.pattern}
77
uno.menu.security.none.build.postbuild.cmd="{tools.imgtool.cmd}" exit
88

9-
uno.menu.security.sien.build.keys.type=public_keys
109
uno.menu.security.sien.build.keys.keychain={runtime.hardware.path}/Default_Keys
1110
uno.menu.security.sien.build.keys.sign_key=default-signing-key.pem
1211
uno.menu.security.sien.build.keys.encrypt_key=default-encrypt-key.pem

0 commit comments

Comments
 (0)