summaryrefslogtreecommitdiff
path: root/mesh/keyring.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesh/keyring.c')
-rw-r--r--mesh/keyring.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/mesh/keyring.c b/mesh/keyring.c
index 995a4b88f..1e1de3e54 100644
--- a/mesh/keyring.c
+++ b/mesh/keyring.c
@@ -30,9 +30,9 @@
#include "mesh/node.h"
#include "mesh/keyring.h"
-const char *dev_key_dir = "/dev_keys";
-const char *app_key_dir = "/app_keys";
-const char *net_key_dir = "/net_keys";
+static const char *dev_key_dir = "/dev_keys";
+static const char *app_key_dir = "/app_keys";
+static const char *net_key_dir = "/net_keys";
static int open_key_file(struct mesh_node *node, const char *key_dir,
uint16_t idx, int flags)
@@ -371,6 +371,28 @@ bool keyring_del_remote_dev_key(struct mesh_node *node, uint16_t unicast,
return true;
}
+bool keyring_del_remote_dev_key_all(struct mesh_node *node, uint16_t unicast)
+{
+ uint8_t dev_key[16];
+ uint8_t test_key[16];
+ uint8_t cnt = 1;
+
+ if (!keyring_get_remote_dev_key(node, unicast, dev_key))
+ return false;
+
+ while (keyring_get_remote_dev_key(node, unicast + cnt, test_key)) {
+ if (memcmp(dev_key, test_key, sizeof(dev_key)))
+ break;
+
+ cnt++;
+ }
+
+ if (cnt > 1)
+ return keyring_del_remote_dev_key(node, unicast + 1, cnt - 1);
+
+ return true;
+}
+
static DIR *open_key_dir(const char *node_path, const char *key_dir_name)
{
char dir_path[PATH_MAX];