Lines Matching refs:keys
90 struct bt_keys *keys; in bt_keys_get_addr() local
99 keys = &key_pool[i]; in bt_keys_get_addr()
101 if (keys->id == id && bt_addr_le_eq(&keys->addr, addr)) { in bt_keys_get_addr()
102 return keys; in bt_keys_get_addr()
105 bt_addr_le_eq(&keys->addr, BT_ADDR_LE_ANY)) { in bt_keys_get_addr()
143 keys = &key_pool[first_free_slot]; in bt_keys_get_addr()
144 keys->id = id; in bt_keys_get_addr()
145 bt_addr_le_copy(&keys->addr, addr); in bt_keys_get_addr()
147 keys->aging_counter = ++aging_counter_val; in bt_keys_get_addr()
148 last_keys_updated = keys; in bt_keys_get_addr()
150 LOG_DBG("created %p for %s", keys, bt_addr_le_str(addr)); in bt_keys_get_addr()
151 return keys; in bt_keys_get_addr()
168 struct bt_keys *keys = &key_pool[i]; in bt_foreach_bond() local
170 if (keys->keys && keys->id == id) { in bt_foreach_bond()
173 bt_addr_le_copy(&info.addr, &keys->addr); in bt_foreach_bond()
183 void bt_keys_foreach_type(enum bt_keys_type type, void (*func)(struct bt_keys *keys, void *data), in bt_keys_foreach_type() argument
191 if ((key_pool[i].keys & type)) { in bt_keys_foreach_type()
206 if ((key_pool[i].keys & type) && key_pool[i].id == id && in bt_keys_find()
217 struct bt_keys *keys; in bt_keys_get_type() local
223 keys = bt_keys_find(type, id, addr); in bt_keys_get_type()
224 if (keys) { in bt_keys_get_type()
225 return keys; in bt_keys_get_type()
228 keys = bt_keys_get_addr(id, addr); in bt_keys_get_type()
229 if (!keys) { in bt_keys_get_type()
233 bt_keys_add_type(keys, type); in bt_keys_get_type()
235 return keys; in bt_keys_get_type()
251 if (!(key_pool[i].keys & BT_KEYS_IRK)) { in bt_keys_find_irk()
264 if (!(key_pool[i].keys & BT_KEYS_IRK)) { in bt_keys_find_irk()
305 void bt_keys_add_type(struct bt_keys *keys, enum bt_keys_type type) in bt_keys_add_type() argument
307 __ASSERT_NO_MSG(keys != NULL); in bt_keys_add_type()
309 keys->keys |= type; in bt_keys_add_type()
312 void bt_keys_clear(struct bt_keys *keys) in bt_keys_clear() argument
314 __ASSERT_NO_MSG(keys != NULL); in bt_keys_clear()
316 LOG_DBG("%s (keys 0x%04x)", bt_addr_le_str(&keys->addr), keys->keys); in bt_keys_clear()
318 if (keys->state & BT_KEYS_ID_ADDED) { in bt_keys_clear()
319 bt_id_del(keys); in bt_keys_clear()
324 bt_settings_delete_keys(keys->id, &keys->addr); in bt_keys_clear()
327 (void)memset(keys, 0, sizeof(*keys)); in bt_keys_clear()
331 int bt_keys_store(struct bt_keys *keys) in bt_keys_store() argument
335 __ASSERT_NO_MSG(keys != NULL); in bt_keys_store()
337 err = bt_settings_store_keys(keys->id, &keys->addr, keys->storage_start, in bt_keys_store()
344 LOG_DBG("Stored keys for %s", bt_addr_le_str(&keys->addr)); in bt_keys_store()
352 struct bt_keys *keys; in keys_set() local
395 keys = bt_keys_find(BT_KEYS_ALL, id, &addr); in keys_set()
396 if (keys) { in keys_set()
397 (void)memset(keys, 0, sizeof(*keys)); in keys_set()
406 keys = bt_keys_get_addr(id, &addr); in keys_set()
407 if (!keys) { in keys_set()
418 memcpy(keys->storage_start, val, len); in keys_set()
421 bt_keys_clear(keys); in keys_set()
426 memcpy(keys->storage_start, val, len); in keys_set()
431 if (aging_counter_val < keys->aging_counter) { in keys_set()
432 aging_counter_val = keys->aging_counter; in keys_set()
438 static void id_add(struct bt_keys *keys, void *user_data) in id_add() argument
440 __ASSERT_NO_MSG(keys != NULL); in id_add()
442 bt_id_add(keys); in id_add()
460 BT_SETTINGS_DEFINE(keys, "keys", keys_set, keys_commit);
469 struct bt_keys *keys = bt_keys_find_addr(id, addr); in bt_keys_update_usage() local
471 if (!keys) { in bt_keys_update_usage()
475 if (last_keys_updated == keys) { in bt_keys_update_usage()
479 keys->aging_counter = ++aging_counter_val; in bt_keys_update_usage()
480 last_keys_updated = keys; in bt_keys_update_usage()
482 LOG_DBG("Aging counter for %s is set to %u", bt_addr_le_str(addr), keys->aging_counter); in bt_keys_update_usage()
485 bt_keys_store(keys); in bt_keys_update_usage()
492 void bt_keys_show_sniffer_info(struct bt_keys *keys, void *data) in bt_keys_show_sniffer_info() argument
496 __ASSERT_NO_MSG(keys != NULL); in bt_keys_show_sniffer_info()
498 if (keys->keys & BT_KEYS_LTK_P256) { in bt_keys_show_sniffer_info()
499 sys_memcpy_swap(ltk, keys->ltk.val, keys->enc_size); in bt_keys_show_sniffer_info()
500 LOG_INF("SC LTK: 0x%s", bt_hex(ltk, keys->enc_size)); in bt_keys_show_sniffer_info()
504 if (keys->keys & BT_KEYS_PERIPH_LTK) { in bt_keys_show_sniffer_info()
505 sys_memcpy_swap(ltk, keys->periph_ltk.val, keys->enc_size); in bt_keys_show_sniffer_info()
506 LOG_INF("Legacy LTK: 0x%s (peripheral)", bt_hex(ltk, keys->enc_size)); in bt_keys_show_sniffer_info()
510 if (keys->keys & BT_KEYS_LTK) { in bt_keys_show_sniffer_info()
511 sys_memcpy_swap(ltk, keys->ltk.val, keys->enc_size); in bt_keys_show_sniffer_info()
512 LOG_INF("Legacy LTK: 0x%s (central)", bt_hex(ltk, keys->enc_size)); in bt_keys_show_sniffer_info()