LoRaMAC  4.6.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 #define USE_LRWAN_1_1_X_CRYPTO 1
57 
61 #define USE_RANDOM_DEV_NONCE 0
62 
70 #define USE_10X_JOIN_NONCE_COUNTER_CHECK 0
71 
75 #define FCNT_DOWN_INITAL_VALUE 0xFFFFFFFF
76 
80 typedef enum eLoRaMacCryptoStatus
81 {
159 
166 typedef void ( *LoRaMacCryptoNvmEvent )( void );
167 
177 
188 
197 LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntDown( FCntIdentifier_t fCntID, uint32_t frameFcnt, uint32_t* currentDown );
198 
205 LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntUp( uint32_t* currentUp );
206 
216 
225 
234 
243 
252 
261 
272 
282 LoRaMacCryptoStatus_t LoRaMacCryptoSecureMessage( uint32_t fCntUp, uint8_t txDr, uint8_t txCh, LoRaMacMessageData_t* macMsg );
283 
294 LoRaMacCryptoStatus_t LoRaMacCryptoUnsecureMessage( AddressIdentifier_t addrID, uint32_t address, FCntIdentifier_t fCntID, uint32_t fCntDown, LoRaMacMessageData_t* macMsg );
295 
310 
320 
332 
335 #ifdef __cplusplus
336 }
337 #endif
338 
339 #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:85
LORAMAC_CRYPTO_FAIL_ADDRESS
Definition: LoRaMacCrypto.h:93
LORAMAC_CRYPTO_FAIL_MIC
Definition: LoRaMacCrypto.h:89
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:951
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:109
LoRaMacCryptoGetFCntUp
LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntUp(uint32_t *currentUp)
LoRaMacMessageTypes.h
LoRa MAC layer message type definitions.
LORAMAC_CRYPTO_FAIL_RJCOUNT0_OVERFLOW
Definition: LoRaMacCrypto.h:101
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:97
LORAMAC_CRYPTO_ERROR_RJCOUNT1_OVERFLOW
Definition: LoRaMacCrypto.h:153
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)
LoRaMacCryptoNvmData_t
Definition: LoRaMacCryptoNvm.h:84
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:113
FCntIdentifier_t
FCntIdentifier_t
Definition: LoRaMacTypes.h:630
KeyIdentifier_t
KeyIdentifier_t
Definition: LoRaMacTypes.h:680
LORAMAC_CRYPTO_FAIL_FCNT_ID
Definition: LoRaMacCrypto.h:105
LoRaMacCryptoDeriveMcKEKey
LoRaMacCryptoStatus_t LoRaMacCryptoDeriveMcKEKey(KeyIdentifier_t keyID)
LoRaMacCryptoStatus_t
LoRaMacCryptoStatus_t
Definition: LoRaMacCrypto.h:80
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: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