---
mesh/model.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/mesh/model.c b/mesh/model.c
index f46cce7c1..324d75dd9 100644
--- a/mesh/model.c
+++ b/mesh/model.c
@@ -39,6 +39,7 @@
#include "mesh/dbus.h"
#include "mesh/util.h"
#include "mesh/model.h"
+#include "mesh/keyring.h"
/* Divide and round to ceiling (up) to calculate segment count */
#define CEILDIV(val, div) (((val) + (div) - 1) / (div))
@@ -369,6 +370,14 @@ static int dev_packet_decrypt(struct mesh_node *node, const uint8_t *data,
dst, key_id, seq, iv_idx, out, key))
return APP_IDX_DEV_LOCAL;
+ if (!keyring_get_remote_dev_key(node, src, dev_key))
+ return -1;
+
+ key = dev_key;
+ if (mesh_crypto_payload_decrypt(NULL, 0, data, size, szmict, src,
+ dst, key_id, seq, iv_idx, out, key))
+ return APP_IDX_DEV_REMOTE;
+
return -1;
}
@@ -852,7 +861,10 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0,
models = node_get_element_models(node, i, NULL);
/* Internal models */
- l_queue_foreach(models, forward_model, &forward);
+ if (decrypt_idx != APP_IDX_DEV_REMOTE)
+ l_queue_foreach(models, forward_model, &forward);
+ else
+ forward.has_dst = true;
/*
* Cycle through external models if the message has not been
--
2.19.1