From ce6733edc03bc38d4574a426a6795b648c6ea5cc Mon Sep 17 00:00:00 2001 From: Hasnain Virk Date: Thu, 18 Oct 2018 18:53:41 +0300 Subject: [PATCH] Removing incorrect context free After deriving JSEncKey we were wrongly clearing the AES context. We shouldn't clear the context until the function is done doing its job. That was why JSINtKey derivation was wrong which would result in MIC failures. --- features/lorawan/lorastack/mac/LoRaMacCrypto.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/features/lorawan/lorastack/mac/LoRaMacCrypto.cpp b/features/lorawan/lorastack/mac/LoRaMacCrypto.cpp index c7fa346364..b5cb99e63a 100644 --- a/features/lorawan/lorastack/mac/LoRaMacCrypto.cpp +++ b/features/lorawan/lorastack/mac/LoRaMacCrypto.cpp @@ -31,7 +31,6 @@ #include "system/lorawan_data_structures.h" #include "mbedtls/platform.h" - #if defined(MBEDTLS_CMAC_C) && defined(MBEDTLS_AES_C) && defined(MBEDTLS_CIPHER_C) LoRaMacCrypto::LoRaMacCrypto() @@ -360,7 +359,6 @@ int LoRaMacCrypto::compute_join_server_keys(const uint8_t *key, uint32_t key_len if (0 != ret) goto exit; - mbedtls_aes_free(&aes_ctx); memset(nonce, 0, sizeof(nonce)); nonce[0] = 0x06; memcpy(nonce + 1, eui, 8);