7#ifndef HW_UNIQUE_KEY_H_
8#define HW_UNIQUE_KEY_H_
28#if defined(__NRF_TFM__)
31#include <zephyr/devicetree.h>
33#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_kmu) || defined(CONFIG_CRACEN_HW_PRESENT)
36#if defined(CONFIG_HAS_HW_NRF_CC310)
39#if defined(CONFIG_HAS_HW_NRF_CC312)
43#if defined(HUK_HAS_CC310)
44#define HUK_SIZE_WORDS 4
45#elif defined(HUK_HAS_CC312)
46#define HUK_SIZE_WORDS 8
47#elif defined(CONFIG_CRACEN_HW_PRESENT)
48#define HUK_SIZE_WORDS 12
50#error "This library requires CryptoCell or Cracen to be available."
53#define HUK_SIZE_BYTES (HUK_SIZE_WORDS * 4)
56#define HW_UNIQUE_KEY_ERR_MISSING (0x16501)
59#define HW_UNIQUE_KEY_ERR_WRITE_FAILED (0x16502)
62#define HW_UNIQUE_KEY_ERR_GENERATION_FAILED (0x16503)
65#define HW_UNIQUE_KEY_ERR_DERIVE_FAILED (0x16504)
68#define HW_UNIQUE_KEY_ERR_GENERIC_ERROR (0x16505)
71#define HW_UNIQUE_KEY_SUCCESS (0x0)
87#define KMU_SELECT_SLOT(KEYSLOT) (uint32_t)((KEYSLOT) + 1)
156 const uint8_t *context,
size_t context_size,
157 uint8_t
const *label,
size_t label_size,
158 uint8_t *output, uint32_t output_size);
hw_unique_key_slot
Definition: hw_unique_key.h:78
@ HUK_KEYSLOT_KDR
Definition: hw_unique_key.h:80
int hw_unique_key_derive_key(enum hw_unique_key_slot key_slot, const uint8_t *context, size_t context_size, uint8_t const *label, size_t label_size, uint8_t *output, uint32_t output_size)
Derive a key from the specified HUK, using the nrf_cc3xx_platform API on CryptoCell....
bool hw_unique_key_are_any_written(void)
Check whether any Hardware Unique Keys are written to the KMU.
int hw_unique_key_write_random(void)
Read random numbers from nrf_cc3xx_platform_ctr_drbg_get and write them to all slots with hw_unique_k...
int hw_unique_key_write(enum hw_unique_key_slot key_slot, const uint8_t *key)
Write a Hardware Unique Key to the KMU.
int hw_unique_key_load_kdr(void)
Load the Hardware Unique Key (HUK) into the KDR registers of the Cryptocell.
bool hw_unique_key_is_written(enum hw_unique_key_slot key_slot)
Check whether a Hardware Unique Key has been written to the KMU.