12#ifndef PACKET_RF4CE_SECUR_H
13#define PACKET_RF4CE_SECUR_H
22#define RF4CE_IEEE_ADDR_LEN 8
23#define RF4CE_SHORT_ADDR_LEN 2
25#define RF4CE_MIN_NWK_LENGTH 5
26#define RF4CE_MAX_NWK_LENGTH 148
28#define RF4CE_VENDOR_SECRET_STORAGE_SIZE 64
29#define RF4CE_NWK_KEY_STORAGE_SIZE 64
30#define RF4CE_ADDR_TABLE_SIZE (RF4CE_NWK_KEY_STORAGE_SIZE * 2)
32#define RF4CE_NWK_KEY_SEED_DATA_LENGTH 80
36#define RF4CE_CCM_NONCE_LEN (15 - RF4CE_CCM_L)
37#define RF4CE_SECUR_CONTROL 5
39#define KEY_LEN SEC_STR_LEN
42 uint8_t nwk_key_seed_latest[RF4CE_NWK_KEY_SEED_DATA_LENGTH];
43 uint8_t nwk_key_seed_prev[RF4CE_NWK_KEY_SEED_DATA_LENGTH];
44 uint8_t nwk_key_seed[RF4CE_NWK_KEY_SEED_DATA_LENGTH];
45 uint8_t controller_addr[RF4CE_IEEE_ADDR_LEN];
46 uint8_t target_addr[RF4CE_IEEE_ADDR_LEN];
47 uint8_t nwk_key_exchange_transfer_expected;
48 uint8_t nwk_key_exchange_transfer_received;
51#define RF4CE_PROFILE_CMD_KEY_EXCHANGE_RAND_A_LENGTH 8
52#define RF4CE_PROFILE_CMD_KEY_EXCHANGE_RAND_B_LENGTH 8
54#define RF4CE_PROFILE_CMD_KEY_EXCHANGE_RAND_AB_LENGTH \
55 (RF4CE_PROFILE_CMD_KEY_EXCHANGE_RAND_A_LENGTH \
56 + RF4CE_PROFILE_CMD_KEY_EXCHANGE_RAND_B_LENGTH)
58#define RF4CE_PROFILE_CMD_KEY_EXCHANGE_TAG_A_LENGTH 4
59#define RF4CE_PROFILE_CMD_KEY_EXCHANGE_TAG_B_LENGTH 4
61#define RF4CE_KEY_EXCHANGE_CONTEXT_LENGTH 9
62#define RF4CE_KEY_EXCHANGE_LABEL_LENGTH (2 * (RF4CE_IEEE_ADDR_LEN))
64#define RF4CE_CMAC_ARG_2_LENGTH \
65 (RF4CE_KEY_EXCHANGE_CONTEXT_LENGTH \
66 + RF4CE_KEY_EXCHANGE_LABEL_LENGTH \
73#define CONTEXT_STR "RF4CE GDP"
74#define CONTEXT_STR_LEN 9
76extern uint8_t DEFAULT_SECRET[SEC_STR_LEN];
79 uint8_t rand_a[RF4CE_PROFILE_CMD_KEY_EXCHANGE_RAND_A_LENGTH];
80 uint8_t rand_b[RF4CE_PROFILE_CMD_KEY_EXCHANGE_RAND_B_LENGTH];
81 uint8_t mac_a[RF4CE_IEEE_ADDR_LEN];
82 uint8_t mac_b[RF4CE_IEEE_ADDR_LEN];
86void rf4ce_aes_cmac(
unsigned char *
input,
unsigned long length,
unsigned char *key,
unsigned char *mac_value);
89 uint8_t ieee_addr[RF4CE_IEEE_ADDR_LEN];
95 uint8_t nwk_key[KEY_LEN];
104 uint8_t secret[SEC_STR_LEN];
114void keypair_context_init(
const uint8_t *controller_ieee,
const uint8_t *target_ieee, uint8_t expected_transfer_count);
115void keypair_context_update_seed(uint8_t *seed, uint8_t seed_seqn);
117void nwk_key_storage_add_entry(uint8_t *nwk_key,
addr_entry_t *controller_addr_ent,
addr_entry_t *target_addr_ent,
bool key_from_gui,
bool is_pairing_key);
118void nwk_key_storage_release_entry(uint8_t *nwk_key,
bool key_from_gui);
120void rf4ce_addr_table_add_addrs(
const void *ieee_addr, uint16_t short_addr);
121bool rf4ce_addr_table_get_ieee_addr(uint8_t *ieee_addr,
packet_info *pinfo,
bool is_src);
122addr_entry_t *rf4ce_addr_table_get_addr_entry_by_ieee(uint8_t *ieee_addr);
124void key_exchange_context_init(
void);
126void key_exchange_context_start_procedure(
void);
127void key_exchange_context_stop_procedure(
void);
128bool key_exchange_context_is_procedure_started(
void);
130void key_exchange_context_set_rand_a(uint8_t *rand_a);
131void key_exchange_context_set_rand_b(uint8_t *rand_b);
133void key_exchange_context_set_mac_a(uint8_t *mac_a);
134void key_exchange_context_set_mac_b(uint8_t *mac_b);
136void key_exchange_calc_key(uint32_t tag_b_pack);
138void vendor_secret_storage_add_entry(uint8_t *secret);
139void vendor_secret_storage_release_entry(uint8_t *secret);
141void rf4ce_secur_cleanup(
void);
146 uint16_t payload_offset,
148 uint8_t src_ieee[RF4CE_IEEE_ADDR_LEN],
149 uint8_t dst_ieee[RF4CE_IEEE_ADDR_LEN]);
Definition packet_info.h:43
Definition packet-rf4ce-secur.h:88
Definition packet-isakmp.c:1889
Definition packet-rf4ce-secur.h:78
Definition packet-rf4ce-secur.h:41
Definition packet-rf4ce-secur.h:94
Definition packet-rf4ce-secur.h:108
Definition packet-rf4ce-secur.h:103