Skip to content

Commit abcbdc3

Browse files
committed
Updated documentation (uart remote flash, encrypted partitions)
1 parent b3fad42 commit abcbdc3

3 files changed

Lines changed: 119 additions & 0 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ For detailed information about the configuration options for the target system,
8181

8282
For more detailed information about firmware update implementation, see [Firmware Update](docs/firmware_update.md)
8383

84+
85+
### Additional features
86+
- [Remote external flash interface](docs/remote_flash.md)
87+
- [External encrypted partitions](docs/encrypted_partitions.md)
88+
8489
## Troubleshooting
8590

8691
1. Python errors when signing a key:

docs/encrypted_partitions.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## Encrypted external partitions
2+
3+
wolfBoot offers the possibility to encrypt the content of the entire UPDATE partition,
4+
by using a pre-shared symmetric key which can be temporarily stored in a safer non-volatile memory area.
5+
6+
SWAP partition is also temporarily encrypted using the same key, so a dump of the external flash won't reveal
7+
any content of the firmware update packages.
8+
9+
### Rationale
10+
11+
Encryption of external partition works at the level of the external flash interface.
12+
13+
All write calls to external partitions from the bootloader perform an additional encryption step
14+
to hide the actual content of the external non-volatile memory.
15+
16+
Viceversa, all read operations will decrypt the data stored when the feature is enabled.
17+
18+
An extra option is provided to the `sign.py` sign tool to encrypt the firmware update after signing it, so
19+
that it can be stored as is in the external memory by the application, and will be decrypted by the bootloader
20+
in order to verify the update and begin the installation.
21+
22+
23+
### Temporary key storage
24+
25+
By default, wolfBoot will store the pre-shared symmetric key used for encryption in a temporary area
26+
on the internal flash. This allows read-out protections to be used to hide the temporary key.
27+
28+
Alternatively, more secure mechanisms are available to store the temporary key in a different key storage
29+
(e.g. using a hardware security module or a TPM device).
30+
31+
The temporary key can be set at run time by the application, and will be used exactly once by the bootloader
32+
to verify and install the next update. The key can be for example received from a back-end during the update
33+
process using secure communication, and set by the application, using `libwolfboot` API, to be used by
34+
wolfBoot upon next boot.
35+
36+
Aside from setting the temporary key, the update mechanism remains the same for distrubuting, uploading and
37+
installing firmware updates through wolfBoot.
38+
39+
### Libwolfboot API
40+
41+
The API to communicate with the bootloader from the application is expanded when this feature is enabled,
42+
to allow setting a temporary key to process the next update.
43+
44+
The functions
45+
46+
```
47+
int wolfBoot_set_encrypt_key(const uint8_t *key, int len);
48+
int wolfBoot_erase_encrypt_key(void);
49+
```
50+
51+
can be used to set a temporary encryption key for the external partition, or erase a key previously set, respectively.
52+
53+
Moreover, using `libwolfboot` to access the external flash with wolfboot hal from the application will not
54+
use encryption. This way the received update, already encrypted at origin, can be stored in the external
55+
memory unchanged, and retreived in its encrypted format, e.g. to verify that the transfer has been successful before
56+
reboot.
57+
58+
### Symmetric encryption algorithm
59+
60+
The algorithm currently used to encrypt and decrypt data in external partitions
61+
is Chacha20-256. The expected key to provide to `wolfBoot_set_encrypt_key()` must be exactly 32 Bytes long.
62+
63+

docs/remote_flash.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## Remote External flash memory support via UART
2+
3+
wolfBoot can emulate external partitions using UART communication with a neighbor system. This feature
4+
is particularly useful in those asynchronous multi-process architectures, where updates can be stored
5+
with the assistance of an external processing unit.
6+
7+
### Bootloader setup
8+
9+
The option to activate this feature is `UART_FLASH=1`. This configuration option depends on the
10+
external flash API, which means that the option `EXT_FLASH=1` is also mandatory to compile the bootloader.
11+
12+
The HAL of the target system must be expanded to include a simple UART driver, that will be used by the
13+
bootloader to access the content of the remote flash using one of the UART controllers on board.
14+
15+
Example UART drivers for a few of the supported platforms can be found in the [hal/uart](hal/uart) directory.
16+
17+
The API exposed by the UART HAL extension for the supported targets is composed by the following functions:
18+
19+
```
20+
int uart_init(uint32_t bitrate, uint8_t data, char parity, uint8_t stop);
21+
int uart_tx(const uint8_t c);
22+
int uart_rx(uint8_t *c);
23+
```
24+
25+
Consider implementing these three functions based on the provided examples if you want to use external flash memory
26+
support on your platform, if not officially supported yet.
27+
28+
29+
### Host side: UART flash server
30+
31+
On the remote system hosting the external partition image for the target, a simple protocol can be implemented
32+
on top of UART messages to serve flash-access specific calls.
33+
34+
An example uart-flash-server daemon, designed to run on a GNU/Linux host and emulate the external partition with
35+
a local file on the filesystem, is available in [tools/uart-flash-server](tools/uart-flash-server).
36+
37+
38+
### External flash update mechanism
39+
40+
wolfBoot treats external UPDATE and SWAP partitions in the same way as when they are mapped on a local SPI flash.
41+
Read and write operations are simply translated into remote procedure calls via UART, that can be interpreted by
42+
the remote application and provide read and write access to actual storage elements which would only be accessible
43+
by the host.
44+
45+
This means that after a successful update, a copy of the previos firmware will be stored in the remote partition to
46+
provide exactly the same update mechanism that is available in all the other use cases. The only difference consist
47+
in the way of accessing the physical storage area, but all the mechanisms at a higher level stay the same.
48+
49+
50+
51+

0 commit comments

Comments
 (0)