bluetoe icon indicating copy to clipboard operation
bluetoe copied to clipboard

MIC Error while receiving retransmitted PDU from Master

Open TorstenRobitzki opened this issue 4 years ago • 2 comments

If the connection is encrypted, currently, if a the CRC of a received PDU is correct, but the MIC is incorrect, the last PDU is resent.

This might happen, if the master did not received the acknowledgment for a PDU and thus resends a PDU. In this case, the receive packet counter would have been incremented and would result in a MIC error computed by the radios CCM hardware. This case could be detected by looking at the PDUs sequence number. If that indicates that the PDU was resend, the MIC error is ok. Otherwise, the connection should be closed (if CRC is correct).

This applies to the current nrf51 binding.

TorstenRobitzki avatar Feb 08 '22 14:02 TorstenRobitzki

Indeed: Bluetooth Core Spec v5.3 Vol 6 Part E Section 2.1 says that "The packetCounter shall not be incremented for retransmissions." Therefore, at reception of a data channel PDU, it makes sense to check if the packet is a retransmission or not (by checking the SN) prior to check the MIC (because the packetCounter value used to compute the expected MIC depends on whether the received packet was a retransmission or not).

XavierBoniface avatar Feb 08 '22 15:02 XavierBoniface

Commit https://github.com/TorstenRobitzki/bluetoe/commit/e1c2cd1f7572bc5be8508d89291ce20135c4eccf seems to have been a workarund for this case.

XavierBoniface avatar Feb 08 '22 15:02 XavierBoniface

Yes, that fixed the issue. But a very same issue #102 was introduced with the new nrf52 driver.

TorstenRobitzki avatar Jan 27 '23 14:01 TorstenRobitzki