summaryrefslogtreecommitdiff
path: root/monitor/keys.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2023-03-24 16:38:56 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2023-03-27 13:56:49 -0700
commit011e562a98a8b8c278391bc64d9dc2c8df0a5585 (patch)
tree645a00bfeb505f9e007247982f8ccd82a41105cd /monitor/keys.c
parent2719bb5aaf6df77edb4bf7c2654c178836300c73 (diff)
downloadbluez-011e562a98a8b8c278391bc64d9dc2c8df0a5585.tar.gz
monitor: Cache IRK being parsed
This caches any IRK being parsed so they can be used to resolve addresses later which fixes the problem of only being able to resolve addresses if the monitor happens to be active while SMP exchange the keys.
Diffstat (limited to 'monitor/keys.c')
-rw-r--r--monitor/keys.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/monitor/keys.c b/monitor/keys.c
index d2fa3b23f..c1eebae82 100644
--- a/monitor/keys.c
+++ b/monitor/keys.c
@@ -112,3 +112,29 @@ bool keys_resolve_identity(const uint8_t addr[6], uint8_t ident[6],
return false;
}
+
+static bool match_key(const void *data, const void *match_data)
+{
+ const struct irk_data *irk = data;
+ const uint8_t *key = match_data;
+
+ return !memcmp(irk->key, key, 16);
+}
+
+bool keys_add_identity(const uint8_t addr[6], uint8_t addr_type,
+ const uint8_t key[16])
+{
+ struct irk_data *irk;
+
+ irk = queue_find(irk_list, match_key, key);
+ if (!irk) {
+ irk = new0(struct irk_data, 1);
+ memcpy(irk->key, key, 16);
+ queue_push_tail(irk_list, irk);
+ }
+
+ memcpy(irk->addr, addr, 6);
+ irk->addr_type = addr_type;
+
+ return true;
+}