Skip to content

Commit 5a62d4e

Browse files
Remove TDB_EXTERNAL_NO_RBP and FILESYSTEM_NO_RBP from KVStore docs
NO_RBP (no rollback protection) is intended to not require an internal TDB, however, DeviceKey, which we use to derive SecureStore's encryption key, still does. Currently, no internal TDB is created with these two configurations, meaning there's no way to store the DeviceKey and SecureStore doesn't work. Update the documentation to reflect these changes.
1 parent 9039027 commit 5a62d4e

File tree

2 files changed

+15
-109
lines changed

2 files changed

+15
-109
lines changed

docs/api/storage/KVStoreGlobalAPI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You can "or" (|) the flags below and pass them to the function set in the parame
2626

2727
- **KV_WRITE_ONCE_FLAG:** The system does not an additional call to the function set with the same file name to delete or replace data.
2828
- **KV_REQUIRE_CONFIDENTIALITY_FLAG:** The system encrypts the data using an AES CTR, a random IV and a key derived from DeviceKey. This flag will be ignored if you select the `TDB_INTERNAL` configuration because the internal memory is seen as protected from physical attacks.
29-
- **KV_REQUIRE_REPLAY_PROTECTION_FLAG:** The system keeps a copy of the data CMAC in internal memory and checks that the data CMAC corresponds to this saved CMAC. It does this to prevent an attacker replacing the latest data with a valid old version of the data. This flag will be ignored if you select the configuration `TDB_EXTERNAL_NO_RBP` or `FILESYSTEM_NO_RBP`.
29+
- **KV_REQUIRE_REPLAY_PROTECTION_FLAG:** The system keeps a copy of the data CMAC in internal memory and checks that the data CMAC corresponds to this saved CMAC. It does this to prevent an attacker replacing the latest data with a valid old version of the data.
3030

3131
### `full_prefix`
3232

docs/reference/configuration/storage-config.md

Lines changed: 14 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,20 @@ kvstore
2727
├───tdb_external
2828
│ mbed_lib.json
2929
30-
├───tdb_external_no_rbp
31-
│ mbed_lib.json
32-
3330
├───filesystem
3431
│ mbed_lib.json
3532
36-
├───filesystem_no_rbp
37-
│ mbed_lib.json
38-
3933
└───tdb_internal
4034
mbed_lib.json
4135
```
4236

43-
The KVStore configuration file structure includes six configuration files. You can use the topmost configuration file to set up the full configuration of the storage by defining a single parameter (`storage_type`) to one of the predefined configurations. You can use the configuration files in the subfoldersto implement the above top level configurations.
37+
The KVStore configuration file structure includes four configuration files. You can use the topmost configuration file to set up the full configuration of the storage by defining a single parameter (`storage_type`) to one of the predefined configurations. You can use the configuration files in the subfoldersto implement the above top level configurations.
4438

4539
You can find the configuration files under `conf/<configuration name>`:
4640

4741
- `conf/tdb_internal` - The storage type `TDB_INTERNAL` configuration is intended to be used when all data will be stored in internal memory only. There is no need for additional security features. A single TDBStore object will be allocated in internal flash.
4842
- `conf/tdb_external` - The storage type `TDB_EXTERNAL` configuration provides full security and is intended to be used when data is stored in external flash. It allocates: SecureStore, TDBStore in external flash and TDBStore in internal flash for rollback protection (RBP).
49-
- `conf/tdb_external_no_rbp` - The storage type `TDB_EXTERNAL_NO_RBP` configuration allows security but without rollback protection. This is similar to `tdb_external` but without the TDBStore in internal memory.
5043
- `conf/filesystem` - This configuration allocates SecureStore, FileSystemStore, filesystem, TDBStore in internal memory and the required block devices. The allocated file system is selected according to the COMPONENT set in `targets.json` (FATFS for SD card and LITTLEFS for SPIF). However, you can set this differently by overriding the respective parameter. Use this configuration if you need the file system with the POSIX API in addition to the set/get API.
51-
- `conf/filesystem_no_rbp` - The storage type `FILESYSTEM_NO_RBP` configuration allows security like the FILESYSTEM configuration but without rollback protection.
5244

5345
A standalone block device is allocated for each component in internal and external memory and SD cards as required for the configurations. The full size of the memory allocated for each block device will be used by the respective component.
5446

@@ -59,9 +51,7 @@ The following is a list of all storage parameters available and their descriptio
5951
- `storage_type` - Used to select one of the predefined configurations.
6052
- `TDB_INTERNAL`.
6153
- `TDB_EXTERNAL`.
62-
- `TDB_EXTERNAL_NO_RBP`.
6354
- `FILESYSTEM`.
64-
- `FILESYSTEM_NO_RBP`.
6555
- `default_kv` - This string represents the path for the default KVStore instantiation. Applications can pass an empty path (only the key name) or pass the generated name for this parameter (`MBED_CONF_STORAGE_DEFAULT_KV`) as the path to use this configuration.
6656
- `internal_size` - The size in bytes for the internal FlashIAP block device. This, together with the `internal_base_address`, adjusts the size and location where the block device resides on memory. If not defined, the block device uses the maximum size available.
6757
- `internal_base_address` - The address where the internal FlashIAP blockDevice starts. This helps to prevent collisions with other needs, such as firmware updates. If this is not defined, the start address is set to the first sector after the application code ends in `TDB_internal`. In any external configurations with rollback protection support, it will be set to end of flash - `rbp_internal_size`.
@@ -83,7 +73,7 @@ Below is the main storage configuration in the `mbed_lib json` file:
8373
"name": "storage",
8474
"config": {
8575
"storage_type": {
86-
"help": "Options are TDB_INTERNAL, TDB_EXTERNAL, TDB_EXTERNAL_NO_RBP, FILESYSTEM or FILESYSTEM_NO_RBP.",
76+
"help": "Options are TDB_INTERNAL, TDB_EXTERNAL, or FILESYSTEM",
8777
"value": "NULL"
8878
},
8979
"default_kv": {
@@ -104,7 +94,7 @@ In this configuration, all KVStore C APIs will be mapped to the TDBStore in the
10494

10595
Below is the `TDB_INTERNAL` configuration in `mbed_lib.json`:
10696

107-
```
97+
```json
10898
{
10999
"name": "storage_tdb_internal",
110100
"config": {
@@ -136,7 +126,7 @@ You can enable this configuration by setting `storage_type` to `TDB_EXTERNAL` in
136126

137127
Below is the `TDB_EXTERNAL` configuration in `mbed_lib.json`:
138128

139-
```
129+
```json
140130
{
141131
"name": "storage_tdb_external",
142132
"config": {
@@ -164,37 +154,6 @@ Below is the `TDB_EXTERNAL` configuration in `mbed_lib.json`:
164154
}
165155
```
166156

