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 Feb 10, 2022
1 parent 05c26f4 commit 31b5331
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 31b5331

Please sign in to comment.