LoRaMAC  4.7.0
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 #ifndef USE_LRWAN_1_1_X_CRYPTO
57 #define USE_LRWAN_1_1_X_CRYPTO 1
58 #endif
59 
63 #define USE_RANDOM_DEV_NONCE 0
64 
72 #define USE_10X_JOIN_NONCE_COUNTER_CHECK 0
73 
77 #define FCNT_DOWN_INITIAL_VALUE 0xFFFFFFFF
78 
82 typedef enum eLoRaMacCryptoStatus
83 {
161 
168 typedef void ( *LoRaMacCryptoNvmEvent )( void );
169 
178 LoRaMacCryptoStatus_t LoRaMacCryptoInit( LoRaMacCryptoNvmData_t* nvm );
179 
190 
199 LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntDown( FCntIdentifier_t fCntID, uint32_t frameFcnt, uint32_t* currentDown );
200 
207 LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntUp( uint32_t* currentUp );
208 
218 
227 
236 
245 
254 
263 
274 
284 LoRaMacCryptoStatus_t LoRaMacCryptoSecureMessage( uint32_t fCntUp, uint8_t txDr, uint8_t txCh, LoRaMacMessageData_t* macMsg );
285 
296 LoRaMacCryptoStatus_t LoRaMacCryptoUnsecureMessage( AddressIdentifier_t addrID, uint32_t address, FCntIdentifier_t fCntID, uint32_t fCntDown, LoRaMacMessageData_t* macMsg );
297 
312 
322 
334 
337 #ifdef __cplusplus
338 }
339 #endif
340 
341 #endif // __LORAMAC_CRYPTO_H__
LORAMAC_CRYPTO_ERROR_SERIALIZER
Definition: LoRaMacCrypto.h:151
LoRaMacMessageReJoinType0or2_t
Definition: LoRaMacMessageTypes.h:125
LORAMAC_CRYPTO_ERROR_NPE
Definition: LoRaMacCrypto.h:123
LORAMAC_CRYPTO_ERROR_INVALID_ADDR_ID
Definition: LoRaMacCrypto.h:131
LoRaMacCryptoSetKey
LoRaMacCryptoStatus_t LoRaMacCryptoSetKey(KeyIdentifier_t keyID, uint8_t *key)
LORAMAC_CRYPTO_SUCCESS
Definition: LoRaMacCrypto.h:87
LORAMAC_CRYPTO_FAIL_ADDRESS
Definition: LoRaMacCrypto.h:95
LORAMAC_CRYPTO_FAIL_MIC
Definition: LoRaMacCrypto.h:91
LORAMAC_CRYPTO_ERROR_BUF_SIZE
Definition: LoRaMacCrypto.h:139
LoRaMacTypes.h
LoRa MAC layer internal types definition. Please do not include in application sources.
LORAMAC_CRYPTO_FAIL_PARAM
Definition: LoRaMacCrypto.h:119
JoinReqIdentifier_t
JoinReqIdentifier_t
Definition: LoRaMacTypes.h:951
LoRaMacCryptoNvmEvent
void(* LoRaMacCryptoNvmEvent)(void)
Definition: LoRaMacCrypto.h:168
LoRaMacCryptoSetMulticastReference
LoRaMacCryptoStatus_t LoRaMacCryptoSetMulticastReference(MulticastCtx_t *multicastList)
LORAMAC_CRYPTO_ERROR
Definition: LoRaMacCrypto.h:159
LORAMAC_CRYPTO_FAIL_FCNT_SMALLER
Definition: LoRaMacCrypto.h:111
LoRaMacCryptoGetFCntUp
LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntUp(uint32_t *currentUp)
LoRaMacMessageTypes.h
LoRa MAC layer message type definitions.
LORAMAC_CRYPTO_FAIL_RJCOUNT0_OVERFLOW
Definition: LoRaMacCrypto.h:103
LORAMAC_CRYPTO_ERROR_PARSER
Definition: LoRaMacCrypto.h:147
LORAMAC_CRYPTO_ERROR_INVALID_VERSION
Definition: LoRaMacCrypto.h:135
LORAMAC_CRYPTO_ERROR_INVALID_KEY_ID
Definition: LoRaMacCrypto.h:127
LORAMAC_CRYPTO_FAIL_JOIN_NONCE
Definition: LoRaMacCrypto.h:99
LORAMAC_CRYPTO_ERROR_RJCOUNT1_OVERFLOW
Definition: LoRaMacCrypto.h:155
MulticastCtx_t
Definition: LoRaMacTypes.h:912
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)
LoRaMacCryptoGetRJcount
LoRaMacCryptoStatus_t LoRaMacCryptoGetRJcount(FCntIdentifier_t fCntID, uint16_t *rJcount)
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:783
LoRaMacMessageJoinRequest_t
Definition: LoRaMacMessageTypes.h:51
LoRaMacMessageData_t
Definition: LoRaMacMessageTypes.h:213
LORAMAC_CRYPTO_FAIL_FCNT_DUPLICATED
Definition: LoRaMacCrypto.h:115
FCntIdentifier_t
FCntIdentifier_t
Definition: LoRaMacTypes.h:630
KeyIdentifier_t
KeyIdentifier_t
Definition: LoRaMacTypes.h:680
LORAMAC_CRYPTO_FAIL_FCNT_ID
Definition: LoRaMacCrypto.h:107
LoRaMacCryptoDeriveMcKEKey
LoRaMacCryptoStatus_t LoRaMacCryptoDeriveMcKEKey(KeyIdentifier_t keyID)
LoRaMacCryptoStatus_t
LoRaMacCryptoStatus_t
Definition: LoRaMacCrypto.h:82
LoRaMacCryptoPrepareReJoinType1
LoRaMacCryptoStatus_t LoRaMacCryptoPrepareReJoinType1(LoRaMacMessageReJoinType1_t *macMsg)
LoRaMacCryptoSetLrWanVersion
LoRaMacCryptoStatus_t LoRaMacCryptoSetLrWanVersion(Version_t version)
LoRaMacCryptoGetFCntDown
LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntDown(FCntIdentifier_t fCntID, uint32_t frameFcnt, uint32_t *currentDown)
LoRaMacCryptoPrepareReJoinType0or2
LoRaMacCryptoStatus_t LoRaMacCryptoPrepareReJoinType0or2(LoRaMacMessageReJoinType0or2_t *macMsg)
LoRaMacCryptoInit
LoRaMacCryptoStatus_t LoRaMacCryptoInit(LoRaMacCryptoNvmData_t *nvm)
LORAMAC_CRYPTO_ERROR_SECURE_ELEMENT_FUNC
Definition: LoRaMacCrypto.h:143
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