nrfxlib API 0.1.0
Loading...
Searching...
No Matches

◆ mbedtls_shadow_key_derive()

int mbedtls_shadow_key_derive ( uint32_t  slot_id,
unsigned int  keybits,
uint8_t const *  label,
size_t  label_size,
uint8_t const *  context,
size_t  context_size,
uint8_t *  output,
size_t  output_size 
)

#include <crypto/nrf_cc310_mbedcrypto/include/mbedtls/cc3xx_kmu.h>

Function to use CMAC to derive a key stored in KMU/Kdr.

The KDF is using a PRF function described in the Special publication 800-108: Recommendation for Key Derivation Using Pseudorandom Functions https://csrc.nist.gov/publications/detail/sp/800-108/final.

This algorithm is described in chapter 5.1 - KDF in Counter Mode

The format of the PRF (the input) is as follows: PRF (KI, i || Label || 0x00 || Context || L)

KI: The Key derivation key i : The counter value for each iteration of the PRF represented as one byte. label: A string identifying the purpose of the derived key that is up to 64 bytes long. 0x00: a single byte delimiter. Context: Fixed information about the derived keying material that is up to 64 bytes long. L : The length of derived key material in bits represented as two bytes.

Note
On nRF52840 only slot_id == 0 is valid, pointing to the Kdr key (also known as a HUK key) loaded into the CryptoCell.
Parameters
slot_idIdentifier of the key slot.
keybitsKey size in bits.
labelLabel to use for KDF.
label_sizeSize of the label to use for KDF.
contextContext info to use for KDF.
context_sizeContext info size to use for KDF.
outputOutput buffer.
output_sizeSize of output buffer in bytes.
Returns
0 on success, otherwise a negative number.