167-
### TDB_External_no_RBP
168-
169-
<span class="images">![External](../../images/TDB_External_no_rbp.jpg)<span>`TDB_External_no_RBP`</span></span>
170-
171-
The `TDB_EXTERNAL_NO_RBF` configuration has no support for rollback protection and is therefore less secure.
172-
173-
The `TDB_EXTERNAL_NO_RBP` uses only one TDBStore on the external flash for all data. In this configuration, all KVStore C API calls are mapped to work with the SecureStore class. The external TDBStore will work on top of the default block device; however, you can set the external TDBStore block device to any of the following block devices: SPIF, QSPIF, DATAFASH and SD.
174-
175-
You can enable this configuration by setting `storage_type` to `TDB_EXTERNAL_NO_RBP` in `storage mbed_lib.json`.
176-
177-
Below is the `TDB_EXTERNAL_NO_RBP` configuration in `mbed_lib.json`:
178-
179-
```
180-
{
181-
"name": "storage_tdb_external_no_rbp",
182-
"config": {
183-
"external_size": {
184-
"help": "Size in bytes of the external block device, if default the maximum size available is used.",
185-
"value": "0"
186-
},
187-
"external_base_address": {
188-
"help": "The default will set start address to address 0",
189-
"value": "0"
190-
},
191-
"blockdevice": {
192-
"help": "Options are default, SPIF, DATAFASH, QSPIF, SD or other. If default the block device will be chosen by the defined component. If other, override get_other_blockdevice() to support block device out of Mbed OS tree.",
193-
"value": "default"
194-
}
195-
}
196-
}
197-
```
198157

199158
### FILESYSTEM
200159

