@@ -1217,31 +1217,34 @@ TEST_F(TestGroupDataProvider, TestGroupDecryption)
1217
1217
size_t count = 0 , total = 0 ;
1218
1218
1219
1219
EXPECT_TRUE (it);
1220
- total = it->Count ();
1221
- EXPECT_EQ (expected.size (), total);
1222
- while (it->Next (session))
1220
+ if (it)
1223
1221
{
1224
- std::pair<FabricIndex, GroupId> found (session.fabric_index , session.group_id );
1225
- EXPECT_GT (expected.count (found), 0u );
1226
- EXPECT_NE (session.keyContext , nullptr );
1227
- // Assert aboves doesn't actually exit, we call continue so that we can call it->Release() outside of
1228
- // loop.
1229
- if (session.keyContext == nullptr )
1222
+ total = it->Count ();
1223
+ EXPECT_EQ (expected.size (), total);
1224
+ while (it->Next (session))
1230
1225
{
1231
- continue ;
1226
+ std::pair<FabricIndex, GroupId> found (session.fabric_index , session.group_id );
1227
+ EXPECT_GT (expected.count (found), 0u );
1228
+ EXPECT_NE (session.keyContext , nullptr );
1229
+ // Assert aboves doesn't actually exit, we call continue so that we can call it->Release() outside of
1230
+ // loop.
1231
+ if (session.keyContext == nullptr )
1232
+ {
1233
+ continue ;
1234
+ }
1235
+
1236
+ // Decrypt the ciphertext
1237
+ EXPECT_EQ (session.keyContext ->MessageDecrypt (ciphertext, ByteSpan (aad, sizeof (aad)), ByteSpan (nonce, sizeof (nonce)),
1238
+ tag, plaintext),
1239
+ CHIP_NO_ERROR);
1240
+
1241
+ // The new plaintext must match the original message
1242
+ EXPECT_EQ (memcmp (plaintext.data (), kMessage , sizeof (kMessage )), 0 );
1243
+ count++;
1232
1244
}
1233
-
1234
- // Decrypt the ciphertext
1235
- EXPECT_EQ (session.keyContext ->MessageDecrypt (ciphertext, ByteSpan (aad, sizeof (aad)), ByteSpan (nonce, sizeof (nonce)), tag,
1236
- plaintext),
1237
- CHIP_NO_ERROR);
1238
-
1239
- // The new plaintext must match the original message
1240
- EXPECT_EQ (memcmp (plaintext.data (), kMessage , sizeof (kMessage )), 0 );
1241
- count++;
1245
+ EXPECT_EQ (count, total);
1246
+ it->Release ();
1242
1247
}
1243
- EXPECT_EQ (count, total);
1244
- it->Release ();
1245
1248
}
1246
1249
1247
1250
} // namespace TestGroups
0 commit comments