modules/woz_uwb/src/ccc/ccc_kdf.h
asxeem/openaliro
Module

ccc_kdf.h

modules/woz_uwb/src/ccc/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

modules/woz_uwb/src/ccc/ccc_kdf.h:16

UWB Ranging Secret Key length, bytes (the schedule's root input).

##define CCC_MUPSK1_LEN 16

modules/woz_uwb/src/ccc/ccc_kdf.h:18

mUPSK1 length, bytes (AES-CCM\* key for the SP0 Pre-POLL).

##define CCC_MUPSK2_LEN 32

modules/woz_uwb/src/ccc/ccc_kdf.h:20

mUPSK2 length, bytes (seed for the UWB-address KDF).

##define CCC_MURSK_LEN 32

modules/woz_uwb/src/ccc/ccc_kdf.h:22

mURSK length, bytes (ranging-key seed feeding URSK_KT).

##define CCC_SALTED_HASH_LEN 16

modules/woz_uwb/src/ccc/ccc_kdf.h:24

SaltedHash length, bytes (ranging-configuration integrity value).

##define CCC_URSK_KT_LEN 32

modules/woz_uwb/src/ccc/ccc_kdf.h:26

URSK_KT length, bytes (per-cycle key-transport intermediate).

##define CCC_DURSK_LEN 16

modules/woz_uwb/src/ccc/ccc_kdf.h:28

dURSK length, bytes (per-cycle STS key material).

##define CCC_DUDSK_LEN 16

modules/woz_uwb/src/ccc/ccc_kdf.h:30

dUDSK length, bytes (per-cycle timestamp-frame key).

##define CCC_STS_V_LEN 16

modules/woz_uwb/src/ccc/ccc_kdf.h:32

STS-V length, bytes (phyHrpUwbStsV, the DW3000 STS_IV).

##define CCC_UAD_LEN 16

modules/woz_uwb/src/ccc/ccc_kdf.h:34

UAD length, bytes (the raw UWB-address derivation output).

##define CCC_CMAC_TAG_LEN 16

modules/woz_uwb/src/ccc/ccc_kdf.h:36

AES-CMAC tag / one-block output length, bytes.

##define CCC_KEYSOURCE_LEN 4

modules/woz_uwb/src/ccc/ccc_kdf.h:38

KeySource length, bytes (KeySourceHigh || KeySourceLow).

##define CCC_DEST_SHORT_ADDR_LEN 2

modules/woz_uwb/src/ccc/ccc_kdf.h:40

UWB destination short-address length, bytes.

##define CCC_SRC_LONG_ADDR_LEN 8

modules/woz_uwb/src/ccc/ccc_kdf.h:42

UWB source long-address length, bytes (the SP0 nonce prefix).

##define CCC_SP0_NONCE_LEN 13

modules/woz_uwb/src/ccc/ccc_kdf.h:44

SP0 AES-CCM\* nonce length, bytes (src-long || frame-ctr || sec-lvl).

##define CCC_SP0_MIC_LEN 8

modules/woz_uwb/src/ccc/ccc_kdf.h:46

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

modules/woz_uwb/src/ccc/ccc_kdf.h:49

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

modules/woz_uwb/src/ccc/ccc_kdf.h:53

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

modules/woz_uwb/src/ccc/ccc_kdf.h:57

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

modules/woz_uwb/src/ccc/ccc_kdf.h:60

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

modules/woz_uwb/src/ccc/ccc_kdf.h:63

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

modules/woz_uwb/src/ccc/ccc_kdf.h:66

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

modules/woz_uwb/src/ccc/ccc_kdf.h:70

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

modules/woz_uwb/src/ccc/ccc_kdf.h:74

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

modules/woz_uwb/src/ccc/ccc_kdf.h:78

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

modules/woz_uwb/src/ccc/ccc_kdf.h:83

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

modules/woz_uwb/src/ccc/ccc_kdf.h:87

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

modules/woz_uwb/src/ccc/ccc_kdf.h:91

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

modules/woz_uwb/src/ccc/ccc_kdf.h:96

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)

modules/woz_uwb/src/ccc/ccc_kdf.h:103

Decrypt + verify an SP0 data frame; zeroes plaintext and returns -EBADMSG on MIC failure.