1 /*! 2 * \file LoRaMacCryptoNvm.h 3 * 4 * \brief LoRa MAC layer cryptographic NVM data. 5 * 6 * \copyright Revised BSD License, see section \ref LICENSE. 7 * 8 * \code 9 * ______ _ 10 * / _____) _ | | 11 * ( (____ _____ ____ _| |_ _____ ____| |__ 12 * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 * _____) ) ____| | | || |_| ____( (___| | | | 14 * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 * (C)2013-2017 Semtech 16 * 17 * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 * embedded.connectivity.solutions=============== 22 * 23 * \endcode 24 * 25 * \author Miguel Luis ( Semtech ) 26 * 27 * \author Daniel Jaeckle ( STACKFORCE ) 28 * 29 * addtogroup LORAMAC 30 * \{ 31 * 32 */ 33 #ifndef __LORAMAC_CRYPTO_NVM_H__ 34 #define __LORAMAC_CRYPTO_NVM_H__ 35 36 #ifdef __cplusplus 37 extern "C" 38 { 39 #endif 40 41 #include <stdint.h> 42 #include "utilities.h" 43 #include "LoRaMacTypes.h" 44 45 46 /*! 47 * LoRaWAN Frame counter list. 48 */ 49 typedef struct sFCntList 50 { 51 /*! 52 * Uplink frame counter which is incremented with each uplink. 53 */ 54 uint32_t FCntUp; 55 /*! 56 * Network downlink frame counter which is incremented with each downlink on FPort 0 57 * or when the FPort field is missing. 58 */ 59 uint32_t NFCntDown; 60 /*! 61 * Application downlink frame counter which is incremented with each downlink 62 * on a port different than 0. 63 */ 64 uint32_t AFCntDown; 65 /*! 66 * In case if the device is connected to a LoRaWAN 1.0 Server, 67 * this counter is used for every kind of downlink frame. 68 */ 69 uint32_t FCntDown; 70 /*! 71 * Multicast downlink counters 72 */ 73 uint32_t McFCntDown[LORAMAC_MAX_MC_CTX]; 74 /*! 75 * RJcount1 is a counter incremented with every Rejoin request Type 1 76 * frame transmitted. 77 */ 78 uint16_t RJcount1; 79 }FCntList_t; 80 81 /*! 82 * LoRaMac Crypto Non Volatile Context structure 83 */ 84 typedef struct sLoRaMacCryptoNvmData 85 { 86 /*! 87 * Stores the information if the device is connected to a LoRaWAN network 88 * server with prior to 1.1.0 implementation. 89 */ 90 Version_t LrWanVersion; 91 /*! 92 * Device nonce is a counter starting at 0 when the device is initially 93 * powered up and incremented with every JoinRequest. 94 */ 95 uint16_t DevNonce; 96 /*! 97 * JoinNonce is a device specific counter value (that never repeats itself) 98 * provided by the join server and incremented with every JoinAccept message. 99 */ 100 uint32_t JoinNonce; 101 /*! 102 * Frame counter list 103 */ 104 FCntList_t FCntList; 105 /*! 106 * LastDownFCnt stores the information which frame counter was used to 107 * decrypt the last frame. This information is needed to compute ConfFCnt in 108 * B1 block for the MIC. 109 */ 110 uint32_t LastDownFCnt; 111 /*! 112 * CRC32 value of the Crypto data structure. 113 */ 114 uint32_t Crc32; 115 }LoRaMacCryptoNvmData_t; 116 117 /*! \} addtogroup LORAMAC */ 118 119 #ifdef __cplusplus 120 } 121 #endif 122 123 #endif // __LORAMAC_CRYPTO_NVM_H__ 124