Skip to content

Commit

Permalink
Group Key Management cluster XML: Bugs fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcasallas-silabs committed Feb 3, 2022
1 parent afc4c44 commit d5f747b
Show file tree
Hide file tree
Showing 18 changed files with 2,127 additions and 2,378 deletions.
42 changes: 21 additions & 21 deletions src/app/tests/suites/TestGroupKeyManagementCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ tests:
arguments:
values:
- name: "GroupId"
value: 0x0011
value: 0x0101
- name: "GroupName"
value: "Group #1"
response:
values:
- name: "status"
value: 0
- name: "GroupId"
value: 0x0011
value: 0x0101

- label: "Add Group 2"
cluster: "Groups"
Expand All @@ -60,15 +60,15 @@ tests:
arguments:
values:
- name: "GroupId"
value: 0x0012
value: 0x0102
- name: "GroupName"
value: "Group #2"
response:
values:
- name: "status"
value: 0
- name: "GroupId"
value: 0x0012
value: 0x0102

- label: "KeySet Write 1"
command: "KeySetWrite"
Expand All @@ -77,7 +77,7 @@ tests:
- name: "GroupKeySet"
value:
{
GroupKeySetID: 0x0101,
GroupKeySetID: 0x01a1,
GroupKeySecurityPolicy: 0,
EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
EpochStartTime0: 1110000,
Expand All @@ -94,7 +94,7 @@ tests:
- name: "GroupKeySet"
value:
{
GroupKeySetID: 0x0102,
GroupKeySetID: 0x01a2,
GroupKeySecurityPolicy: 1,
EpochKey0: "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
EpochStartTime0: 2110000,
Expand All @@ -109,13 +109,13 @@ tests:
arguments:
values:
- name: "GroupKeySetID"
value: 0x0101
value: 0x01a1
response:
values:
- name: "GroupKeySet"
value:
{
GroupKeySetID: 0x0101,
GroupKeySetID: 0x01a1,
GroupKeySecurityPolicy: 0,
EpochKey0: null,
EpochStartTime0: 1110000,
Expand All @@ -131,16 +131,16 @@ tests:
response:
values:
- name: "GroupKeySetIDs"
value: [0x0101, 0x0102]
value: [0x01a1, 0x01a2]

- label: "Write Group Keys"
command: "writeAttribute"
attribute: "GroupKeyMap"
arguments:
value:
[
{ FabricIndex: 1, GroupId: 0x0011, GroupKeySetID: 0x0101 },
{ FabricIndex: 1, GroupId: 0x0012, GroupKeySetID: 0x0102 },
{ FabricIndex: 1, GroupId: 0x0101, GroupKeySetID: 0x01a1 },
{ FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a2 },
]

- label: "Read Group Keys"
Expand All @@ -149,8 +149,8 @@ tests:
response:
value:
[
{ FabricIndex: 1, GroupId: 0x0011, GroupKeySetID: 0x0101 },
{ FabricIndex: 1, GroupId: 0x0012, GroupKeySetID: 0x0102 },
{ FabricIndex: 1, GroupId: 0x0101, GroupKeySetID: 0x01a1 },
{ FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a2 },
]

- label: "Read GroupTable"
Expand All @@ -161,13 +161,13 @@ tests:
[
{
FabricIndex: 1,
GroupId: 0x0011,
GroupId: 0x0101,
endpoints: [1],
GroupName: "Group #1",
},
{
FabricIndex: 1,
GroupId: 0x0012,
GroupId: 0x0102,
endpoints: [1],
GroupName: "Group #2",
},
Expand All @@ -178,14 +178,14 @@ tests:
arguments:
values:
- name: "GroupKeySetID"
value: 0x0101
value: 0x01a1

- label: "KeySet Read (removed)"
command: "KeySetRead"
arguments:
values:
- name: "GroupKeySetID"
value: 0x0101
value: 0x01a1
response:
error: NOT_FOUND

Expand All @@ -194,13 +194,13 @@ tests:
arguments:
values:
- name: "GroupKeySetID"
value: 0x0102
value: 0x01a2
response:
values:
- name: "GroupKeySet"
value:
{
GroupKeySetID: 0x0102,
GroupKeySetID: 0x01a2,
GroupKeySecurityPolicy: 1,
EpochKey0: null,
EpochStartTime0: 2110000,
Expand All @@ -220,13 +220,13 @@ tests:
arguments:
values:
- name: "GroupKeySetID"
value: 0x0102
value: 0x01a2

- label: "KeySet Read (also removed)"
command: "KeySetRead"
arguments:
values:
- name: "GroupKeySetID"
value: 0x0102
value: 0x01a2
response:
error: NOT_FOUND
46 changes: 23 additions & 23 deletions src/app/tests/suites/TestGroupMessaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ tests:
arguments:
values:
- name: "groupId"
value: 0x1234
value: 0x0101
- name: "groupName"
value: "Group #1"
response:
values:
- name: "status"
value: 0
- name: "groupId"
value: 0x1234
value: 0x0101

- label: "Add Group 2 - endpoint 0"
cluster: "Groups"
Expand All @@ -53,15 +53,15 @@ tests:
arguments:
values:
- name: "groupId"
value: 0x0001
value: 0x0102
- name: "groupName"
value: "Group #2"
response:
values:
- name: "status"
value: 0
- name: "groupId"
value: 0x0001
value: 0x0102

- label: "KeySet Write 1"
cluster: "Group Key Management"
Expand All @@ -71,14 +71,14 @@ tests:
- name: "GroupKeySet"
value:
{
groupKeySetID: 0x0101,
securityPolicy: 0,
epochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
epochStartTime0: 1110000,
epochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
epochStartTime1: 1110001,
epochKey2: "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
epochStartTime2: 1110002,
GroupKeySetID: 0x01a1,
GroupKeySecurityPolicy: 0,
EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
EpochStartTime0: 1110000,
EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
EpochStartTime1: 1110001,
EpochKey2: "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
EpochStartTime2: 1110002,
}

- label: "KeySet Write 2"
Expand All @@ -89,25 +89,25 @@ tests:
- name: "GroupKeySet"
value:
{
groupKeySetID: 0x0102,
securityPolicy: 0,
epochKey0: "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
epochStartTime0: 2220000,
epochKey1: "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
epochStartTime1: 2220001,
epochKey2: "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
epochStartTime2: 2220002,
GroupKeySetID: 0x01a2,
GroupKeySecurityPolicy: 1,
EpochKey0: "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
EpochStartTime0: 2110000,
EpochKey1: "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
EpochStartTime1: 2110001,
EpochKey2: "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
EpochStartTime2: 2110002,
}

- label: "Write Group Keys"
cluster: "Group Key Management"
command: "writeAttribute"
attribute: "groupKeyMap"
attribute: "GroupKeyMap"
arguments:
value:
[
{ fabricIndex: 1, groupId: 0x1234, groupKeySetID: 0x0101 },
{ fabricIndex: 1, groupId: 0x0001, groupKeySetID: 0x0102 },
{ FabricIndex: 1, GroupId: 0x0101, GroupKeySetID: 0x01a1 },
{ FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a2 },
]

# Test Pair 1 : Sends a Group Write Attribute
Expand Down
7 changes: 5 additions & 2 deletions src/credentials/GroupDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ CHIP_ERROR GroupDataProviderImpl::GetKeySet(chip::FabricIndex fabric_index, uint
out_keyset.keyset_id = keyset.keyset_id;
out_keyset.policy = keyset.policy;
out_keyset.num_keys_used = keyset.keys_count;
// Epoch keys are not read back, only the times
// Epoch keys are not read back, only start times
memset(out_keyset.epoch_keys, 0x00, sizeof(out_keyset.epoch_keys));
out_keyset.epoch_keys[0].start_time = keyset.operational_keys[0].start_time;
out_keyset.epoch_keys[1].start_time = keyset.operational_keys[1].start_time;
Expand Down Expand Up @@ -1718,8 +1718,11 @@ bool GroupDataProviderImpl::KeySetIteratorImpl::Next(KeySet & output)
output.keyset_id = keyset.keyset_id;
output.policy = keyset.policy;
output.num_keys_used = keyset.keys_count;
// Epoch keys are not read back
// Epoch keys are not read back, only start times
memset(output.epoch_keys, 0x00, sizeof(output.epoch_keys));
output.epoch_keys[0].start_time = keyset.operational_keys[0].start_time;
output.epoch_keys[1].start_time = keyset.operational_keys[1].start_time;
output.epoch_keys[2].start_time = keyset.operational_keys[2].start_time;
return true;
}

Expand Down
13 changes: 8 additions & 5 deletions src/credentials/tests/TestGroupDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,14 @@ static TestListener sListener;

bool CompareKeySets(const KeySet & keyset1, const KeySet & keyset2)
{
ReturnErrorOnFailure(keyset1.policy == keyset2.policy);
ReturnErrorOnFailure(keyset1.num_keys_used == keyset2.num_keys_used);
ReturnErrorOnFailure(keyset1.epoch_keys[0].start_time == keyset2.epoch_keys[0].start_time);
ReturnErrorOnFailure(keyset1.epoch_keys[1].start_time == keyset2.epoch_keys[1].start_time);
ReturnErrorOnFailure(keyset1.epoch_keys[2].start_time == keyset2.epoch_keys[2].start_time);
VerifyOrReturnError(keyset1.policy == keyset2.policy, false);
VerifyOrReturnError(keyset1.num_keys_used == keyset2.num_keys_used, false);
VerifyOrReturnError(keyset1.epoch_keys[0].start_time == keyset2.epoch_keys[0].start_time, false);
VerifyOrReturnError(keyset1.epoch_keys[1].start_time == keyset2.epoch_keys[1].start_time, false);
VerifyOrReturnError(keyset1.epoch_keys[2].start_time == keyset2.epoch_keys[2].start_time, false);
VerifyOrReturnError(0 == memcmp(kZeroKey, keyset1.epoch_keys[0].key, EpochKey::kLengthBytes), false);
VerifyOrReturnError(0 == memcmp(kZeroKey, keyset1.epoch_keys[1].key, EpochKey::kLengthBytes), false);
VerifyOrReturnError(0 == memcmp(kZeroKey, keyset1.epoch_keys[2].key, EpochKey::kLengthBytes), false);
return true;
}

Expand Down
Loading

0 comments on commit d5f747b

Please sign in to comment.