summaryrefslogtreecommitdiff
path: root/mesh/model.c
diff options
context:
space:
mode:
authorBrian Gix <brian.gix@intel.com>2022-10-25 14:33:48 -0700
committerBrian Gix <brian.gix@gmail.com>2023-01-30 16:14:41 -0800
commitf3243ecba0a2a062021e461afc4fdc91e480f510 (patch)
tree7ed2394f9483cfceaa6cb8597a6092f2cdc972e0 /mesh/model.c
parent265c12dc96081b969a60e2b5baad6087940cd7be (diff)
downloadbluez-f3243ecba0a2a062021e461afc4fdc91e480f510.tar.gz
mesh: Add Remote Provisioning
Add Remote Provisioning Server Add Remote Provisioning Client Remove local scanning/provisioning Add delete-all dev key function Add NPPI procedures
Diffstat (limited to 'mesh/model.c')
-rw-r--r--mesh/model.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/mesh/model.c b/mesh/model.c
index d48e6ef12..e2babea10 100644
--- a/mesh/model.c
+++ b/mesh/model.c
@@ -24,6 +24,8 @@
#include "mesh/net.h"
#include "mesh/appkey.h"
#include "mesh/cfgmod.h"
+#include "mesh/prov.h"
+#include "mesh/remprv.h"
#include "mesh/error.h"
#include "mesh/dbus.h"
#include "mesh/util.h"
@@ -76,6 +78,9 @@ static bool is_internal(uint32_t id)
if (id == CONFIG_SRV_MODEL || id == CONFIG_CLI_MODEL)
return true;
+ if (id == REM_PROV_SRV_MODEL || id == REM_PROV_CLI_MODEL)
+ return true;
+
return false;
}
@@ -457,13 +462,25 @@ static int dev_packet_decrypt(struct mesh_node *node, const uint8_t *data,
dst, key_aid, seq, iv_idx, out, key))
return APP_IDX_DEV_LOCAL;
- if (!keyring_get_remote_dev_key(node, src, dev_key))
+ key = dev_key;
+
+ if (keyring_get_remote_dev_key(node, src, dev_key)) {
+ if (mesh_crypto_payload_decrypt(NULL, 0, data, size, szmict,
+ src, dst, key_aid, seq, iv_idx, out, key))
+ return APP_IDX_DEV_REMOTE;
+ }
+
+ /* See if there is a local Device Key Candidate as last resort */
+ if (!node_get_device_key_candidate(node, dev_key))
return -1;
- key = dev_key;
- if (mesh_crypto_payload_decrypt(NULL, 0, data, size, szmict, src,
- dst, key_aid, seq, iv_idx, out, key))
- return APP_IDX_DEV_REMOTE;
+ if (mesh_crypto_payload_decrypt(NULL, 0, data, size, szmict,
+ src, dst, key_aid, seq, iv_idx, out, key)) {
+
+ /* If candidate dev_key worked, it is considered finalized */
+ node_finalize_candidate(node);
+ return APP_IDX_DEV_LOCAL;
+ }
return -1;
}