ccc_kdf.h
Overview
UWB ranging key schedule + SP0 frame crypto (CONFIG_WOZ_ALIRO). Turns the 32-byte URSK into the per-ranging-cycle keys the DW3000 STS engine and the SP0 frames consume, over a single AES block-encrypt primitive.
used by ccc_crypto_mbedtls.c ccc_crypto_psa.c ccc_kdf.c ccc_mac.h ccc_shim.h ccc_shim_rx.c ccc_sts.h
API
##define CCC_URSK_LEN 32
UWB Ranging Secret Key length, bytes (the schedule's root input).
##define CCC_MUPSK1_LEN 16
mUPSK1 length, bytes (AES-CCM\* key for the SP0 Pre-POLL).
##define CCC_MUPSK2_LEN 32
mUPSK2 length, bytes (seed for the UWB-address KDF).
##define CCC_MURSK_LEN 32
mURSK length, bytes (ranging-key seed feeding URSK_KT).
##define CCC_SALTED_HASH_LEN 16
SaltedHash length, bytes (ranging-configuration integrity value).
##define CCC_URSK_KT_LEN 32
URSK_KT length, bytes (per-cycle key-transport intermediate).
##define CCC_DURSK_LEN 16
dURSK length, bytes (per-cycle STS key material).
##define CCC_DUDSK_LEN 16
dUDSK length, bytes (per-cycle timestamp-frame key).
##define CCC_STS_V_LEN 16
STS-V length, bytes (phyHrpUwbStsV, the DW3000 STS_IV).
##define CCC_UAD_LEN 16
UAD length, bytes (the raw UWB-address derivation output).
##define CCC_CMAC_TAG_LEN 16
AES-CMAC tag / one-block output length, bytes.
##define CCC_KEYSOURCE_LEN 4
KeySource length, bytes (KeySourceHigh || KeySourceLow).
##define CCC_DEST_SHORT_ADDR_LEN 2
UWB destination short-address length, bytes.
##define CCC_SRC_LONG_ADDR_LEN 8
UWB source long-address length, bytes (the SP0 nonce prefix).
##define CCC_SP0_NONCE_LEN 13
SP0 AES-CCM\* nonce length, bytes (src-long || frame-ctr || sec-lvl).
##define CCC_SP0_MIC_LEN 8
SP0 Pre-POLL MIC length, bytes (Security Level 6 = ENC-MIC-64).
Fint crypto_aes_ecb_encrypt(const uint8_t *key, size_t key_bits, const uint8_t in[16], uint8_t out[16])
AES block-cipher seam: one 128-bit ECB block encrypt (out may alias in).
Fint ccc_aes_cmac(const uint8_t *key, size_t key_bits, const uint8_t *msg, size_t msg_len, uint8_t tag[CCC_CMAC_TAG_LEN])
AES-CMAC over msg (msg may be NULL iff msg_len is 0).
Fint ccc_derive_mupsk1(const uint8_t ursk[CCC_URSK_LEN], uint8_t out[CCC_MUPSK1_LEN])
Derive mUPSK1 — the SP0 Pre-POLL AES-CCM* key.
Fint ccc_derive_mupsk2(const uint8_t ursk[CCC_URSK_LEN], uint8_t out[CCC_MUPSK2_LEN])
Derive mUPSK2 — the seed for the UWB-address KDF.
Fint ccc_derive_mursk(const uint8_t ursk[CCC_URSK_LEN], uint8_t out[CCC_MURSK_LEN])
Derive mURSK — the ranging-key seed feeding URSK_KT.
Fint ccc_derive_salted_hash(const uint8_t ursk[CCC_URSK_LEN], const uint8_t *ranging_config, size_t rc_len, uint8_t out[CCC_SALTED_HASH_LEN])
Derive SaltedHash from the serialized ranging configuration.
Fint ccc_derive_ursk_kt(const uint8_t mursk[CCC_MURSK_LEN], uint32_t sts_index, uint8_t out[CCC_URSK_KT_LEN])
Derive URSK_KT — once per ranging cycle, keyed by the STS index.
Fint ccc_derive_dursk(const uint8_t ursk_kt[CCC_URSK_KT_LEN], const uint8_t salted_hash[CCC_SALTED_HASH_LEN], uint8_t out[CCC_DURSK_LEN])
Derive dURSK — per-cycle STS key material.
Fint ccc_derive_dudsk(const uint8_t ursk_kt[CCC_URSK_KT_LEN], const uint8_t salted_hash[CCC_SALTED_HASH_LEN], uint8_t out[CCC_DUDSK_LEN])
Derive dUDSK — per-cycle SP0 timestamp-frame key.
Fint ccc_derive_sts_v(const uint8_t salted_hash[CCC_SALTED_HASH_LEN], uint32_t sts_index, uint8_t out[CCC_STS_V_LEN])
Derive STS-V (phyHrpUwbStsV) — the per-PPDU STS IV for the DW3000 (out may alias salted_hash).
Fint ccc_derive_uad(const uint8_t mupsk2[CCC_MUPSK2_LEN], uint32_t sts_index0, uint8_t out[CCC_UAD_LEN])
Derive UAD — the raw UWB-address derivation output.
Fint ccc_uad_addresses(const uint8_t uad[CCC_UAD_LEN], uint8_t keysource[CCC_KEYSOURCE_LEN], uint8_t dest_short_addr[CCC_DEST_SHORT_ADDR_LEN], uint8_t src_long_addr[CCC_SRC_LONG_ADDR_LEN])
Split UAD into the UWB addresses (KeySource, dest short, src long).
Fint ccc_sp0_encrypt(const uint8_t key[CCC_MUPSK1_LEN], const uint8_t src_long_addr[CCC_SRC_LONG_ADDR_LEN], uint32_t frame_counter, const uint8_t *mhr, size_t mhr_len, const uint8_t *payload, size_t payload_len, uint8_t *ciphertext_out, uint8_t mic_out[CCC_SP0_MIC_LEN])
Encrypt + authenticate an SP0 data frame (AES-CCM*, ENC-MIC-64).
Fint ccc_sp0_decrypt(const uint8_t key[CCC_MUPSK1_LEN], const uint8_t src_long_addr[CCC_SRC_LONG_ADDR_LEN], uint32_t frame_counter, const uint8_t *mhr, size_t mhr_len, const uint8_t *ciphertext, size_t ciphertext_len, const uint8_t mic[CCC_SP0_MIC_LEN], uint8_t *payload_out)
Decrypt + verify an SP0 data frame; zeroes plaintext and returns -EBADMSG on MIC failure.