From ea75a5e683da0f69aeeae926fcd4f7491a151d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Wed, 6 Oct 2021 08:05:48 +0200 Subject: [PATCH] host/mesh: Update seqnum when re-encrypting for friend Sets the sequence number when re-encrypting messages from the friend to the lpn. This is port of 512444d863f0e4de69ea600dda37b11f032e9707 --- nimble/host/mesh/src/friend.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nimble/host/mesh/src/friend.c b/nimble/host/mesh/src/friend.c index ff34eda9c..b544a7830 100644 --- a/nimble/host/mesh/src/friend.c +++ b/nimble/host/mesh/src/friend.c @@ -431,6 +431,9 @@ static int unseg_app_sdu_prepare(struct bt_mesh_friend *frnd, return 0; } + BT_DBG("Re-encrypting friend pdu (SeqNum %06x -> %06x)", + meta.crypto.seq_num, bt_mesh.seq); + err = unseg_app_sdu_unpack(frnd, buf, &meta); if (err) { return err; @@ -446,6 +449,8 @@ static int unseg_app_sdu_prepare(struct bt_mesh_friend *frnd, BT_DBG("Re-encrypting friend pdu (SeqNum %06x -> %06x)", meta.crypto.seq_num, bt_mesh.seq); + meta.crypto.seq_num = bt_mesh.seq; + err = unseg_app_sdu_decrypt(frnd, buf, &meta); if (err) { BT_WARN("Decryption failed! %d", err);