mesh: Fix set friend_cred flag incorrectly
Only set friend_cred to true when friendship established and
use friend cred security material decryption successfully.
this is port of
@@ -585,7 +585,6 @@ bool bt_mesh_net_cred_find(struct bt_mesh_net_rx *rx, struct os_mbuf *in,
BT_DBG("");
- rx->friend_cred = 1U;
#if MYNEWT_VAL(BLE_MESH_LOW_POWER)
if (bt_mesh_lpn_established()) {
rx->sub = bt_mesh.lpn.sub;
@@ -597,6 +596,7 @@ bool bt_mesh_net_cred_find(struct bt_mesh_net_rx *rx, struct os_mbuf *in,
if (cb(rx, in, out, &bt_mesh.lpn.cred[j])) {
rx->new_key = (j > 0);
+ rx->friend_cred = 1U;
return true;
}
}
@@ -630,6 +630,7 @@ bool bt_mesh_net_cred_find(struct bt_mesh_net_rx *rx, struct os_mbuf *in,
if (cb(rx, in, out, &frnd->cred[j])) {
rx->new_key = (j > 0);
+ rx->friend_cred = 1U;
return true;
}
}
@@ -649,6 +650,7 @@ bool bt_mesh_net_cred_find(struct bt_mesh_net_rx *rx, struct os_mbuf *in,
if (cb(rx, in, out, &rx->sub->keys[j].msg)) {
rx->new_key = (j > 0);
+ rx->friend_cred = 0U;
return true;
}
}
