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
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.
Copy file name to clipboardExpand all lines: docs/api/storage/KVStoreGlobalAPI.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ You can "or" (|) the flags below and pass them to the function set in the parame
26
26
27
27
-**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.
28
28
-**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.
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.
44
38
45
39
You can find the configuration files under `conf/<configuration name>`:
46
40
47
41
-`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.
48
42
-`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.
50
43
-`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.
52
44
53
45
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.
54
46
@@ -59,9 +51,7 @@ The following is a list of all storage parameters available and their descriptio
59
51
-`storage_type` - Used to select one of the predefined configurations.
60
52
-`TDB_INTERNAL`.
61
53
-`TDB_EXTERNAL`.
62
-
-`TDB_EXTERNAL_NO_RBP`.
63
54
-`FILESYSTEM`.
64
-
-`FILESYSTEM_NO_RBP`.
65
55
-`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.
66
56
-`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.
67
57
-`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:
83
73
"name": "storage",
84
74
"config": {
85
75
"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",
87
77
"value": "NULL"
88
78
},
89
79
"default_kv": {
@@ -104,7 +94,7 @@ In this configuration, all KVStore C APIs will be mapped to the TDBStore in the
104
94
105
95
Below is the `TDB_INTERNAL` configuration in `mbed_lib.json`:
106
96
107
-
```
97
+
```json
108
98
{
109
99
"name": "storage_tdb_internal",
110
100
"config": {
@@ -136,7 +126,7 @@ You can enable this configuration by setting `storage_type` to `TDB_EXTERNAL` in
136
126
137
127
Below is the `TDB_EXTERNAL` configuration in `mbed_lib.json`:
138
128
139
-
```
129
+
```json
140
130
{
141
131
"name": "storage_tdb_external",
142
132
"config": {
@@ -164,37 +154,6 @@ Below is the `TDB_EXTERNAL` configuration in `mbed_lib.json`:
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
-
```
198
157
199
158
### FILESYSTEM
200
159
@@ -208,7 +167,7 @@ You can enable this configuration by setting `storage_type` to `FILESYSTEM` in `
208
167
209
168
Below is the `FILESYSTEM` configuration in `mbed_lib.json`:
210
169
211
-
```
170
+
```json
212
171
{
213
172
"name": "storage_filesystem",
214
173
"config": {
@@ -250,66 +209,14 @@ Below is the `FILESYSTEM` configuration in `mbed_lib.json`:
250
209
251
210
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.
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.
298
212
299
213
### Configuration functions API
300
214
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:
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.
309
216
310
217
### Override user-defined setup
311
218
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.
313
220
314
221
## LittleFS configuration
315
222
@@ -432,21 +339,20 @@ The list above is in the order of precedence shows which block device is the def
432
339
433
340
For example, the following entry in `targets.json` enables the SD component:
The following `mbed_app.json` snippet enables the SPI flash component when compiling for the MTB_ADV_WISE_1570 target:
448
354
449
-
```
355
+
```json
450
356
"target_overrides": {
451
357
"MTB_ADV_WISE_1570": {
452
358
"target.components_add": ["SPIF"]
@@ -458,7 +364,7 @@ Please note that while a default block device exists, an application is not forc
458
364
459
365
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:
460
366
461
-
```
367
+
```json
462
368
"target_overrides": {
463
369
"NRF52_DK": {
464
370
"target.features_add": ["STORAGE"],
@@ -475,7 +381,7 @@ These values override the default pins assigned to the parameters: `MBED_CONF_SD
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.
479
385
480
386
```
481
387
#include "HeapBlockDevice.h"
@@ -497,7 +403,7 @@ The default file system is created based on the default block device due to perf
497
403
498
404
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.
### Overriding the default FileSystem implementation
501
407
502
408
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.
0 commit comments