LoRaMAC  4.4.7
Documentation of the API
LoRaMacCrypto.h
Go to the documentation of this file.
1 
37 #ifndef __LORAMAC_CRYPTO_H__
38 #define __LORAMAC_CRYPTO_H__
39 
40 #ifdef __cplusplus
41 extern "C"
42 {
43 #endif
44 
45 #include <stdlib.h>
46 #include <stdint.h>
47 #include <stdbool.h>
48 #include "utilities.h"
49 #include "LoRaMacTypes.h"
50 #include "LoRaMacMessageTypes.h"
51 #include "LoRaMacCryptoNvm.h"
52 
56 #define USE_LRWAN_1_1_X_CRYPTO 0
57 
61 #define USE_RANDOM_DEV_NONCE 1
62 
66 #define USE_JOIN_NONCE_COUNTER_CHECK 0
67 
71 #define FCNT_DOWN_INITAL_VALUE 0xFFFFFFFF
72 
76 typedef enum eLoRaMacCryptoStatus
77 {
159 
166 typedef void ( *LoRaMacCryptoNvmEvent )( void );
167 
177 
188 
198 LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntDown( FCntIdentifier_t fCntID, uint16_t maxFCntGap, uint32_t frameFcnt, uint32_t* currentDown );
199 
206 LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntUp( uint32_t* currentUp );
207 
216 
225 
234 
243 
252 
263 
273 LoRaMacCryptoStatus_t LoRaMacCryptoSecureMessage( uint32_t fCntUp, uint8_t txDr, uint8_t txCh, LoRaMacMessageData_t* macMsg );
274 
285 LoRaMacCryptoStatus_t LoRaMacCryptoUnsecureMessage( AddressIdentifier_t addrID, uint32_t address, FCntIdentifier_t fCntID, uint32_t fCntDown, LoRaMacMessageData_t* macMsg );
286 
301 
311 
323 
326 #ifdef __cplusplus
327 }
328 #endif
329 
330 #endif // __LORAMAC_CRYPTO_H__
LORAMAC_CRYPTO_ERROR_SERIALIZER
Definition: LoRaMacCrypto.h:149
LoRaMacMessageReJoinType0or2_t
Definition: LoRaMacMessageTypes.h:125
LORAMAC_CRYPTO_ERROR_NPE
Definition: LoRaMacCrypto.h:121
LORAMAC_CRYPTO_ERROR_INVALID_ADDR_ID
Definition: LoRaMacCrypto.h:129
LoRaMacCryptoSetKey
LoRaMacCryptoStatus_t LoRaMacCryptoSetKey(KeyIdentifier_t keyID, uint8_t *key)
LORAMAC_CRYPTO_SUCCESS
Definition: LoRaMacCrypto.h:81
LORAMAC_CRYPTO_FAIL_MAX_GAP_FCNT
Definition: LoRaMacCrypto.h:113
LORAMAC_CRYPTO_FAIL_ADDRESS
Definition: LoRaMacCrypto.h:89
LORAMAC_CRYPTO_FAIL_MIC
Definition: LoRaMacCrypto.h:85
LORAMAC_CRYPTO_ERROR_BUF_SIZE
Definition: LoRaMacCrypto.h:137
LoRaMacTypes.h
LoRa MAC layer internal types definition. Please do not include in application sources.
LORAMAC_CRYPTO_FAIL_PARAM
Definition: LoRaMacCrypto.h:117
JoinReqIdentifier_t
JoinReqIdentifier_t
Definition: LoRaMacTypes.h:936
LoRaMacCryptoNvmEvent
void(* LoRaMacCryptoNvmEvent)(void)
Definition: LoRaMacCrypto.h:166
LoRaMacCryptoSetMulticastReference
LoRaMacCryptoStatus_t LoRaMacCryptoSetMulticastReference(MulticastCtx_t *multicastList)
LORAMAC_CRYPTO_ERROR
Definition: LoRaMacCrypto.h:157
LORAMAC_CRYPTO_FAIL_FCNT_SMALLER
Definition: LoRaMacCrypto.h:105
LoRaMacCryptoGetFCntUp
LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntUp(uint32_t *currentUp)
LoRaMacMessageTypes.h
LoRa MAC layer message type definitions.
LORAMAC_CRYPTO_FAIL_RJCOUNT0_OVERFLOW
Definition: LoRaMacCrypto.h:97
LoRaMacCryptoNvm.h
LoRa MAC layer cryptographic NVM data.
LORAMAC_CRYPTO_ERROR_PARSER
Definition: LoRaMacCrypto.h:145
LORAMAC_CRYPTO_ERROR_INVALID_VERSION
Definition: LoRaMacCrypto.h:133
LORAMAC_CRYPTO_ERROR_INVALID_KEY_ID
Definition: LoRaMacCrypto.h:125
LORAMAC_CRYPTO_FAIL_JOIN_NONCE
Definition: LoRaMacCrypto.h:93
LORAMAC_CRYPTO_ERROR_RJCOUNT1_OVERFLOW
Definition: LoRaMacCrypto.h:153
MulticastCtx_t
Definition: LoRaMacTypes.h:901
LoRaMacMessageReJoinType1_t
Definition: LoRaMacMessageTypes.h:86
LoRaMacCryptoSecureMessage
LoRaMacCryptoStatus_t LoRaMacCryptoSecureMessage(uint32_t fCntUp, uint8_t txDr, uint8_t txCh, LoRaMacMessageData_t *macMsg)
LoRaMacCryptoPrepareJoinRequest
LoRaMacCryptoStatus_t LoRaMacCryptoPrepareJoinRequest(LoRaMacMessageJoinRequest_t *macMsg)
LoRaMacCryptoDeriveMcRootKey
LoRaMacCryptoStatus_t LoRaMacCryptoDeriveMcRootKey(uint8_t versionMinor, KeyIdentifier_t keyID)
LoRaMacCryptoNvmData_t
Definition: LoRaMacCryptoNvm.h:85
LoRaMacCryptoDeriveMcSessionKeyPair
LoRaMacCryptoStatus_t LoRaMacCryptoDeriveMcSessionKeyPair(AddressIdentifier_t addrID, uint32_t mcAddr)
LoRaMacCryptoHandleJoinAccept
LoRaMacCryptoStatus_t LoRaMacCryptoHandleJoinAccept(JoinReqIdentifier_t joinReqType, uint8_t *joinEUI, LoRaMacMessageJoinAccept_t *macMsg)
AddressIdentifier_t
AddressIdentifier_t
Definition: LoRaMacTypes.h:775
LoRaMacMessageJoinRequest_t
Definition: LoRaMacMessageTypes.h:51
LoRaMacMessageData_t
Definition: LoRaMacMessageTypes.h:213
LORAMAC_CRYPTO_FAIL_FCNT_DUPLICATED
Definition: LoRaMacCrypto.h:109
FCntIdentifier_t
FCntIdentifier_t
Definition: LoRaMacTypes.h:630
KeyIdentifier_t
KeyIdentifier_t
Definition: LoRaMacTypes.h:672
LoRaMacCryptoGetFCntDown
LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntDown(FCntIdentifier_t fCntID, uint16_t maxFCntGap, uint32_t frameFcnt, uint32_t *currentDown)
LORAMAC_CRYPTO_FAIL_FCNT_ID
Definition: LoRaMacCrypto.h:101
LoRaMacCryptoDeriveMcKEKey
LoRaMacCryptoStatus_t LoRaMacCryptoDeriveMcKEKey(KeyIdentifier_t keyID)
LoRaMacCryptoStatus_t
LoRaMacCryptoStatus_t
Definition: LoRaMacCrypto.h:76
LoRaMacCryptoPrepareReJoinType1
LoRaMacCryptoStatus_t LoRaMacCryptoPrepareReJoinType1(LoRaMacMessageReJoinType1_t *macMsg)
LoRaMacCryptoSetLrWanVersion
LoRaMacCryptoStatus_t LoRaMacCryptoSetLrWanVersion(Version_t version)
LoRaMacCryptoPrepareReJoinType0or2
LoRaMacCryptoStatus_t LoRaMacCryptoPrepareReJoinType0or2(LoRaMacMessageReJoinType0or2_t *macMsg)
LoRaMacCryptoInit
LoRaMacCryptoStatus_t LoRaMacCryptoInit(LoRaMacCryptoNvmData_t *nvm)
LORAMAC_CRYPTO_ERROR_SECURE_ELEMENT_FUNC
Definition: LoRaMacCrypto.h:141
LoRaMacCryptoUnsecureMessage
LoRaMacCryptoStatus_t LoRaMacCryptoUnsecureMessage(AddressIdentifier_t addrID, uint32_t address, FCntIdentifier_t fCntID, uint32_t fCntDown, LoRaMacMessageData_t *macMsg)
LoRaMacMessageJoinAccept_t
Definition: LoRaMacMessageTypes.h:164