mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 07:37:46 +00:00
[radio] fix ACK frame counter with previous key (#10816)
This commit tracks the frame counter used for the previous key index and use it for the ACK frame to a frame still using previous key index.
This commit is contained in:
@@ -294,6 +294,7 @@ otError otMacFrameProcessTransmitSecurity(otRadioFrame *aFrame, otRadioContext *
|
||||
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
|
||||
otMacKeyMaterial *key = nullptr;
|
||||
uint8_t keyId;
|
||||
uint32_t frameCounter;
|
||||
|
||||
VerifyOrExit(otMacFrameIsSecurityEnabled(aFrame) && otMacFrameIsKeyIdMode1(aFrame) &&
|
||||
!aFrame->mInfo.mTxInfo.mIsSecurityProcessed);
|
||||
@@ -306,15 +307,18 @@ otError otMacFrameProcessTransmitSecurity(otRadioFrame *aFrame, otRadioContext *
|
||||
|
||||
if (keyId == aRadioContext->mKeyId)
|
||||
{
|
||||
key = &aRadioContext->mCurrKey;
|
||||
key = &aRadioContext->mCurrKey;
|
||||
frameCounter = aRadioContext->mMacFrameCounter++;
|
||||
}
|
||||
else if (keyId == aRadioContext->mKeyId - 1)
|
||||
{
|
||||
key = &aRadioContext->mPrevKey;
|
||||
key = &aRadioContext->mPrevKey;
|
||||
frameCounter = aRadioContext->mPrevMacFrameCounter++;
|
||||
}
|
||||
else if (keyId == aRadioContext->mKeyId + 1)
|
||||
{
|
||||
key = &aRadioContext->mNextKey;
|
||||
key = &aRadioContext->mNextKey;
|
||||
frameCounter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -323,8 +327,9 @@ otError otMacFrameProcessTransmitSecurity(otRadioFrame *aFrame, otRadioContext *
|
||||
}
|
||||
else if (!aFrame->mInfo.mTxInfo.mIsHeaderUpdated)
|
||||
{
|
||||
key = &aRadioContext->mCurrKey;
|
||||
keyId = aRadioContext->mKeyId;
|
||||
key = &aRadioContext->mCurrKey;
|
||||
keyId = aRadioContext->mKeyId;
|
||||
frameCounter = aRadioContext->mMacFrameCounter++;
|
||||
}
|
||||
|
||||
if (key != nullptr)
|
||||
@@ -332,7 +337,7 @@ otError otMacFrameProcessTransmitSecurity(otRadioFrame *aFrame, otRadioContext *
|
||||
aFrame->mInfo.mTxInfo.mAesKey = key;
|
||||
|
||||
otMacFrameSetKeyId(aFrame, keyId);
|
||||
otMacFrameSetFrameCounter(aFrame, aRadioContext->mMacFrameCounter++);
|
||||
otMacFrameSetFrameCounter(aFrame, frameCounter);
|
||||
aFrame->mInfo.mTxInfo.mIsHeaderUpdated = true;
|
||||
}
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user