lorabasics / basicmac

LoRa Basics™ MAC
Other
79 stars 42 forks source link

NwkKey used to Join Regardless of CFG_lorawan11 #19

Closed lthiery closed 4 years ago

lthiery commented 4 years ago

https://github.com/lorabasics/basicmac/blob/master/lmic/lce.c#L73

Does LoRaWAN pre-1.1 have a notion of NwkKey? Perhaps that code should be:


void lce_addMicJoinReq (u1_t* pdu, int len) {
#if defined(CFG_lorawan11)
    os_getNwkKey(AESkey);
#else
    os_getAppKey(AESkey);
#endif    
    os_wmsbf4(pdu+len, os_aes(AES_MIC|AES_MICNOAUX, pdu, len));  // MSB because of internal structure of AES
}
mkuyper commented 4 years ago

Unfortunately, the introduction of the NwkKey in LW1.1 created some naming confusion. The NwkKey is actually what was used to be the AppKey in LW1.0.x and the newly introducted key that is only used for encryption of non-port-0 payloads is now called AppKey in LW1.1. Yeah I know.

In BasicMAC, we use the newer terminology, hence the 1.0 AppKey is already called NwkKey.

lthiery commented 4 years ago

Ah got it. Thanks for the explanation!