Skip to content

Commit

Permalink
Group Key Management XML: Review comments applied.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcasallas-silabs committed Feb 4, 2022
1 parent 49fbca4 commit 4cef16b
Show file tree
Hide file tree
Showing 46 changed files with 4,439 additions and 7,300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1509,25 +1509,25 @@ server cluster GroupKeyManagement = 63 {
fabric_idx fabricIndex = 0;
group_id groupId = 1;
endpoint_no endpoints[] = 2;
CHAR_STRING groupName = 3;
optional CHAR_STRING<16> groupName = 3;
}

struct GroupKeySetStruct {
INT16U groupKeySetID = 0;
GroupKeySecurityPolicy groupKeySecurityPolicy = 1;
OCTET_STRING epochKey0 = 2;
epoch_us epochStartTime0 = 3;
OCTET_STRING epochKey1 = 4;
epoch_us epochStartTime1 = 5;
OCTET_STRING epochKey2 = 6;
epoch_us epochStartTime2 = 7;
}

attribute(writable) GroupKeyMapStruct groupKeyMap[] = 0;
attribute(readonly) GroupInfoMapStruct groupTable[] = 1;
attribute(readonly) int16u maxGroupsPerFabric = 2;
attribute(readonly) int16u maxGroupKeysPerFabric = 3;
attribute(readonly) int16u clusterRevision = 65533;
nullable OCTET_STRING<16> epochKey0 = 2;
nullable epoch_us epochStartTime0 = 3;
nullable OCTET_STRING<16> epochKey1 = 4;
nullable epoch_us epochStartTime1 = 5;
nullable OCTET_STRING<16> epochKey2 = 6;
nullable epoch_us epochStartTime2 = 7;
}

attribute GroupKeyMapStruct groupKeyMap[] = 0;
readonly attribute GroupInfoMapStruct groupTable[] = 1;
readonly attribute int16u maxGroupsPerFabric = 2;
readonly attribute int16u maxGroupKeysPerFabric = 3;
readonly global attribute int16u clusterRevision = 65533;

request struct KeySetReadRequest {
INT16U groupKeySetID = 0;
Expand All @@ -1542,15 +1542,15 @@ server cluster GroupKeyManagement = 63 {
}

request struct KeySetWriteRequest {
GroupKeySetStruct groupKeySetStruct = 0;
GroupKeySetStruct groupKeySet = 0;
}

response struct KeySetReadAllIndicesResponse {
INT16U groupKeySetIDs[] = 0;
}

response struct KeySetReadResponse {
GroupKeySetStruct groupKeySetStruct = 0;
GroupKeySetStruct groupKeySet = 0;
}

command KeySetRead(KeySetReadRequest): KeySetReadResponse = 1;
Expand Down
8 changes: 4 additions & 4 deletions examples/thermostat/thermostat-common/thermostat.matter
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,12 @@ server cluster GroupKeyManagement = 63 {
fabric_idx fabricIndex = 0;
group_id groupId = 1;
endpoint_no endpoints[] = 2;
CHAR_STRING groupName = 3;
optional CHAR_STRING<16> groupName = 3;
}

attribute(writable) GroupKeyMapStruct groupKeyMap[] = 0;
attribute(readonly) GroupInfoMapStruct groupTable[] = 1;
attribute(readonly) int16u clusterRevision = 65533;
attribute GroupKeyMapStruct groupKeyMap[] = 0;
readonly attribute GroupInfoMapStruct groupTable[] = 1;
readonly global attribute int16u clusterRevision = 65533;
}

server cluster Groups = 4 {
Expand Down
8 changes: 4 additions & 4 deletions examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -766,12 +766,12 @@ server cluster GroupKeyManagement = 63 {
fabric_idx fabricIndex = 0;
group_id groupId = 1;
endpoint_no endpoints[] = 2;
CHAR_STRING groupName = 3;
optional CHAR_STRING<16> groupName = 3;
}

attribute(writable) GroupKeyMapStruct groupKeyMap[] = 0;
attribute(readonly) GroupInfoMapStruct groupTable[] = 1;
attribute(readonly) int16u clusterRevision = 65533;
attribute GroupKeyMapStruct groupKeyMap[] = 0;
readonly attribute GroupInfoMapStruct groupTable[] = 1;
readonly global attribute int16u clusterRevision = 65533;
}

