Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate PASE session to newly created fabric #13712

Merged
merged 3 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,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(commandObj->GetAccessingFabricIndex());
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
mlepage-google marked this conversation as resolved.
Show resolved Hide resolved

// 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 = mPaseFabric;
}
else
{
Expand Down
16 changes: 16 additions & 0 deletions src/transport/SecureSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ 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 place on a newly commissioned fabric after successful
// OperationalCredentialsCluster::AddNOC
CHIP_ERROR NewFabric(FabricIndex fabricIndex)
{
// TODO: should check that secure session type is PASE and current value is undefined
// (i.e. that it's called exactly once in proper circumstances)
// but that's difficult until issue #13711 is addressed
mPaseFabric = fabricIndex;
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
return CHIP_NO_ERROR;
}

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

Expand Down Expand Up @@ -141,6 +153,10 @@ class SecureSession : public Session
const uint16_t mPeerSessionId;
const FabricIndex mFabric;

// PASE sessions start with undefined fabric, but can be placed on a newly
// commissioned fabric after successful OperationalCredentialsCluster::AddNOC
FabricIndex mPaseFabric = kUndefinedFabricIndex;

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