@@ -208,7 +167,7 @@ You can enable this configuration by setting `storage_type` to `FILESYSTEM` in `
208167

209168
Below is the `FILESYSTEM` configuration in `mbed_lib.json`:
210169

211-
```
170+
```json
212171
{
213172
"name": "storage_filesystem",
214173
"config": {
@@ -250,66 +209,14 @@ Below is the `FILESYSTEM` configuration in `mbed_lib.json`:
250209

251210
If the file system is not set, the default file system and block device will be applied, and `blockdevice`, `external_size` and `external_base_address` will be ignored.
252211

253-
### FILESYSTEM_NO_RBP
254-
255-
<span class="images">![FILESYSTEM](../../images/FILESYSTEM_no_rbp.jpg)<span>`FILESYSTEM_NO_RBP`</span></span>
256-
257-
The `FILESYSTEM_NO_RBP` configuration resembles the `EXTERNAL_NO_RBP` with the difference that it uses FileSystemStore on the external flash. By default, FileSystemStore uses the default file system and the default block device. This configuration has no support for rollback protection and is therefore less secure.
258-
259-
In this configuration, all KVStore C API calls are mapped to the SecureStore class. This class handles the use of the external FileSystemStore.
260-
261-
You can enable this configuration by setting `storage_type` to `FILESYSTEM_NO_RBF` in `storage mbed_lib.json`.
262-
263-
Below is the `FILESYSTEM` configuration in `mbed_lib.json`:
264-
265-
```
266-
{
267-
"name": "storage_filesystem_no_rbp",
268-
"config": {
269-
"filesystem": {
270-
"help": "Options are default, FAT or LITTLE. If default value the filesystem is chosen by the blockdevice type",
271-
"value": "default"
272-
},
273-
"blockdevice": {
274-
"help": "Options are default, SPIF, DATAFLASH, QSPIF, SD or other. If default the block device will be chosen by the defined component. If other, override get_other_blockdevice() to support block device out of Mbed OS tree.",
275-
"value": "default"
276-
},
277-
"external_size": {
278-
"help": "Size in bytes of the external block device, if default the maximum size available is used.",
279-
"value": "0"
280-
},
281-
"external_base_address": {
282-
"help": "The default will set start address to address 0",
283-
"value": "0"
284-
},
285-
"mount_point": {
286-
"help": "Where to mount the filesystem.",
287-
"value": "kv"
288-
},
289-
"folder_path": {
290-
"help": "Path for the working directory where the FileSystemStore stores the data",
291-
"value": "kvstore"
292-
}
293-
}
294-
}
295-
```
296-
297-
If the file system is not set, the default file system and block device will be applied, and `blockdevice`, `external_size` and `external_base_address` will be ignored.
298212

299213
### Configuration functions API
300214

301-
Applications must call the function **storage_configuration()** to instantiate the required configuration. This function is defined as weak to allow the replacement of this function with a completely different implementation of the instantiation of components:
302-
303-
```
304-
MBED_WEAK bool storage_configuration()
305-
{
306-
return _STORAGE_CONFIG(MBED_CONF_STORAGE_STORAGE_TYPE);
307-
}
308-
```
215+
Applications must call the function **kv_init_storage_config()** to instantiate any of the required default configurations. This function is defined as weak to allow it to be overridden by a user implementation of the instantiation.
309216

310217
### Override user-defined setup
311218

312-
To create a much more complex setup, including using other block devices, such as MBRBlockDevice or SlicingBlockDevice, you need to override the `storage_configuration` function and generate any storage configuration.
219+
To create a more complex setup, including using other block devices, such as MBRBlockDevice or SlicingBlockDevice, you need to override the `kv_init_storage_config` function and generate any storage configuration.
313220

314221
## LittleFS configuration
315222

@@ -432,21 +339,20 @@ The list above is in the order of precedence shows which block device is the def
432339

433340
For example, the following entry in `targets.json` enables the SD component:
434341

435-
```
342+
```json
436343
"K64F": {
437344
"components": ["SD"],
438345
"core": "Cortex-M4F",
439346
"supported_toolchains": ["ARM", "GCC_ARM", "IAR"],
440347
"inherits": ["Target"],
441348
"features": ["STORAGE"],
442-
"release_versions": ["2", "5"],
443-
...
444-
},
349+
"release_versions": ["2", "5"]
350+
}
445351
```
446352

447353
The following `mbed_app.json` snippet enables the SPI flash component when compiling for the MTB_ADV_WISE_1570 target:
448354

449-
```
355+
```json
450356
"target_overrides": {
451357
"MTB_ADV_WISE_1570": {
452358
"target.components_add": ["SPIF"]
@@ -458,7 +364,7 @@ Please note that while a default block device exists, an application is not forc
458364

459365
Enabling the storage feature, SD component, and overriding the default pins can be done within `mbed_app.json`. Using the NRF52_DK target as an example:
460366

461-
```
367+
```json
462368
"target_overrides": {
463369
"NRF52_DK": {
464370
"target.features_add": ["STORAGE"],
@@ -475,7 +381,7 @@ These values override the default pins assigned to the parameters: `MBED_CONF_SD
475381

476382
### Overriding default block device implementation
477383

478-
The get default instance is implemented as [MBED_WEAK](https://github.com/ARMmbed/mbed-os/blob/40058871de290edc758a21ae6d8f2ec1d1b3533d/platform/mbed_toolchain.h#L120) at `features/storage/system_storage/SystemStorage.cpp`. That means that can override it by implementing the function without `MBED_WEAK` and change the default block device for a given application.
384+
The get default instance is implemented as [MBED_WEAK](https://github.com/ARMmbed/mbed-os/blob/40058871de290edc758a21ae6d8f2ec1d1b3533d/platform/mbed_toolchain.h#L120) at `features/storage/system_storage/SystemStorage.cpp`. That means that a user can override it by implementing the function without `MBED_WEAK` and change the default block device for a given application.
479385

480386
```
481387
#include "HeapBlockDevice.h"
@@ -497,7 +403,7 @@ The default file system is created based on the default block device due to perf
497403

498404
SPIF and DATAFLASH block devices support the Little file system, and the SD block device supports the FAT file system. However, the application can ovveride this behavior.
499405

500-
### Overriding default block device implementation
406+
### Overriding the default FileSystem implementation
501407

502408
The get default instance is implemented as `MBED_WEAK` at `features/storage/system_storage/SystemStorage.cpp`. That means you can overridde it by implementing the function without `MBED_WEAK` and change the default block device for a given application.
503409

0 commit comments

Comments
 (0)