mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-17 15:30:11 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user