From 06d83fcca17f5d6d4993147d974019ab44bbd1bb Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 30 Oct 2024 13:03:08 -0700 Subject: [PATCH] [border-agent] invoke ephemeral key callback on session connection (#10699) This commit updates the Border Agent to invoke the ephemeral key callback when a commissioner candidate successfully establishes a secure session using the ephemeral key. This can be identified by checking the state `otBorderAgentGetState()` and matching it with `OT_BORDER_AGENT_STATE_ACTIVE`. This new signal can be used to stop advertising the mDNS service "_meshcop-e._udp" earlier (since the ephemeral key is one-time use). --- include/openthread/border_agent.h | 3 +++ include/openthread/instance.h | 2 +- src/core/meshcop/border_agent.cpp | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/openthread/border_agent.h b/include/openthread/border_agent.h index bfe0e7461..6411142cd 100644 --- a/include/openthread/border_agent.h +++ b/include/openthread/border_agent.h @@ -257,6 +257,9 @@ bool otBorderAgentIsEphemeralKeyActive(otInstance *aInstance); * * - The Border Agent starts using an ephemeral key. * - Any parameter related to the ephemeral key, such as the port number, changes. + * - A commissioner candidate successfully establishes a secure session with the Border Agent using the ephemeral key. + * This situation can be identified by `otBorderAgentGetState()` being `OT_BORDER_AGENT_STATE_ACTIVE` (this event + * can be used to stop advertising the mDNS service "_meshcop-e._udp"). * - The Border Agent stops using the ephemeral key due to: * - A direct call to `otBorderAgentClearEphemeralKey()`. * - The ephemeral key timing out. diff --git a/include/openthread/instance.h b/include/openthread/instance.h index daca8dace..4686ce001 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -52,7 +52,7 @@ extern "C" { * * @note This number versions both OpenThread platform and user APIs. */ -#define OPENTHREAD_API_VERSION (459) +#define OPENTHREAD_API_VERSION (460) /** * @addtogroup api-instance diff --git a/src/core/meshcop/border_agent.cpp b/src/core/meshcop/border_agent.cpp index f98746244..1e14c6649 100644 --- a/src/core/meshcop/border_agent.cpp +++ b/src/core/meshcop/border_agent.cpp @@ -655,6 +655,7 @@ void BorderAgent::HandleConnected(SecureTransport::ConnectEvent aEvent) if (mUsingEphemeralKey) { mCounters.mEpskcSecureSessionSuccesses++; + mEphemeralKeyTask.Post(); } else #endif