Skip to content

Commit

Permalink
GroupKeyManagement server: Added validation against groupKeySetID == …
Browse files Browse the repository at this point in the history
…0. (#16683)

* GroupKeyManagement server: Added validation against groupKeySetID == 0.

* GroupKeyManagement cluster: YAML test added.

* GroupKeyManagement cluster: Review comment applied.
  • Loading branch information
rcasallas-silabs authored and pull[bot] committed Oct 12, 2023
1 parent 9ba5038 commit 2419304
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
{
const auto & value = iter.GetValue();
VerifyOrReturnError(fabric_index == value.fabricIndex, CHIP_ERROR_INVALID_FABRIC_ID);
// Cannot map to IPK, see `GroupKeyMapStruct` in Group Key Management cluster spec
VerifyOrReturnError(value.groupKeySetID != 0, CHIP_IM_GLOBAL_STATUS(ConstraintError));

ReturnErrorOnFailure(provider->SetGroupKeyAt(value.fabricIndex, i++,
GroupDataProvider::GroupKey(value.groupId, value.groupKeySetID)));
}
Expand All @@ -215,6 +218,8 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
VerifyOrReturnError(nullptr != provider, CHIP_ERROR_INTERNAL);
ReturnErrorOnFailure(aDecoder.Decode(value));
VerifyOrReturnError(fabric_index == value.fabricIndex, CHIP_ERROR_INVALID_FABRIC_ID);
// Cannot map to IPK, see `GroupKeyMapStruct` in Group Key Management cluster spec
VerifyOrReturnError(value.groupKeySetID != 0, CHIP_IM_GLOBAL_STATUS(ConstraintError));

{
auto iter = provider->IterateGroupKeys(fabric_index);
Expand Down
8 changes: 8 additions & 0 deletions src/app/tests/suites/TestGroupKeyManagementCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ tests:
- name: "GroupKeySetIDs"
value: [0x01a1, 0x01a2]

- label: "Write Group Keys (invalid)"
command: "writeAttribute"
attribute: "GroupKeyMap"
arguments:
value: [{ FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0 }]
response:
error: CONSTRAINT_ERROR

- label: "Write Group Keys"
command: "writeAttribute"
attribute: "GroupKeyMap"
Expand Down
45 changes: 37 additions & 8 deletions src/darwin/Framework/CHIPTests/CHIPClustersTests.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 61 additions & 28 deletions zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2419304

Please sign in to comment.