-
Notifications
You must be signed in to change notification settings - Fork 22
Generate DeviceKey Root of Trust if SecureStore is enabled #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,13 +20,17 @@ | |
#include <string.h> | ||
#include "KVStore.h" | ||
#include "kvstore_global_api.h" | ||
#include "DeviceKey.h" | ||
|
||
using namespace mbed; | ||
|
||
#define EXAMPLE_KV_VALUE_LENGTH 64 | ||
#define EXAMPLE_KV_KEY_LENGTH 32 | ||
#define err_code(res) MBED_GET_ERROR_CODE(res) | ||
|
||
#define STR_EXPAND(tok) #tok | ||
#define STR(tok) STR_EXPAND(tok) | ||
|
||
void kv_store_global_api_example(); | ||
|
||
int main() | ||
|
@@ -59,6 +63,11 @@ void kv_store_global_api_example() | |
res = kv_reset("/kv/"); | ||
printf("kv_reset -> %d\n", err_code(res)); | ||
|
||
if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_EXTERNAL") == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In most projects, we normally do #if (MBED_CONF_STORAGE_STORAGE_TYPE == TDB_EXTERNAL)
but kv-config doesn't define The runtime check is probably not optimal in terms of code size (i.e. DeviceKey dependencies get pulled in even if the condition is not true). Unless the compiler compares the strings at compile time for optimisation? |
||
res = DeviceKey::get_instance().generate_root_of_trust(); | ||
printf("DeviceKey::get_instance().generate_root_of_trust() -> %d\n", res); | ||
} | ||
|
||
/* Set First 'Dummy' Key/Value pair with unprotected clear value data */ | ||
printf("kv_set first dummy key\n"); | ||
res = kv_set(kv_key_in, kv_value_in, strlen(kv_value_in), 0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copied from https://github.com/ARMmbed/mbed-os/blob/f2278567d09b9ae9f4843e1d9d393526b9462783/storage/kvstore/kv_config/source/kv_config.cpp#L170-L171
It doesn't look pretty but we need it, see below.