openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
ccc_kdf.h File Reference

UWB ranging key schedule + SP0 frame crypto (CONFIG_WOZ_ALIRO). More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for ccc_kdf.h:

Go to the source code of this file.

Macros

#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).
 

Functions

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).
 
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).
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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).
 
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.
 
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).
 
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).
 
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.
 

Detailed Description

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.

Function Documentation

◆ ccc_aes_cmac()

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).

AES-CMAC over msg (msg may be NULL iff msg_len is 0).

◆ ccc_derive_dudsk()

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.

Derive dUDSK — per-cycle SP0 timestamp-frame key.

◆ ccc_derive_dursk()

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.

Derive dURSK — per-cycle STS key material.

◆ ccc_derive_mupsk1()

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.

Derive mUPSK1 — the SP0 Pre-POLL AES-CCM* key.

◆ ccc_derive_mupsk2()

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.

Derive mUPSK2 — the seed for the UWB-address KDF.

◆ ccc_derive_mursk()

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.

Derive mURSK — the ranging-key seed feeding URSK_KT.

◆ ccc_derive_sts_v()

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).

Derive STS-V (phyHrpUwbStsV) — the per-PPDU STS IV for the DW3000 (out may alias salted_hash).

◆ ccc_derive_uad()

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.

Derive UAD — the raw UWB-address derivation output.

◆ ccc_derive_ursk_kt()

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.

Derive URSK_KT — once per ranging cycle, keyed by the STS index.

◆ ccc_uad_addresses()

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).

Split UAD into the UWB addresses (KeySource, dest short, src long).

◆ crypto_aes_ecb_encrypt()

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).

AES block-cipher seam: one 128-bit ECB block encrypt (out may alias in).