Skip to content

Commit 14e8f84

Browse files
cvinayaknashif
authored andcommitted
Bluetooth: controller: Fix start encryption in progress check
Fix check in start encryption to disallow new encryption setup while there is one already in progress. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent cec657b commit 14e8f84

File tree

1 file changed

+5
-3
lines changed
  • subsys/bluetooth/controller/ll_sw

1 file changed

+5
-3
lines changed

subsys/bluetooth/controller/ll_sw/ctrl.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12116,7 +12116,9 @@ u8_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, u8_t *ltk)
1211612116
return BT_HCI_ERR_UNKNOWN_CONN_ID;
1211712117
}
1211812118

12119-
if (conn->llcp_enc.req != conn->llcp_enc.ack) {
12119+
if ((conn->llcp_enc.req != conn->llcp_enc.ack) ||
12120+
((conn->llcp_req != conn->llcp_ack) &&
12121+
(conn->llcp_type == LLCP_ENCRYPTION))) {
1212012122
return BT_HCI_ERR_CMD_DISALLOWED;
1212112123
}
1212212124

@@ -12128,7 +12130,7 @@ u8_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, u8_t *ltk)
1212812130

1212912131
memcpy(&conn->llcp_enc.ltk[0], ltk, sizeof(conn->llcp_enc.ltk));
1213012132

12131-
if ((conn->enc_rx == 0) && (conn->enc_tx == 0)) {
12133+
if (!conn->enc_rx && !conn->enc_tx) {
1213212134
struct pdu_data_llctrl_enc_req *enc_req;
1213312135

1213412136
pdu_data_tx->ll_id = PDU_DATA_LLID_CTRL;
@@ -12144,7 +12146,7 @@ u8_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, u8_t *ltk)
1214412146
enc_req->ediv[1] = ediv[1];
1214512147
bt_rand(enc_req->skdm, sizeof(enc_req->skdm));
1214612148
bt_rand(enc_req->ivm, sizeof(enc_req->ivm));
12147-
} else if ((conn->enc_rx != 0) && (conn->enc_tx != 0)) {
12149+
} else if (conn->enc_rx && conn->enc_tx) {
1214812150
memcpy(&conn->llcp_enc.rand[0], rand,
1214912151
sizeof(conn->llcp_enc.rand));
1215012152

0 commit comments

Comments
 (0)