[mac-frame] process the security of the wakeup frame (#11003)

If the radio driver supports the `OT_RADIO_CAPS_TRANSMIT_SEC`, the
radio driver should process the security of the send frame. But the
current method `otMacFrameProcessTransmitSecurity()` doesn't process
the security of the wakeup frame. Which causes sent wakeup frame is not
encrypted.

This commit enables the method `otMacFrameProcessTransmitSecurity()`
to process the security of the wakeup frame.
This commit is contained in:
Zhanglong Xia
2024-12-12 15:32:41 -08:00
committed by GitHub
parent 871196689d
commit 9fefeedb0d
2 changed files with 28 additions and 2 deletions
+18 -2
View File
@@ -224,6 +224,16 @@ bool otMacFrameIsKeyIdMode1(otRadioFrame *aFrame)
return (error == OT_ERROR_NONE) ? (keyIdMode == Mac::Frame::kKeyIdMode1) : false;
}
bool otMacFrameIsKeyIdMode2(otRadioFrame *aFrame)
{
uint8_t keyIdMode;
otError error;
error = static_cast<const Mac::Frame *>(aFrame)->GetKeyIdMode(keyIdMode);
return (error == OT_ERROR_NONE) ? (keyIdMode == Mac::Frame::kKeyIdMode2) : false;
}
uint8_t otMacFrameGetKeyId(otRadioFrame *aFrame)
{
uint8_t keyId = 0;
@@ -306,9 +316,15 @@ otError otMacFrameProcessTransmitSecurity(otRadioFrame *aFrame, otRadioContext *
otMacKeyMaterial *key = nullptr;
uint8_t keyId;
uint32_t frameCounter;
bool processKeyId;
VerifyOrExit(otMacFrameIsSecurityEnabled(aFrame) && otMacFrameIsKeyIdMode1(aFrame) &&
!aFrame->mInfo.mTxInfo.mIsSecurityProcessed);
processKeyId =
#if OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE
otMacFrameIsKeyIdMode2(aFrame) ||
#endif
otMacFrameIsKeyIdMode1(aFrame);
VerifyOrExit(otMacFrameIsSecurityEnabled(aFrame) && processKeyId && !aFrame->mInfo.mTxInfo.mIsSecurityProcessed);
if (otMacFrameIsAck(aFrame))
{
+10
View File
@@ -259,6 +259,16 @@ bool otMacFrameIsSecurityEnabled(otRadioFrame *aFrame);
*/
bool otMacFrameIsKeyIdMode1(otRadioFrame *aFrame);
/**
* Tell if the key ID mode of @p aFrame is 2.
*
* @param[in] aFrame A pointer to the frame.
*
* @retval true The frame key ID mode is 2.
* @retval false The frame security is not enabled or key ID mode is not 2.
*/
bool otMacFrameIsKeyIdMode2(otRadioFrame *aFrame);
/**
* Get the key ID of @p aFrame.
*