+void _bt_mesh_keys_set_net_key_phase(_bt_mesh_cdb_t *cfg,
+ uint16_t net_idx, uint8_t phase, bool save)
+{
+ struct mesh_net_key_t *key;
+ struct mesh_network_t *network;
+
+ network = l_queue_find(networks, __mesh_net_uuid_match, cfg->uuid);
+ if (!network)
+ return;
+
+ if (!network->net_keys)
+ return;
+
+ key = l_queue_find(network->net_keys,
+ __mesh_net_idx_match, L_UINT_TO_PTR(net_idx));
+ if (!key)
+ return;
+
+ key->phase = phase;
+
+ if (save && !_bt_mesh_conf_set_phase_network_key(cfg,
+ net_idx, phase))
+ BT_INFO("Failed to save updated KR phase\n");
+}
+
+void _bt_mesh_keys_del_net_key(uint8_t net_uuid[],
+ uint16_t idx, _bt_mesh_cdb_t *cfg)
+{
+ struct mesh_net_key_t *key;
+ struct mesh_network_t *network;
+ BT_INFO("Mesh:Keys: Delete new netkey for Network KeyIDx [%u]",
+ idx);
+
+ network = l_queue_find(networks, __mesh_net_uuid_match, net_uuid);
+ if (!network)
+ return;
+
+ if (!network->net_keys)
+ return;
+
+ key = l_queue_remove_if(network->net_keys,
+ __mesh_net_idx_match, L_UINT_TO_PTR(idx));
+ if (!key)
+ return;
+
+ l_queue_foreach_remove(key->app_keys,
+ __mesh_delete_bound_appkey, cfg);
+ l_free(key);
+}
+