Skip to content

Commit

Permalink
Migrate PASE session to newly created fabric (project-chip#13712)
Browse files Browse the repository at this point in the history
* Place PASESession on new fabric

PASE sessions start with no fabric, but during commissioning,
after OperationalCredentialsCluster::AddNOC, they should be
placed on the newly commissioned fabric so administrative
actions pertaining to the newly commissioned fabric can be
performed over the PASE session, if desired.

Work towards issue project-chip#10242

* Change SecureSession::NewFabric to alter mFabric

This makes it easier to also have it be the accessing fabric after the
change.
  • Loading branch information
mlepage-google authored and selissia committed Jan 28, 2022
1 parent bf52c1a commit 7a2603f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ bool emberAfOperationalCredentialsClusterAddNOCCallback(app::CommandHandler * co
err = Server::GetInstance().GetFabricTable().Store(fabricIndex);
VerifyOrExit(err == CHIP_NO_ERROR, nocResponse = ConvertToNOCResponseStatus(err));

// Notify the secure session of the new fabric.
commandObj->GetExchangeContext()->GetSessionHandle()->AsSecureSession()->NewFabric(fabricIndex);

// We might have a new operational identity, so we should start advertising it right away.
app::DnssdServer::Instance().AdvertiseOperational();

Expand Down
6 changes: 3 additions & 3 deletions src/transport/SecureSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Access::SubjectDescriptor SecureSession::GetSubjectDescriptor() const
}
else if (IsPAKEKeyId(mPeerNodeId))
{
subjectDescriptor.authMode = Access::AuthMode::kPase;
subjectDescriptor.subject = mPeerNodeId;
// TODO(#10242): PASE *can* have fabric in some situations
subjectDescriptor.authMode = Access::AuthMode::kPase;
subjectDescriptor.subject = mPeerNodeId;
subjectDescriptor.fabricIndex = mFabric;
}
else
{
Expand Down
22 changes: 21 additions & 1 deletion src/transport/SecureSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ class SecureSession : public Session
uint16_t GetPeerSessionId() const { return mPeerSessionId; }
FabricIndex GetFabricIndex() const { return mFabric; }

// Should only be called for PASE sessions, which start with undefined fabric,
// to migrate to a newly commissioned fabric after successful
// OperationalCredentialsCluster::AddNOC
CHIP_ERROR NewFabric(FabricIndex fabricIndex)
{
#if 0
// TODO(#13711): this check won't work until the issue is addressed
if (mSecureSessionType == Type::kPASE)
{
mFabric = fabricIndex;
}
#else
mFabric = fabricIndex;
#endif
return CHIP_NO_ERROR;
}

System::Clock::Timestamp GetLastActivityTime() const { return mLastActivityTime; }
void MarkActive() { mLastActivityTime = System::SystemClock().GetMonotonicTimestamp(); }

Expand All @@ -139,7 +156,10 @@ class SecureSession : public Session
const CATValues mPeerCATs;
const uint16_t mLocalSessionId;
const uint16_t mPeerSessionId;
const FabricIndex mFabric;

// PASE sessions start with undefined fabric, but are migrated to a newly
// commissioned fabric after successful OperationalCredentialsCluster::AddNOC
FabricIndex mFabric;

PeerAddress mPeerAddress;
System::Clock::Timestamp mLastActivityTime;
Expand Down

0 comments on commit 7a2603f

Please sign in to comment.