server cluster KeypadInput = 1289 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1432,12 +1432,12 @@ server cluster GroupKeyManagement = 63 {
fabric_idx fabricIndex = 0;
group_id groupId = 1;
endpoint_no endpoints[] = 2;
CHAR_STRING groupName = 3;
optional CHAR_STRING<16> groupName = 3;
}

attribute(writable) GroupKeyMapStruct groupKeyMap[] = 0;
attribute(readonly) GroupInfoMapStruct groupTable[] = 1;
attribute(readonly) int16u clusterRevision = 65533;
attribute GroupKeyMapStruct groupKeyMap[] = 0;
readonly attribute GroupInfoMapStruct groupTable[] = 1;
readonly global attribute int16u clusterRevision = 65533;
}

server cluster Groups = 4 {
Expand Down
62 changes: 31 additions & 31 deletions src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,42 +267,45 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback(
return true;
}

if (commandData.groupKeySetStruct.epochKey0.empty() || (0 == commandData.groupKeySetStruct.epochStartTime0))
if (commandData.groupKeySet.epochKey0.IsNull() || commandData.groupKeySet.epochStartTime0.IsNull() ||
commandData.groupKeySet.epochKey0.Value().empty() || (0 == commandData.groupKeySet.epochStartTime0.Value()))
{
// If the EpochKey0 field is null or its associated EpochStartTime0 field is null,
// then this command SHALL fail with an INVALID_COMMAND
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND);
return true;
}

GroupDataProvider::KeySet keyset(commandData.groupKeySetStruct.groupKeySetID,
commandData.groupKeySetStruct.groupKeySecurityPolicy, 0);
GroupDataProvider::KeySet keyset(commandData.groupKeySet.groupKeySetID, commandData.groupKeySet.groupKeySecurityPolicy, 0);

// Epoch Key 0
keyset.epoch_keys[0].start_time = commandData.groupKeySetStruct.epochStartTime0;
memcpy(keyset.epoch_keys[0].key, commandData.groupKeySetStruct.epochKey0.data(), GroupDataProvider::EpochKey::kLengthBytes);
keyset.epoch_keys[0].start_time = commandData.groupKeySet.epochStartTime0.Value();
memcpy(keyset.epoch_keys[0].key, commandData.groupKeySet.epochKey0.Value().data(), GroupDataProvider::EpochKey::kLengthBytes);
keyset.num_keys_used++;

// Epoch Key 1
if (!commandData.groupKeySetStruct.epochKey1.empty())
if (!commandData.groupKeySet.epochKey1.IsNull() && !commandData.groupKeySet.epochStartTime1.IsNull() &&
!commandData.groupKeySet.epochKey1.Value().empty())
{
if (commandData.groupKeySetStruct.epochStartTime1 <= commandData.groupKeySetStruct.epochStartTime0)
if (commandData.groupKeySet.epochStartTime1.Value() <= commandData.groupKeySet.epochStartTime0.Value())
{
// If the EpochKey1 field is not null, its associated EpochStartTime1 field SHALL contain
// a later epoch start time than the epoch start time found in the EpochStartTime0 field.
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND);
return true;
}
keyset.epoch_keys[1].start_time = commandData.groupKeySetStruct.epochStartTime1;
memcpy(keyset.epoch_keys[1].key, commandData.groupKeySetStruct.epochKey1.data(), GroupDataProvider::EpochKey::kLengthBytes);
keyset.epoch_keys[1].start_time = commandData.groupKeySet.epochStartTime1.Value();
memcpy(keyset.epoch_keys[1].key, commandData.groupKeySet.epochKey1.Value().data(),
GroupDataProvider::EpochKey::kLengthBytes);
keyset.num_keys_used++;
}

