Skip to content

Commit

Permalink
Changed improved the way USE_LRWAN_1_1_X_CRYPTO pre-processing direct…
Browse files Browse the repository at this point in the history
…ive is used
  • Loading branch information
mluis1 committed Jul 1, 2021
1 parent 62b0864 commit ceb9844
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/mac/LoRaMacCrypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static LoRaMacCryptoStatus_t PrepareB0( uint16_t msgLen, KeyIdentifier_t keyID,

b0[0] = 0x49;

#if( USE_LRWAN_1_1_X_CRYPTO == 1 )
if( ( isAck == true ) && ( dir == DOWNLINK ) )
{
// confFCnt contains the frame counter value modulo 2^16 of the "confirmed" uplink or downlink frame that is being acknowledged
Expand All @@ -291,6 +292,7 @@ static LoRaMacCryptoStatus_t PrepareB0( uint16_t msgLen, KeyIdentifier_t keyID,
b0[2] = ( confFCnt >> 8 ) & 0xFF;
}
else
#endif
{
b0[1] = 0x00;
b0[2] = 0x00;
Expand Down Expand Up @@ -915,9 +917,9 @@ LoRaMacCryptoStatus_t LoRaMacCryptoGetFCntDown( FCntIdentifier_t fCntID, uint32_
return LORAMAC_CRYPTO_SUCCESS;
}

#if( USE_LRWAN_1_1_X_CRYPTO == 1 )
LoRaMacCryptoStatus_t LoRaMacCryptoGetRJcount( FCntIdentifier_t fCntID, uint16_t* rJcount )
{
#if( USE_LRWAN_1_1_X_CRYPTO == 1 )
if( rJcount == 0 )
{
return LORAMAC_CRYPTO_ERROR_NPE;
Expand All @@ -934,8 +936,10 @@ LoRaMacCryptoStatus_t LoRaMacCryptoGetRJcount( FCntIdentifier_t fCntID, uint16_t
return LORAMAC_CRYPTO_FAIL_FCNT_ID;
}
return LORAMAC_CRYPTO_SUCCESS;
}
#else
return LORAMAC_CRYPTO_ERROR;
#endif
}

LoRaMacCryptoStatus_t LoRaMacCryptoSetMulticastReference( MulticastCtx_t* multicastList )
{
Expand Down Expand Up @@ -1024,9 +1028,9 @@ LoRaMacCryptoStatus_t LoRaMacCryptoPrepareJoinRequest( LoRaMacMessageJoinRequest
return LORAMAC_CRYPTO_SUCCESS;
}

#if( USE_LRWAN_1_1_X_CRYPTO == 1 )
LoRaMacCryptoStatus_t LoRaMacCryptoPrepareReJoinType1( LoRaMacMessageReJoinType1_t* macMsg )
{
#if( USE_LRWAN_1_1_X_CRYPTO == 1 )
if( macMsg == 0 )
{
return LORAMAC_CRYPTO_ERROR_NPE;
Expand Down Expand Up @@ -1061,10 +1065,14 @@ LoRaMacCryptoStatus_t LoRaMacCryptoPrepareReJoinType1( LoRaMacMessageReJoinType1
CryptoNvm->FCntList.RJcount1++;

return LORAMAC_CRYPTO_SUCCESS;
#else
return LORAMAC_CRYPTO_ERROR;
#endif
}

LoRaMacCryptoStatus_t LoRaMacCryptoPrepareReJoinType0or2( LoRaMacMessageReJoinType0or2_t* macMsg )
{
#if( USE_LRWAN_1_1_X_CRYPTO == 1 )
if( macMsg == 0 )
{
return LORAMAC_CRYPTO_ERROR_NPE;
Expand Down Expand Up @@ -1099,8 +1107,10 @@ LoRaMacCryptoStatus_t LoRaMacCryptoPrepareReJoinType0or2( LoRaMacMessageReJoinTy
RJcount0++;

return LORAMAC_CRYPTO_SUCCESS;
}
#else
return LORAMAC_CRYPTO_ERROR;
#endif
}

LoRaMacCryptoStatus_t LoRaMacCryptoHandleJoinAccept( JoinReqIdentifier_t joinReqType, uint8_t* joinEUI, LoRaMacMessageJoinAccept_t* macMsg )
{
Expand Down

0 comments on commit ceb9844

Please sign in to comment.