mesh: Add key storage
Subsystems (2)
PATCH v2 1/1 mesh: Add key storage
This implements internal key storage add/delete/fetch for the three basic key types managed in Mesh: Network, Application and Device.
This key storage is separate from keys assigned to nodes within the mesh, and are used to support Configuration Client functionality.
--- Makefile.mesh | 1 + mesh/keyring.c | 315 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mesh/keyring.h | 49 +++++++++ mesh/node.c | 13 +++ mesh/node.h | 2 + mesh/storage.c | 92 ++++++++++++----- mesh/storage.h | 16 +++ 7 files changed, 460 insertions(+), 28 deletions(-) create mode 100644 mesh/keyring.c create mode 100644 mesh/keyring.h
Makefile.mesh +1 -0
@@ -25,6 +25,7 @@ mesh_sources = mesh/mesh.h mesh/mesh.c \ mesh/agent.h mesh/agent.c \ mesh/prov-acceptor.c mesh/prov-initiator.c \ mesh/pb-adv.h mesh/pb-adv.c \ + mesh/keyring.h mesh/keyring.c \ mesh/mesh-defs.h libexec_PROGRAMS += mesh/bluetooth-meshd
mesh/keyring.c new file +315 -0
315 lines not on this page · raw message
mesh/keyring.h new file +49 -0
49 lines not on this page · raw message
mesh/node.c +13 -0
@@ -79,6 +79,7 @@ struct mesh_node {char *path;void *jconfig;char *cfg_file; +char *node_path;uint32_t disc_watch;time_t upd_sec;uint32_t seq_number;
@@ -235,6 +236,8 @@ static void free_node_resources(void *data)l_free (node->comp);l_free (node->app_path);l_free (node->owner); +l_free (node->cfg_file); +l_free (node->node_path);if (node->disc_watch)l_dbus_remove_watch (dbus_get_bus (), node->disc_watch);
@@ -1883,6 +1886,16 @@ char *node_cfg_file_get(struct mesh_node *node)return node->cfg_file; } +void node_path_set (struct mesh_node *node,char *path) +{ + node->node_path = path; +} + +char *node_path_get (struct mesh_node *node) +{ +return node->node_path; +} +struct mesh_net *node_get_net (struct mesh_node *node) {return node->net;
mesh/node.h +2 -0
@@ -97,3 +97,5 @@ void node_jconfig_set(struct mesh_node *node, void *jconfig);void *node_jconfig_get (struct mesh_node *node);void node_cfg_file_set (struct mesh_node *node,char *cfg);char *node_cfg_file_get (struct mesh_node *node); +void node_path_set (struct mesh_node *node,char *path); +char *node_path_get (struct mesh_node *node);
mesh/storage.c +64 -28
136 lines not on this page · raw message
mesh/storage.h +16 -0
@@ -20,6 +20,20 @@struct mesh_net ;struct mesh_node ; +struct net_key_storage { +uint16_t net_idx; +uint8_t phase; +uint8_t old_key[16 ]; +uint8_t new_key[16 ]; +}; + +struct app_key_storage { +uint16_t app_idx; +uint16_t net_idx; +uint8_t old_key[16 ]; +uint8_t new_key[16 ]; +}; +bool storage_load_nodes (const char *dir);bool storage_create_node_config (struct mesh_node *node,void *db_node);void storage_remove_node_config (struct mesh_node *node);
@@ -49,3 +63,5 @@ bool storage_set_device_key(struct mesh_node *node, uint8_t dev_key[16]);bool storage_set_unicast (struct mesh_node *node,uint16_t unicast);bool storage_set_key_refresh_phase (struct mesh_net *net,uint16_t net_idx,uint8_t phase); +int storage_create_dir (const char *dirname); +char *storage_path_get (struct mesh_node *node);
Signature · 1 line
2.14.5