Lora-net / SWL2001

LoRa Basics Modem LoRaWAN stack
BSD 3-Clause Clear License
107 stars 61 forks source link

Relay ACK MIC incorrectly calculated #92

Closed StevenCellist closed 2 weeks ago

StevenCellist commented 2 weeks ago

Hi team,

In my opinion, the MIC of the ACK message is not correctly calculated. According to TS011-1.0.0 section 6.2, the CMAC is calculated over block B_0, AckUplinkEnc and WOR, where "WOR contains the data received in the WOR Relay Class A Uplink". I read this as follows: the Frequency and Datarate fields in the WOR block should be the Frequency and Datarate as received in the WOR frame. However, in LBM, the MIC is calculated using the Frequency and Datarate of the ACK message:

https://github.com/Lora-net/SWL2001/blob/0ad056afad1c2102b8bcd121e87cc060d46d98c0/lbm_lib/smtc_modem_core/lr1mac/src/relay/relay_tx/relay_tx.c#L596-L609

https://github.com/Lora-net/SWL2001/blob/0ad056afad1c2102b8bcd121e87cc060d46d98c0/lbm_lib/smtc_modem_core/lr1mac/src/relay/common/wake_on_radio.c#L284-L287

I think that these fields should refer to the WOR payload's Freq/Dr instead. Please let me know your thoughts!

mluis1 commented 2 weeks ago

Duplicate of #62

StevenCellist commented 2 weeks ago

Ah, sorry, the name of that issue somehow didn't strike my eye as being a duplicate. Thanks! I'll close this one.