Skip to content

Commit

Permalink
[Group] Decryption optimization (#14974)
Browse files Browse the repository at this point in the history
* optimization

* fix build
  • Loading branch information
jepenven-silabs authored and pull[bot] committed Sep 7, 2023
1 parent 3a6b61a commit 2655590
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,8 @@ void SessionManager::SecureGroupMessageDispatch(const PacketHeader & packetHeade
return; // malformed packet
}

GroupId groupId = packetHeader.GetDestinationGroupId().Value();

if (msg.IsNull())
{
ChipLogError(Inet, "Secure transport received Groupcast NULL packet, discarding");
Expand All @@ -634,6 +636,11 @@ void SessionManager::SecureGroupMessageDispatch(const PacketHeader & packetHeade
bool decrypted = false;
while (!decrypted && iter->Next(groupContext))
{
// Optimization to reduce number of decryption attempts
if (groupId != groupContext.group_id)
{
continue;
}
msgCopy = msg.CloneData();
decrypted =
(CHIP_NO_ERROR == SecureMessageCodec::Decrypt(CryptoContext(groupContext.key), payloadHeader, packetHeader, msgCopy));
Expand Down

0 comments on commit 2655590

Please sign in to comment.