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
Copy file name to clipboardExpand all lines: docs/api/security/Devicekey.md
+38-7Lines changed: 38 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -19,31 +19,62 @@ The characteristics required by this root of trust are:
19
19
20
20
The DeviceKey feature keeps the root of trust key in internal storage, using the KVStore component. Internal storage provides protection from external physical attacks to the device.
21
21
22
-
The root of trust is generated at the first use of DeviceKey if the true random number generator is available in the device. If no true random number generator is available, you must pass the injected root of trust key to the DeviceKey before you call the key derivation API.
22
+
The root of trust must be created before its first use. Otherwise, the key derivation API fails.
23
23
24
24
## Key derivation API
25
25
26
26
`generate_derived_key`: This API generates a new key based on an array of data ([salt](https://en.wikipedia.org/wiki/Salt_(cryptography)) the caller provides. A single salt value always generates the same key, so if you need a new key, you must use a new salt value. The salt can have any value - array, string and so on.
27
27
28
-
The generated keys can be 128 or 256 bits in length.
28
+
The generated keys can be 128b or 256b in length.
29
29
30
-
### Root of Trust Injection API
30
+
### Root of Trust generation API
31
31
32
-
`device_inject_root_of_trust`: You must call this API once in the lifecycle of the device, before any call to key derivation, if the device does not support true random number generator (`DEVICE_TRNG` is not defined).
32
+
DeviceKey class needs root of trust ready to use before the derivation API's first call. There are two options to achieve this:
33
+
34
+
- Create a device key using a built-in random number generator.
35
+
- Manually fill the device key data array.
36
+
37
+
Both cases requires injecting this key data to the KVStore reserved area.
38
+
39
+
When `DEVICE_TRNG` is defined, the device supports a random number generator, and you may generate the key by calling `generate_root_of_trust()`. The call succeeds only if the key does not already exist. You can't change the existing key.
40
+
41
+
```c++ NOCI
42
+
int status = DeviceKey::get_instance().generate_root_of_trust();
43
+
if(status == DEVICEKEY_SUCCESS) {
44
+
//success
45
+
} else {
46
+
//error
47
+
}
48
+
```
49
+
50
+
If `DEVICE_TRNG` is not defined, the key buffer must be filled manually by calling `device_inject_root_of_trust()`. The example below shows an injection of a dummy key:
0 commit comments