Skip to content

Commit

Permalink
[border-agent] apply pskc if changed (openthread#10641)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
librasungirl authored Sep 2, 2024
1 parent d60aaab commit 98d1aed
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions src/core/meshcop/border_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,41 @@ Error BorderAgent::SetId(const Id &aId)

void BorderAgent::HandleNotifierEvents(Events aEvents)
{
VerifyOrExit(aEvents.ContainsAny(kEventThreadRoleChanged | kEventCommissionerStateChanged));

if ((aEvents.ContainsAny(kEventThreadRoleChanged | kEventCommissionerStateChanged)))
{
#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD
VerifyOrExit(Get<Commissioner>().IsDisabled());
VerifyOrExit(Get<Commissioner>().IsDisabled());
#endif

if (Get<Mle::MleRouter>().IsAttached())
{
Start();
if (Get<Mle::MleRouter>().IsAttached())
{
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:
Expand Down

0 comments on commit 98d1aed

Please sign in to comment.