Skip to contentSkip to conversation

mesh: Fix app payload decryption for virtual labels

PATCH Applied Inga Stotland 2 participants 2 messages Feb 18, 2020 – Feb 19, 2020 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mesh: Fix app payload decryption for virtual labels

This fixes a bug when a virtual label and its size hasn't been passed to a decryption function: instead of always using NULL pointer for label and 0 for lable size, use actual virtual label info if decrypting a payload addressed to a virtual destination.

---
 mesh/model.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
mesh/model.c +4 -4
index 072972fda..4e5856292 100644
@@ -444,8 +444,8 @@ static int app_packet_decrypt(struct mesh_net *net, const uint8_t *data,
 			continue;
 
 		if (old_key && old_key_aid == key_aid) {
-			decrypted = mesh_crypto_payload_decrypt(NULL, 0, data,
-						size, szmict, src, dst, key_aid,
+			decrypted = mesh_crypto_payload_decrypt(virt, virt_size,
+					data, size, szmict, src, dst, key_aid,
 						seq, iv_idx, out, old_key);
 
 			if (decrypted) {
@@ -457,8 +457,8 @@ static int app_packet_decrypt(struct mesh_net *net, const uint8_t *data,
 		}
 
 		if (new_key && new_key_aid == key_aid) {
-			decrypted = mesh_crypto_payload_decrypt(NULL, 0, data,
-						size, szmict, src, dst, key_aid,
+			decrypted = mesh_crypto_payload_decrypt(virt, virt_size,
+					data, size, szmict, src, dst, key_aid,
 						seq, iv_idx, out, new_key);
 
 			if (decrypted) {
Signature · 1 line
2.21.1
Applied
#1 lore raw

Applied

Quoted 34 lines · Inga Stotland

This fixes a bug when a virtual label and its size hasn't been passed to a decryption function: instead of always using NULL pointer for label and 0 for lable size, use actual virtual label info if decrypting a payload addressed to a virtual destination.

---
 mesh/model.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
mesh/model.c +4 -4
index 072972fda..4e5856292 100644
@@ -444,8 +444,8 @@ static int app_packet_decrypt(struct mesh_net *net, const uint8_t *data,
 			continue;
 
 		if (old_key && old_key_aid == key_aid) {
-			decrypted = mesh_crypto_payload_decrypt(NULL, 0, data,
-						size, szmict, src, dst, key_aid,
+			decrypted = mesh_crypto_payload_decrypt(virt, virt_size,
+					data, size, szmict, src, dst, key_aid,
 						seq, iv_idx, out, old_key);
 
 			if (decrypted) {
@@ -457,8 +457,8 @@ static int app_packet_decrypt(struct mesh_net *net, const uint8_t *data,
 		}
 
 		if (new_key && new_key_aid == key_aid) {
-			decrypted = mesh_crypto_payload_decrypt(NULL, 0, data,
-						size, szmict, src, dst, key_aid,
+			decrypted = mesh_crypto_payload_decrypt(virt, virt_size,
+					data, size, szmict, src, dst, key_aid,
 						seq, iv_idx, out, new_key);
 
 			if (decrypted) {