// Epoch Key 2
if (!commandData.groupKeySetStruct.epochKey2.empty())
if (!commandData.groupKeySet.epochKey2.IsNull() && !commandData.groupKeySet.epochStartTime2.IsNull() &&
!commandData.groupKeySet.epochKey2.Value().empty())
{
keyset.num_keys_used++;
if (commandData.groupKeySetStruct.epochStartTime2 <= commandData.groupKeySetStruct.epochStartTime1)
if (commandData.groupKeySet.epochStartTime2.Value() <= commandData.groupKeySet.epochStartTime1.Value())
{
// If the EpochKey2 field is not null then:
// * The EpochKey1 field SHALL NOT be null
Expand All @@ -311,8 +314,9 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback(
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_COMMAND);
return true;
}
keyset.epoch_keys[2].start_time = commandData.groupKeySetStruct.epochStartTime2;
memcpy(keyset.epoch_keys[2].key, commandData.groupKeySetStruct.epochKey2.data(), GroupDataProvider::EpochKey::kLengthBytes);
keyset.epoch_keys[2].start_time = commandData.groupKeySet.epochStartTime2.Value();
memcpy(keyset.epoch_keys[2].key, commandData.groupKeySet.epochKey2.Value().data(),
GroupDataProvider::EpochKey::kLengthBytes);
keyset.num_keys_used++;
}

Expand Down Expand Up @@ -358,48 +362,44 @@ bool emberAfGroupKeyManagementClusterKeySetReadCallback(
return true;
}

// In KeySetReadResponse, EpochKey0, EpochKey1 and EpochKey2 key contents shall be null
// In KeySetReadResponse EpochKey0, EpochKey1 and EpochKey2 fields shall be null.

GroupKeyManagement::Commands::KeySetReadResponse::Type response;
response.groupKeySetStruct.groupKeySetID = keyset.keyset_id;
response.groupKeySetStruct.groupKeySecurityPolicy = keyset.policy;
response.groupKeySet.groupKeySetID = keyset.keyset_id;
response.groupKeySet.groupKeySecurityPolicy = keyset.policy;

// Keyset 0
if (keyset.num_keys_used > 0)
{
response.groupKeySetStruct.epochStartTime0 = keyset.epoch_keys[0].start_time;
response.groupKeySetStruct.epochKey0 = chip::ByteSpan(keyset.epoch_keys[0].key, GroupDataProvider::EpochKey::kLengthBytes);
response.groupKeySet.epochStartTime0.SetNonNull(keyset.epoch_keys[0].start_time);
}
else
{
response.groupKeySetStruct.epochStartTime0 = 0;
response.groupKeySetStruct.epochKey0 = chip::ByteSpan(nullptr, 0);
response.groupKeySet.epochStartTime0.SetNull();
}
response.groupKeySet.epochKey0 = ByteSpan();
response.groupKeySet.epochKey0.SetNull();

// Keyset 1
if (keyset.num_keys_used > 1)
{
response.groupKeySetStruct.epochStartTime1 = keyset.epoch_keys[1].start_time;
response.groupKeySetStruct.epochKey1 = chip::ByteSpan(keyset.epoch_keys[1].key, GroupDataProvider::EpochKey::kLengthBytes);
response.groupKeySet.epochStartTime1.SetNonNull(keyset.epoch_keys[1].start_time);
}
else
{
response.groupKeySetStruct.epochStartTime1 = 0;
response.groupKeySetStruct.epochKey1 = chip::ByteSpan(nullptr, 0);
response.groupKeySet.epochStartTime1.SetNull();
}
response.groupKeySet.epochKey1 = ByteSpan();
response.groupKeySet.epochKey1.SetNull();

