[border-agent] apply pskc if changed (#10641)

This commit applies new pskc into secure transport when it's changed
via active/pending dataset, without impacting existing secure session
if any or ephemeralkey mode if it's activated
This commit is contained in:
Rongli Sun
2024-09-02 14:02:51 -07:00
committed by GitHub
parent d60aaab22e
commit 98d1aed973
+30 -8
View File
@@ -308,19 +308,41 @@ exit:
void BorderAgent::HandleNotifierEvents(Events aEvents) void BorderAgent::HandleNotifierEvents(Events aEvents)
{ {
VerifyOrExit(aEvents.ContainsAny(kEventThreadRoleChanged | kEventCommissionerStateChanged)); if ((aEvents.ContainsAny(kEventThreadRoleChanged | kEventCommissionerStateChanged)))
{
#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD #if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD
VerifyOrExit(Get<Commissioner>().IsDisabled()); VerifyOrExit(Get<Commissioner>().IsDisabled());
#endif #endif
if (Get<Mle::MleRouter>().IsAttached()) if (Get<Mle::MleRouter>().IsAttached())
{ {
Start(); Start();
}
else
{
Stop();
}
} }
else
if (aEvents.ContainsAny(kEventPskcChanged))
{ {
Stop(); VerifyOrExit(mState != kStateStopped);
#if OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE
// No-op if Ephemeralkey mode is activated, new pskc will be applied
// when Ephemeralkey mode is deactivated.
VerifyOrExit(!mUsingEphemeralKey);
#endif
{
Pskc pskc;
Get<KeyManager>().GetPskc(pskc);
// If there is secure session already established, it won't be impacted,
// new pskc will be applied for next connection.
SuccessOrExit(Get<Tmf::SecureAgent>().SetPsk(pskc.m8, Pskc::kSize));
pskc.Clear();
}
} }
exit: exit: