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

[Group] Decryption optimization #14974

Merged
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
8 changes: 8 additions & 0 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,13 +601,16 @@ void SessionManager::SecureGroupMessageDispatch(const PacketHeader & packetHeade
PayloadHeader payloadHeader;
SessionMessageDelegate::DuplicateMessage isDuplicate = SessionMessageDelegate::DuplicateMessage::No;
Credentials::GroupDataProvider * groups = Credentials::GetGroupDataProvider();
GroupId groupId;
VerifyOrReturn(nullptr != groups);

if (!packetHeader.GetDestinationGroupId().HasValue())
{
return; // malformed packet
}

groupId = packetHeader.GetDestinationGroupId().Value();
jepenven-silabs marked this conversation as resolved.
Show resolved Hide resolved

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