// Keyset 2
if (keyset.num_keys_used > 2)
{
response.groupKeySetStruct.epochStartTime2 = keyset.epoch_keys[2].start_time;
response.groupKeySetStruct.epochKey2 = chip::ByteSpan(keyset.epoch_keys[2].key, GroupDataProvider::EpochKey::kLengthBytes);
response.groupKeySet.epochStartTime2.SetNonNull(keyset.epoch_keys[2].start_time);
}
else
{
response.groupKeySetStruct.epochStartTime2 = 0;
response.groupKeySetStruct.epochKey2 = chip::ByteSpan(nullptr, 0);
response.groupKeySet.epochStartTime2.SetNull();
}
response.groupKeySet.epochKey2 = ByteSpan();
response.groupKeySet.epochKey2.SetNull();

CHIP_ERROR err = commandObj->AddResponseData(commandPath, response);
if (CHIP_NO_ERROR != err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ limitations under the License.
<item fieldId="0" name="FabricIndex" type="fabric_idx"/>
<item fieldId="1" name="GroupId" type="group_id"/>
<item fieldId="2" name="Endpoints" type="endpoint_no" array="true"/>
<item fieldId="3" name="GroupName" type="CHAR_STRING" length="16" />
<item fieldId="3" name="GroupName" type="CHAR_STRING" length="16" optional="true"/>
</struct>

<struct name="GroupKeySetStruct">
<cluster code="0x003F"/>
<item fieldId="0" name="GroupKeySetID" type="INT16U"/>
<item fieldId="1" name="GroupKeySecurityPolicy" type="GroupKeySecurityPolicy"/>
<item fieldId="2" name="EpochKey0" type="OCTET_STRING" length="16"/>
<item fieldId="3" name="EpochStartTime0" type="epoch_us"/>
<item fieldId="4" name="EpochKey1" type="OCTET_STRING" length="16"/>
<item fieldId="5" name="EpochStartTime1" type="epoch_us"/>
<item fieldId="6" name="EpochKey2" type="OCTET_STRING" length="16"/>
<item fieldId="7" name="EpochStartTime2" type="epoch_us"/>
<item fieldId="2" name="EpochKey0" type="OCTET_STRING" length="16" isNullable="true"/>
<item fieldId="3" name="EpochStartTime0" type="epoch_us" isNullable="true"/>
<item fieldId="4" name="EpochKey1" type="OCTET_STRING" length="16" isNullable="true"/>
<item fieldId="5" name="EpochStartTime1" type="epoch_us" isNullable="true"/>
<item fieldId="6" name="EpochKey2" type="OCTET_STRING" length="16" isNullable="true"/>
<item fieldId="7" name="EpochStartTime2" type="epoch_us" isNullable="true"/>
</struct>

<enum name="GroupKeySecurityPolicy" type="ENUM8">
Expand All @@ -63,7 +63,7 @@ limitations under the License.

<command source="client" code="0x00" name="KeySetWrite" optional="false" cli="zcl GroupKeyManagement KeySetWrite">
<description>Revoke a Root Key from a Group</description>
<arg name="GroupKeySetStruct" type="GroupKeySetStruct"/>
<arg name="GroupKeySet" type="GroupKeySetStruct"/>
</command>

<command source="client" code="0x01" name="KeySetRead" response="KeySetReadResponse" optional="false" cli="zcl GroupKeyManagement KeySetRead">
Expand All @@ -75,7 +75,7 @@ limitations under the License.
<description>
Response to KeySetRead
</description>
<arg name="GroupKeySetStruct" type="GroupKeySetStruct"/>
<arg name="GroupKeySet" type="GroupKeySetStruct"/>
</command>

<command source="client" code="0x03" name="KeySetRemove" optional="false" cli="zcl GroupKeyManagement KeySetRemove">
Expand Down
50 changes: 23 additions & 27 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1824,26 +1824,26 @@ client cluster GroupKeyManagement = 63 {
fabric_idx fabricIndex = 0;
group_id groupId = 1;
endpoint_no endpoints[] = 2;
CHAR_STRING groupName = 3;
optional CHAR_STRING<16> groupName = 3;
}

struct GroupKeySetStruct {
INT16U groupKeySetID = 0;
GroupKeySecurityPolicy groupKeySecurityPolicy = 1;
OCTET_STRING epochKey0 = 2;
epoch_us epochStartTime0 = 3;
OCTET_STRING epochKey1 = 4;
epoch_us epochStartTime1 = 5;
OCTET_STRING epochKey2 = 6;
epoch_us epochStartTime2 = 7;
}

attribute(writable) GroupKeyMapStruct groupKeyMap[] = 0;
attribute(readonly) GroupInfoMapStruct groupTable[] = 1;
attribute(readonly) int16u maxGroupsPerFabric = 2;
attribute(readonly) int16u maxGroupKeysPerFabric = 3;
attribute(readonly) attrib_id attributeList[] = 65531;
attribute(readonly) int16u clusterRevision = 65533;
nullable OCTET_STRING<16> epochKey0 = 2;
nullable epoch_us epochStartTime0 = 3;
nullable OCTET_STRING<16> epochKey1 = 4;
nullable epoch_us epochStartTime1 = 5;
nullable OCTET_STRING<16> epochKey2 = 6;
nullable epoch_us epochStartTime2 = 7;
}

