takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

DeviceKey Class Reference

Use this singleton if you need to derive a new key from the device root of trust. More...

#include <DeviceKey.h>

Inherits NonCopyable< DeviceKey >.

Public Member Functions

int generate_derived_key (const unsigned char *isalt, size_t isalt_size, unsigned char *output, uint16_t ikey_type)
 Derive a new key based on the salt string.
int device_inject_root_of_trust (uint32_t *value, size_t isize)
 Set a device key into the NVStore.

Static Public Member Functions

static DeviceKeyget_instance ()
 As a singleton, return the single instance of the class.

Private Member Functions

 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.

Detailed Description

Use this singleton if you need to derive a new key from the device root of trust.

Note:
Synchronization level: Thread safe

Definition at line 53 of file DeviceKey.h.


Member Function Documentation

int device_inject_root_of_trust ( uint32_t *  value,
size_t  isize 
)

Set a device key into the NVStore.

In case TRNG support is missing, Call this method before calling device_key_derived_key. This method should be called only once!

Parameters:
valueinput buffer contain the key.
isizesize of the supplied key. Must be 16 bytes or 32 bytes.
Returns:
0 on success, negative error code on failure

Definition at line 98 of file DeviceKey.cpp.

int generate_derived_key ( const unsigned char *  isalt,
size_t  isalt_size,
unsigned char *  output,
uint16_t  ikey_type 
)

Derive a new key based on the salt string.

key type can be with values 16 bytes and 32 bytes

Parameters:
isaltinput buffer used to create the new key. Same input will generate always the same key
isalt_sizesize of the data in salt buffer
outputbuffer to receive the derived key. Size must be 16 bytes or 32 bytes according to the ikey_type parameter
ikey_typetype of the required key. Type must be 16 bytes or 32 bytes.
Returns:
0 on success, negative error code on failure

Definition at line 61 of file DeviceKey.cpp.

static DeviceKey& get_instance (  ) [static]

As a singleton, return the single instance of the class.

Reason for this class being a singleton is the following:

  • Ease the use for users of this class not having to coordinate instantiations.
  • Lazy instantiation of internal data (which we can't achieve with simple static classes).
Returns:
Singleton instance reference.

Definition at line 64 of file DeviceKey.h.