nimble/phy/nrf: Wait for CCM to finish decryption

In extremely rare cases seems like ENDCRYPT flag is not set before we
check for MISTATUS, so just spin a bit in that case and wait for CCM to
finish.
This commit is contained in:
Andrzej Kaczmarek
2022-08-05 10:33:10 +02:00
parent 65716bde50
commit 3bb185daad
2 changed files with 8 additions and 20 deletions
+4 -10
View File
@@ -1100,6 +1100,10 @@ ble_phy_rx_end_isr(void)
ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_CRC_OK;
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
if (g_ble_phy_data.phy_encrypted) {
while (NRF_CCM->EVENTS_ENDCRYPT == 0) {
/* Make sure CCM finished */
};
/* Only set MIC failure flag if frame is not zero length */
if ((dptr[1] != 0) && (NRF_CCM->MICSTATUS == 0)) {
ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_MIC_FAILURE;
@@ -1115,16 +1119,6 @@ ble_phy_rx_end_isr(void)
STATS_INC(ble_phy_stats, rx_hw_err);
ble_hdr->rxinfo.flags &= ~BLE_MBUF_HDR_F_CRC_OK;
}
/*
* XXX: This is a total hack work-around for now but I dont
* know what else to do. If ENDCRYPT is not set and we are
* encrypted we need to not trust this frame and drop it.
*/
if (NRF_CCM->EVENTS_ENDCRYPT == 0) {
STATS_INC(ble_phy_stats, rx_hw_err);
ble_hdr->rxinfo.flags &= ~BLE_MBUF_HDR_F_CRC_OK;
}
}
#endif
}
+4 -10
View File
@@ -958,6 +958,10 @@ ble_phy_rx_end_isr(void)
ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_CRC_OK;
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
if (g_ble_phy_data.phy_encrypted) {
while (NRF_CCM_NS->EVENTS_ENDCRYPT == 0) {
/* Make sure CCM finished */
};
/* Only set MIC failure flag if frame is not zero length */
if ((dptr[1] != 0) && (NRF_CCM_NS->MICSTATUS == 0)) {
ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_MIC_FAILURE;
@@ -973,16 +977,6 @@ ble_phy_rx_end_isr(void)
STATS_INC(ble_phy_stats, rx_hw_err);
ble_hdr->rxinfo.flags &= ~BLE_MBUF_HDR_F_CRC_OK;
}
/*
* XXX: This is a total hack work-around for now but I dont
* know what else to do. If ENDCRYPT is not set and we are
* encrypted we need to not trust this frame and drop it.
*/
if (NRF_CCM_NS->EVENTS_ENDCRYPT == 0) {
STATS_INC(ble_phy_stats, rx_hw_err);
ble_hdr->rxinfo.flags &= ~BLE_MBUF_HDR_F_CRC_OK;
}
}
#endif
}