Skip to content

Commit 7c90d71

Browse files
committed
Generate DeviceKey Root of Trust if TDB_EXTERNAL is used
TDB_INTERNAL is based on SecureStore which uses DeviceKey.
1 parent 3ae1656 commit 7c90d71

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020
#include <string.h>
2121
#include "KVStore.h"
2222
#include "kvstore_global_api.h"
23+
#include "DeviceKey.h"
2324

2425
using namespace mbed;
2526

2627
#define EXAMPLE_KV_VALUE_LENGTH 64
2728
#define EXAMPLE_KV_KEY_LENGTH 32
2829
#define err_code(res) MBED_GET_ERROR_CODE(res)
2930

31+
#define STR_EXPAND(tok) #tok
32+
#define STR(tok) STR_EXPAND(tok)
33+
3034
void kv_store_global_api_example();
3135

3236
int main()
@@ -59,6 +63,11 @@ void kv_store_global_api_example()
5963
res = kv_reset("/kv/");
6064
printf("kv_reset -> %d\n", err_code(res));
6165

66+
if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_EXTERNAL") == 0) {
67+
res = DeviceKey::get_instance().generate_root_of_trust();
68+
printf("DeviceKey::get_instance().generate_root_of_trust() -> %d\n", res);
69+
}
70+
6271
/* Set First 'Dummy' Key/Value pair with unprotected clear value data */
6372
printf("kv_set first dummy key\n");
6473
res = kv_set(kv_key_in, kv_value_in, strlen(kv_value_in), 0);

0 commit comments

Comments
 (0)