attribute GroupKeyMapStruct groupKeyMap[] = 0;
readonly attribute GroupInfoMapStruct groupTable[] = 1;
readonly attribute int16u maxGroupsPerFabric = 2;
readonly attribute int16u maxGroupKeysPerFabric = 3;
readonly global attribute attrib_id attributeList[] = 65531;
readonly global attribute int16u clusterRevision = 65533;

request struct KeySetReadRequest {
INT16U groupKeySetID = 0;
Expand All @@ -1858,15 +1858,15 @@ client cluster GroupKeyManagement = 63 {
}

request struct KeySetWriteRequest {
GroupKeySetStruct groupKeySetStruct = 0;
GroupKeySetStruct groupKeySet = 0;
}

response struct KeySetReadAllIndicesResponse {
INT16U groupKeySetIDs[] = 0;
}

response struct KeySetReadResponse {
GroupKeySetStruct groupKeySetStruct = 0;
GroupKeySetStruct groupKeySet = 0;
}

command KeySetRead(KeySetReadRequest): KeySetReadResponse = 1;
Expand Down Expand Up @@ -2209,9 +2209,7 @@ client cluster LevelControl = 8 {
client cluster LocalizationConfiguration = 43 {
attribute char_string<35> activeLocale = 1;
readonly attribute CHAR_STRING supportedLocales[] = 2;
readonly global attribute command_id serverGeneratedCommandList[] = 65528;
readonly global attribute command_id clientGeneratedCommandList[] = 65529;
readonly global attribute int16u clusterRevision = 65533;
readonly global nosubscribe attribute int16u clusterRevision = 65533;
}

client cluster LowPower = 1288 {
Expand Down Expand Up @@ -2714,7 +2712,7 @@ client cluster OperationalCredentials = 62 {
CHAR_STRING<32> label = 5;
}

readonly attribute NOCStruct NOCs[] = 0;
readonly nosubscribe attribute NOCStruct NOCs[] = 0;
readonly attribute FabricDescriptor fabricsList[] = 1;
readonly attribute int8u supportedFabrics = 2;
readonly attribute int8u commissionedFabrics = 3;
Expand Down Expand Up @@ -3783,12 +3781,10 @@ client cluster TimeFormatLocalization = 44 {
k24hr = 1;
}

attribute HourFormat hourFormat = 0;
attribute CalendarType activeCalendarType = 1;
readonly attribute CalendarType supportedCalendarTypes[] = 2;
readonly global attribute command_id serverGeneratedCommandList[] = 65528;
readonly global attribute command_id clientGeneratedCommandList[] = 65529;
readonly global attribute int16u clusterRevision = 65533;
nosubscribe attribute HourFormat hourFormat = 0;
nosubscribe attribute CalendarType activeCalendarType = 1;
readonly nosubscribe attribute CalendarType supportedCalendarTypes[] = 2;
readonly global nosubscribe attribute int16u clusterRevision = 65533;
}

client cluster UnitLocalization = 45 {
Expand Down
Loading

0 comments on commit 4cef16b

Please sign in to comment.