LoRaMAC  4.4.5
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 
55 #define USE_LRWAN_1_1_X_CRYPTO 0
56 
60 #define USE_RANDOM_DEV_NONCE 1
61 
65 #define USE_JOIN_NONCE_COUNTER_CHECK 0
66 
70 #define FCNT_DOWN_INITAL_VALUE 0xFFFFFFFF
71 
75 typedef enum eLoRaMacCryptoStatus
76 {
158 
165 typedef void ( *LoRaMacCryptoNvmEvent )( void );
166 
176 
187 
195 
202 void* LoRaMacCryptoGetNvmCtx( size_t* cryptoNvmCtxSize );
203 
213 LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntDown( FCntIdentifier_t fCntID, uint16_t maxFCntGap, uint32_t frameFcnt, uint32_t* currentDown );
214 
221 LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntUp( uint32_t* currentUp );
222 
231 
240 
249 
258 
267 
278 
288 LoRaMacCryptoStatus_t LoRaMacCryptoSecureMessage( uint32_t fCntUp, uint8_t txDr, uint8_t txCh, LoRaMacMessageData_t* macMsg );
289 
300 LoRaMacCryptoStatus_t LoRaMacCryptoUnsecureMessage( AddressIdentifier_t addrID, uint32_t address, FCntIdentifier_t fCntID, uint32_t fCntDown, LoRaMacMessageData_t* macMsg );
301 
316 
326 
338 
341 #ifdef __cplusplus
342 }
343 #endif
344 
345 #endif // __LORAMAC_CRYPTO_H__
LORAMAC_CRYPTO_ERROR_SERIALIZER
Definition: LoRaMacCrypto.h:148
LoRaMacMessageReJoinType0or2_t
Definition: LoRaMacMessageTypes.h:125
LORAMAC_CRYPTO_ERROR_NPE
Definition: LoRaMacCrypto.h:120
LORAMAC_CRYPTO_ERROR_INVALID_ADDR_ID
Definition: LoRaMacCrypto.h:128
LoRaMacCryptoSetKey
LoRaMacCryptoStatus_t LoRaMacCryptoSetKey(KeyIdentifier_t keyID, uint8_t *key)
LORAMAC_CRYPTO_SUCCESS
Definition: LoRaMacCrypto.h:80
LORAMAC_CRYPTO_FAIL_MAX_GAP_FCNT
Definition: LoRaMacCrypto.h:112
LORAMAC_CRYPTO_FAIL_ADDRESS
Definition: LoRaMacCrypto.h:88
LORAMAC_CRYPTO_FAIL_MIC
Definition: LoRaMacCrypto.h:84
LORAMAC_CRYPTO_ERROR_BUF_SIZE
Definition: LoRaMacCrypto.h:136
LoRaMacTypes.h
LoRa MAC layer internal types definition. Please do not include in application sources.
LORAMAC_CRYPTO_FAIL_PARAM
Definition: LoRaMacCrypto.h:116
JoinReqIdentifier_t
JoinReqIdentifier_t
Definition: LoRaMacTypes.h:433
LoRaMacCryptoNvmEvent
void(* LoRaMacCryptoNvmEvent)(void)
Definition: LoRaMacCrypto.h:165
LoRaMacCryptoSetMulticastReference
LoRaMacCryptoStatus_t LoRaMacCryptoSetMulticastReference(MulticastCtx_t *multicastList)
LORAMAC_CRYPTO_ERROR
Definition: LoRaMacCrypto.h:156
LORAMAC_CRYPTO_FAIL_FCNT_SMALLER
Definition: LoRaMacCrypto.h:104
LoRaMacCryptoGetFCntUp
LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntUp(uint32_t *currentUp)
LoRaMacMessageTypes.h
LoRa MAC layer message type definitions.
LORAMAC_CRYPTO_FAIL_RJCOUNT0_OVERFLOW
Definition: LoRaMacCrypto.h:96
LORAMAC_CRYPTO_ERROR_PARSER
Definition: LoRaMacCrypto.h:144
LORAMAC_CRYPTO_ERROR_INVALID_VERSION
Definition: LoRaMacCrypto.h:132
LORAMAC_CRYPTO_ERROR_INVALID_KEY_ID
Definition: LoRaMacCrypto.h:124
LORAMAC_CRYPTO_FAIL_JOIN_NONCE
Definition: LoRaMacCrypto.h:92
LoRaMacCryptoGetNvmCtx
void * LoRaMacCryptoGetNvmCtx(size_t *cryptoNvmCtxSize)
LORAMAC_CRYPTO_ERROR_RJCOUNT1_OVERFLOW
Definition: LoRaMacCrypto.h:152
MulticastCtx_t
Definition: LoRaMacTypes.h:398
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)
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:272
LoRaMacMessageJoinRequest_t
Definition: LoRaMacMessageTypes.h:51
LoRaMacCryptoInit
LoRaMacCryptoStatus_t LoRaMacCryptoInit(LoRaMacCryptoNvmEvent cryptoNvmCtxChanged)
LoRaMacMessageData_t
Definition: LoRaMacMessageTypes.h:213
LORAMAC_CRYPTO_FAIL_FCNT_DUPLICATED
Definition: LoRaMacCrypto.h:108
FCntIdentifier_t
FCntIdentifier_t
Definition: LoRaMacTypes.h:127
KeyIdentifier_t
KeyIdentifier_t
Definition: LoRaMacTypes.h:169
LoRaMacCryptoGetFCntDown
LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntDown(FCntIdentifier_t fCntID, uint16_t maxFCntGap, uint32_t frameFcnt, uint32_t *currentDown)
LORAMAC_CRYPTO_FAIL_FCNT_ID
Definition: LoRaMacCrypto.h:100
LoRaMacCryptoDeriveMcKEKey
LoRaMacCryptoStatus_t LoRaMacCryptoDeriveMcKEKey(KeyIdentifier_t keyID)
LoRaMacCryptoStatus_t
LoRaMacCryptoStatus_t
Definition: LoRaMacCrypto.h:75
LoRaMacCryptoRestoreNvmCtx
LoRaMacCryptoStatus_t LoRaMacCryptoRestoreNvmCtx(void *cryptoNvmCtx)
LoRaMacCryptoPrepareReJoinType1
LoRaMacCryptoStatus_t LoRaMacCryptoPrepareReJoinType1(LoRaMacMessageReJoinType1_t *macMsg)
LoRaMacCryptoSetLrWanVersion
LoRaMacCryptoStatus_t LoRaMacCryptoSetLrWanVersion(Version_t version)
LoRaMacCryptoPrepareReJoinType0or2
LoRaMacCryptoStatus_t LoRaMacCryptoPrepareReJoinType0or2(LoRaMacMessageReJoinType0or2_t *macMsg)
LORAMAC_CRYPTO_ERROR_SECURE_ELEMENT_FUNC
Definition: LoRaMacCrypto.h:140
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