From b3b50f6da8e44ade7baf9c00b0bee2d3bd41012c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Maciejo=C5=84czyk?= <32327281+lmaciejonczyk@users.noreply.github.com> Date: Wed, 26 May 2021 23:03:48 +0200 Subject: [PATCH] [mac] always set Key Identifier for Transmit Security (#6678) For multi-layer application, the radio requires from the upper layer to provide information for security processing like Key Identifier, in the Auxiliary Security Header according to IEEE802.15.4-2015. This change matters for handling security processing by radio only. --- src/core/mac/sub_mac.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index 5b4f67e16..fea69f28b 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -328,10 +328,16 @@ void SubMac::ProcessTransmitSecurity(void) const ExtAddress *extAddress = nullptr; uint8_t keyIdMode; - VerifyOrExit(ShouldHandleTransmitSecurity()); VerifyOrExit(mTransmitFrame.GetSecurityEnabled()); VerifyOrExit(!mTransmitFrame.IsSecurityProcessed()); + if (!mTransmitFrame.IsARetransmission()) + { + mTransmitFrame.SetKeyId(mKeyId); + } + + VerifyOrExit(ShouldHandleTransmitSecurity()); + SuccessOrExit(mTransmitFrame.GetKeyIdMode(keyIdMode)); VerifyOrExit(keyIdMode == Frame::kKeyIdMode1); @@ -341,7 +347,6 @@ void SubMac::ProcessTransmitSecurity(void) { uint32_t frameCounter = GetFrameCounter(); - mTransmitFrame.SetKeyId(mKeyId); mTransmitFrame.SetFrameCounter(frameCounter); UpdateFrameCounter(frameCounter + 1); }