When provisioning secrets into an RW612 device, one common requirement is to securely load cryptographic keys without ever exposing the plaintext key material to application software.
The EdgeLock Secure Subsystem (ELS) provides a secure mechanism for accomplishing this by allowing a wrapped key blob to be imported directly into an ELS key slot. The wrapping key is derived from device-unique root material inside the secure enclave.
This article demonstrates how to:
NXP_DIE_KEK_SKThe imported key never exists in plaintext in application memory, significantly reducing the attack surface compared to software-based key management.
Before looking at the implementation, it is useful to understand the different keys involved.
This is the 256-bit die master key derived from UDF and PUF using the KEYPROV operation.
Characteristics:
The key is loaded via dedicated secret key bus from PUF into ELS and XOR with a UDF derived key using KEYPROV, where it is used as a main key for further derivation of all remaining keys used by ROM. Applications never directly access the key material.
This 256-bit key is derived from the master key using CKDF. It used for the wrapping of RFC3394 blobs stored in the OTP fuse region.
Purpose:
In this example the KEK is stored temporarily in key slot 5.
The final key imported from the wrapped blob depends on how the blob was originally generated using the HSM provisioning flow (for example, via HSM_STORE_KEY and later loaded with loadkeyblob).
The imported key may represent a customer-defined security asset such as:
CUST_CKDFK_FLAG)CUST_HKDFK_FLAG)CUST_HMACK_FLAG)CUST_CMACK_FLAG)CUST_AESK_FLAG)CUST_KUOK_FLAG)Regardless of the key type, the import process remains the same. The key material is never exposed to application software during this process. Once imported, the key can be used directly by ELS for the cryptographic operations associated with its intended purpose, while remaining protected within the secure subsystem.
Required Headers:
#include "mcux_els.h"
#include "mcuxClEls.h"
#include "mcux_pkc.h"
#include "fsl_romapi_otp.h"
The wrapped blob is protected using a Key Encryption Key (KEK).
On RW612, the KEK can be derived from the device master key (NXP_DIE_MK_SK) using the official recipe constants.
The derivation operation uses masterKeyIdx = 0; which corresponds to NXP_DIE_MK_SK and produces a new key in the target slot.
Example:
static const uint8_t derivation_data[12] =
{
0x94, 0xbe, 0x03, 0xac,
0x8b, 0x59, 0x32, 0x45,
0x11, 0x7f, 0xf8, 0x3f
};
mcuxClEls_Ckdf_Sp800108_Async(
masterKeyIdx,
target_slot,
targetKeyProperties,
derivation_data);
Wait for completion:
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR);Verify that the derived key slot becomes active before proceeding.
otp_fuse_read(starting_fuse_index + i, &fuse_word);
These words are assembled into a contiguous buffer:
blob_data[i * 4 + 0] = (fuse_word >> 0) & 0xFF;
blob_data[i * 4 + 1] = (fuse_word >> 8) & 0xFF;
blob_data[i * 4 + 2] = (fuse_word >> 16) & 0xFF;
blob_data[i * 4 + 3] = (fuse_word >> 24) & 0xFF;
The resulting buffer contains the RFC3394 wrapped key.
Once the KEK exists and the blob has been retrieved, the import operation can begin.
Configure ELS for RFC3394 import:
mcuxClEls_KeyImportOption_t options;
options.word.value = 0;
options.bits.kfmt =
MCUXCLELS_KEYIMPORT_KFMT_RFC3394;
Perform the import:
mcuxClEls_KeyImport_Async(
options,
blob_data,
blob_length,
kek_slot,
target_slot);
Parameters:
| Parameter | Purpose |
|---|---|
| blob_data | Wrapped key blob |
| blob_length | Blob size |
| kek_slot | Slot containing NXP_DIE_KEK_SK |
| target_slot | Destination keyslot |
Wait for completion:
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR);
If successful, ELS unwraps the blob internally and places the resulting key into the destination key slot.
No plaintext key material is exposed to software.
After the blob has been imported, delete the temporary KEK:
mcuxClEls_KeyDelete_Async(kek_slot);
mcuxClEls_WaitForOperation(MCUXCLELS_ERROR_FLAGS_CLEAR);
This leaves only the imported key resident inside ELS.
At this point, the wrapped key blob has been successfully imported into the target ELS key slot, and the temporary NXP_DIE_KEK_SK has been removed. The imported key is now available for use by ELS-protected cryptographic operations without exposing the underlying key material to application software.
The next step is to validate the imported key by performing the operation it was provisioned for. Depending on the key type, this may include:
A successful cryptographic operation confirms that:
NXP_DIE_KEK_SK derivation completed successfully.For production deployments, this import mechanism provides a secure method for provisioning customer keys generated with the HSM tooling while ensuring that plaintext key material never leaves the ELS security boundary.