From 44569e1c72951a014a07ec7c088e85a8596e52f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Rymanowski?= Date: Thu, 7 Feb 2019 00:55:48 +0100 Subject: [PATCH] nimble/ll: Fix handling RX data while encryption as a Slave Set enc_stat in the LL_ENC_REQ handler and not when sending LL_ENC_RSP. This is in order to make sure that next incoming PDU will be alread verified This fix small rate of failures of LL/SEC/SLA/BI-05 --- nimble/controller/src/ble_ll_ctrl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nimble/controller/src/ble_ll_ctrl.c b/nimble/controller/src/ble_ll_ctrl.c index 709209c29..06b76c4e7 100644 --- a/nimble/controller/src/ble_ll_ctrl.c +++ b/nimble/controller/src/ble_ll_ctrl.c @@ -1295,6 +1295,8 @@ ble_ll_ctrl_rx_enc_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr, return BLE_LL_CTRL_UNKNOWN_RSP; } + connsm->enc_data.enc_state = CONN_ENC_S_LTK_REQ_WAIT; + /* In case we were already encrypted we need to reset packet counters */ connsm->enc_data.rx_pkt_cntr = 0; connsm->enc_data.tx_pkt_cntr = 0; @@ -2621,7 +2623,6 @@ ble_ll_ctrl_tx_done(struct os_mbuf *txpdu, struct ble_ll_conn_sm *connsm) connsm->enc_data.enc_state = CONN_ENC_S_ENC_RSP_WAIT; break; case BLE_LL_CTRL_ENC_RSP: - connsm->enc_data.enc_state = CONN_ENC_S_LTK_REQ_WAIT; connsm->csmflags.cfbit.send_ltk_req = 1; break; case BLE_LL_CTRL_START_ENC_RSP: