Skip to content

Commit 46e164b

Browse files
dhineshkumarmcciterrillmoore
authored andcommitted
removed usage of LMIC.artKey and LMIC.nwkKey to store session keys from secure element layer
1 parent 95bc031 commit 46e164b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/lmic/lmic.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,6 @@ static bit_t processJoinAccept (void) {
15501550
}
15511551

15521552
LMIC_SecureElement_Error_t seErr;
1553-
LMIC_SecureElement_Aes128Key_t AppSKey, NwkSKey;
15541553

15551554
seErr = LMIC_SecureElement_Default_decodeJoinAccept(
15561555
LMIC.frame, dlen,
@@ -1560,12 +1559,6 @@ static bit_t processJoinAccept (void) {
15601559

15611560
if (seErr != LMIC_SecureElement_Error_OK)
15621561
return processJoinAccept_badframe();
1563-
1564-
LMIC_SecureElement_getAppSKey(&AppSKey, LMIC_SecureElement_KeySelector_Unicast);
1565-
LMIC_SecureElement_getNwkSKey(&NwkSKey, LMIC_SecureElement_KeySelector_Unicast);
1566-
1567-
memcpy(LMIC.artKey, AppSKey.bytes, sizeof(LMIC.artKey));
1568-
memcpy(LMIC.nwkKey, NwkSKey.bytes, sizeof(LMIC.nwkKey));
15691562

15701563
u4_t addr = os_rlsbf4(LMIC.frame+OFF_JA_DEVADDR);
15711564
LMIC.devaddr = addr;
@@ -3010,10 +3003,14 @@ u4_t LMIC_setSeqnoUp(u4_t seq_no) {
30103003

30113004
// \brief return the current session keys returned from join.
30123005
void LMIC_getSessionKeys (u4_t *netid, devaddr_t *devaddr, xref2u1_t nwkKey, xref2u1_t artKey) {
3006+
LMIC_SecureElement_Aes128Key_t AppSKey, NwkSKey;
30133007
*netid = LMIC.netid;
30143008
*devaddr = LMIC.devaddr;
3015-
memcpy(artKey, LMIC.artKey, sizeof(LMIC.artKey));
3016-
memcpy(nwkKey, LMIC.nwkKey, sizeof(LMIC.nwkKey));
3009+
3010+
LMIC_SecureElement_getAppSKey(&AppSKey, LMIC_SecureElement_KeySelector_Unicast);
3011+
LMIC_SecureElement_getNwkSKey(&NwkSKey, LMIC_SecureElement_KeySelector_Unicast);
3012+
memcpy(artKey, AppSKey.bytes, sizeof(AppSKey.bytes));
3013+
memcpy(nwkKey, NwkSKey.bytes, sizeof(NwkSKey.bytes));
30173014
}
30183015

30193016
// \brief post an asynchronous request for the network time.

0 commit comments

Comments
 (0)