Skip to content
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

Generate DeviceKey Root of Trust if SecureStore is enabled #66

Merged
merged 1 commit into from
Nov 27, 2020

Conversation

LDong-Arm
Copy link
Contributor

@LDong-Arm LDong-Arm commented Nov 26, 2020

Fixes: #52

Following ARMmbed/mbed-os#12385, DeviceKey Root of Trust is not implicitly generated anymore. The Root of Trust can be either auto generated with DeviceKey::get_instance().generate_root_of_trust(), or injected with DeviceKey::device_inject_root_of_trust(...).

External TDB uses SecureStore which depends on DeviceKey (here), so we need to set up a Root of Trust by generating one. Note: generate_root_of_trust() depends on TRNG support, which is already a requirement for SecureStore so we don't need an extra check here.

Tested on K64F with SD card.

@ARMmbed/mbed-os-core

TDB_INTERNAL is based on SecureStore which uses DeviceKey.
@LDong-Arm
Copy link
Contributor Author

Now ready for review.

Comment on lines +31 to +32
#define STR_EXPAND(tok) #tok
#define STR(tok) STR_EXPAND(tok)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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) {
Copy link
Contributor Author

@LDong-Arm LDong-Arm Nov 26, 2020

Choose a reason for hiding this comment

The 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 TDB_EXTERNAL as a macro, so we need to convert MBED_CONF_STORAGE_STORAGE_TYPE to string for string comparison (like everywhere MBED_CONF_STORAGE_STORAGE_TYPE is checked in Mbed OS)...

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?

@evedon evedon merged commit 1ba8d2b into ARMmbed:development Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants