16#define CCC_URSK_LEN 32
18#define CCC_MUPSK1_LEN 16
20#define CCC_MUPSK2_LEN 32
22#define CCC_MURSK_LEN 32
24#define CCC_SALTED_HASH_LEN 16
26#define CCC_URSK_KT_LEN 32
28#define CCC_DURSK_LEN 16
30#define CCC_DUDSK_LEN 16
32#define CCC_STS_V_LEN 16
36#define CCC_CMAC_TAG_LEN 16
38#define CCC_KEYSOURCE_LEN 4
40#define CCC_DEST_SHORT_ADDR_LEN 2
42#define CCC_SRC_LONG_ADDR_LEN 8
44#define CCC_SP0_NONCE_LEN 13
46#define CCC_SP0_MIC_LEN 8
53int ccc_aes_cmac(
const uint8_t *key,
size_t key_bits,
const uint8_t *msg,
size_t msg_len,
98 const uint8_t *mhr,
size_t mhr_len,
const uint8_t *payload,
size_t payload_len,
105 const uint8_t *mhr,
size_t mhr_len,
const uint8_t *ciphertext,
107 uint8_t *payload_out);
int 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).
Definition ccc_kdf.c:602
#define CCC_CMAC_TAG_LEN
AES-CMAC tag / one-block output length, bytes.
Definition ccc_kdf.h:36
int 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.
Definition ccc_kdf.c:380
#define CCC_DURSK_LEN
dURSK length, bytes (per-cycle STS key material).
Definition ccc_kdf.h:28
int 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.
Definition ccc_kdf.c:229
int 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.
Definition ccc_kdf.c:217
#define CCC_URSK_LEN
UWB Ranging Secret Key length, bytes (the schedule's root input).
Definition ccc_kdf.h:16
#define CCC_SALTED_HASH_LEN
SaltedHash length, bytes (ranging-configuration integrity value).
Definition ccc_kdf.h:24
#define CCC_UAD_LEN
UAD length, bytes (the raw UWB-address derivation output).
Definition ccc_kdf.h:34
#define CCC_SP0_MIC_LEN
SP0 Pre-POLL MIC length, bytes (Security Level 6 = ENC-MIC-64).
Definition ccc_kdf.h:46
#define CCC_MUPSK1_LEN
mUPSK1 length, bytes (AES-CCM* key for the SP0 Pre-POLL).
Definition ccc_kdf.h:18
int 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).
Definition ccc_kdf.c:425
#define CCC_SRC_LONG_ADDR_LEN
UWB source long-address length, bytes (the SP0 nonce prefix).
Definition ccc_kdf.h:42
#define CCC_DUDSK_LEN
dUDSK length, bytes (per-cycle timestamp-frame key).
Definition ccc_kdf.h:30
int 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).
Definition ccc_kdf.c:364
int 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.
Definition ccc_kdf.c:294
int 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.
Definition ccc_kdf.c:634
int 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.
Definition ccc_kdf.c:268
int 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.
Definition ccc_kdf.c:249
#define CCC_MUPSK2_LEN
mUPSK2 length, bytes (seed for the UWB-address KDF).
Definition ccc_kdf.h:20
#define CCC_KEYSOURCE_LEN
KeySource length, bytes (KeySourceHigh || KeySourceLow).
Definition ccc_kdf.h:38
int 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).
Definition ccc_crypto_mbedtls.c:17
#define CCC_DEST_SHORT_ADDR_LEN
UWB destination short-address length, bytes.
Definition ccc_kdf.h:40
int 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).
Definition ccc_kdf.c:88
int 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.
Definition ccc_kdf.c:352
#define CCC_URSK_KT_LEN
URSK_KT length, bytes (per-cycle key-transport intermediate).
Definition ccc_kdf.h:26
int 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.
Definition ccc_kdf.c:340
#define CCC_STS_V_LEN
STS-V length, bytes (phyHrpUwbStsV, the DW3000 STS_IV).
Definition ccc_kdf.h:32
#define CCC_MURSK_LEN
mURSK length, bytes (ranging-key seed feeding URSK_KT).
Definition ccc_kdf.h:22