Skip to content

Commit

Permalink
[privacy] Don't enable privacy when privacy is not supported. (#22425) (
Browse files Browse the repository at this point in the history
#22452)

Co-authored-by: Martin Turon <mturon@google.com>
Co-authored-by: Andrei Litvin <andy314@gmail.com>
  • Loading branch information
3 people authored Sep 8, 2022
1 parent 9f4d680 commit 45dde43
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ CHIP_ERROR SessionManager::PrepareMessage(const SessionHandle & sessionHandle, P
packetHeader.SetDestinationGroupId(groupSession->GetGroupId());
packetHeader.SetMessageCounter(mGroupClientCounter.GetCounter(isControlMsg));
mGroupClientCounter.IncrementCounter(isControlMsg);
packetHeader.SetFlags(Header::SecFlagValues::kPrivacyFlag);
packetHeader.SetSessionType(Header::SessionType::kGroupSession);
NodeId sourceNodeId = fabric->GetNodeId();
packetHeader.SetSourceNodeId(sourceNodeId);
Expand Down
4 changes: 2 additions & 2 deletions src/transport/raw/MessageHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,14 @@ class PacketHeader
{
// Check is based on spec 4.11.2
return (IsGroupSession() && GetSourceNodeId().HasValue() && GetDestinationGroupId().HasValue() &&
!IsSecureSessionControlMsg() && HasPrivacyFlag());
!IsSecureSessionControlMsg());
}

bool IsValidMCSPMsg() const
{
// Check is based on spec 4.9.2.4
return (IsGroupSession() && GetSourceNodeId().HasValue() && GetDestinationNodeId().HasValue() &&
IsSecureSessionControlMsg() && HasPrivacyFlag());
IsSecureSessionControlMsg());
}

bool IsEncrypted() const { return !((mSessionId == kMsgUnicastSessionIdUnsecured) && IsUnicastSession()); }
Expand Down
4 changes: 1 addition & 3 deletions src/transport/raw/tests/TestMessageHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ void TestPacketHeaderEncodeDecode(nlTestSuite * inSuite, void * inContext)

header.ClearDestinationNodeId();
header.SetSessionType(Header::SessionType::kGroupSession);
header.SetFlags(Header::SecFlagValues::kPrivacyFlag);
header.SetSecureSessionControlMsg(false);
NL_TEST_ASSERT(inSuite, header.Encode(buffer, &encodeLen) == CHIP_NO_ERROR);

Expand All @@ -165,7 +164,7 @@ void TestPacketHeaderEncodeDecode(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, header.IsValidGroupMsg());

// Verify MCSP state
header.ClearDestinationGroupId().SetDestinationNodeId(42).SetFlags(Header::SecFlagValues::kPrivacyFlag);
header.ClearDestinationGroupId().SetDestinationNodeId(42);
header.SetSecureSessionControlMsg(true);
NL_TEST_ASSERT(inSuite, header.Encode(buffer, &encodeLen) == CHIP_NO_ERROR);

Expand All @@ -174,7 +173,6 @@ void TestPacketHeaderEncodeDecode(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, header.Decode(buffer, &decodeLen) == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, header.GetDestinationNodeId() == Optional<uint64_t>::Value(42ull));
NL_TEST_ASSERT(inSuite, !header.GetDestinationGroupId().HasValue());
NL_TEST_ASSERT(inSuite, header.HasPrivacyFlag());
NL_TEST_ASSERT(inSuite, header.IsValidMCSPMsg());
}

Expand Down

0 comments on commit 45dde43

Please sign in to comment.