Skip to content

Commit

Permalink
Group encryption/decryption enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcasallas-silabs committed Jan 28, 2022
1 parent 68440e5 commit 47dbe5e
Show file tree
Hide file tree
Showing 68 changed files with 4,011 additions and 966 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1275,32 +1275,32 @@ server cluster GroupKeyManagement = 63 {
kLowLatency = 1;
}

struct GroupKey {
struct GroupKeyMapStruct {
fabric_idx fabricIndex = 0;
INT16U groupId = 1;
group_id groupId = 1;
INT16U groupKeySetID = 2;
}

struct GroupInfo {
INT16U fabricIndex = 0;
INT16U groupId = 1;
INT16U endpoints[] = 2;
CHAR_STRING<16> groupName = 3;
struct GroupInfoMapStruct {
fabric_idx fabricIndex = 0;
group_id groupId = 1;
endpoint_no endpoints[] = 2;
optional CHAR_STRING<16> groupName = 3;
}

struct GroupKeySet {
struct GroupKeySetStruct {
INT16U groupKeySetID = 0;
GroupKeySecurityPolicy securityPolicy = 1;
OCTET_STRING<16> epochKey0 = 2;
INT64U epochStartTime0 = 3;
OCTET_STRING<16> epochKey1 = 4;
INT64U epochStartTime1 = 5;
OCTET_STRING<16> epochKey2 = 6;
INT64U epochStartTime2 = 7;
GroupKeySecurityPolicy groupKeySecurityPolicy = 1;
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;
}

readonly attribute GroupKey groupKeyMap[] = 0;
readonly attribute GroupInfo groupTable[] = 1;
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;
Expand All @@ -1318,15 +1318,15 @@ server cluster GroupKeyManagement = 63 {
}

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

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

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

command KeySetRead(KeySetReadRequest): KeySetReadResponse = 1;
Expand Down
44 changes: 44 additions & 0 deletions examples/chip-tool/commands/common/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,47 @@
#include <lib/support/CHIPMem.h>
#include <lib/support/CodeUtils.h>


#include <credentials/GroupDataProviderImpl.h>
#include <lib/support/TestPersistentStorageDelegate.h>

chip::TestPersistentStorageDelegate sDeviceStorage;
chip::Credentials::GroupDataProviderImpl sGroupsProvider(sDeviceStorage);

CHIP_ERROR GroupInit()
{
ReturnErrorOnFailure(sGroupsProvider.Init());
chip::Credentials::SetGroupDataProvider(&sGroupsProvider);

const chip::FabricIndex kFabric1 = 1;
const chip::GroupId kGroup1 = 0x1234;
const chip::GroupId kGroup2 = 0x0001;
const chip::KeysetId kKeySet1 = 0x0101;

const chip::Credentials::GroupDataProvider::GroupInfo group1(kGroup1, "Group #1");
ReturnErrorOnFailure(sGroupsProvider.SetGroupInfo(kFabric1, group1));
ReturnErrorOnFailure(sGroupsProvider.AddEndpoint(kFabric1, group1.group_id, 1));

const chip::Credentials::GroupDataProvider::GroupInfo group2(kGroup2, "Group #2");
ReturnErrorOnFailure(sGroupsProvider.SetGroupInfo(kFabric1, group2));
ReturnErrorOnFailure(sGroupsProvider.AddEndpoint(kFabric1, group2.group_id, 0));

chip::Credentials::GroupDataProvider::KeySet keyset1(kKeySet1, chip::Credentials::GroupDataProvider::KeySet::SecurityPolicy::kStandard, 3);
const chip::Credentials::GroupDataProvider::EpochKey epoch_keys[] = {
{ 0xaaaaaaaaaaaaaaaa, { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf } },
{ 0xbbbbbbbbbbbbbbbb, { 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf } },
{ 0xcccccccccccccccc, { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf } },
};
memcpy(keyset1.epoch_keys, epoch_keys, sizeof(epoch_keys));
ReturnErrorOnFailure(sGroupsProvider.SetKeySet(kFabric1, keyset1));

sGroupsProvider.SetGroupKeyAt(kFabric1, 0, chip::Credentials::GroupDataProvider::GroupKey(kGroup1, kKeySet1));
sGroupsProvider.SetGroupKeyAt(kFabric1, 1, chip::Credentials::GroupDataProvider::GroupKey(kGroup2, kKeySet1));

return CHIP_NO_ERROR;
}


void Commands::Register(const char * clusterName, commands_list commandsList)
{
for (auto & command : commandsList)
Expand All @@ -44,6 +85,9 @@ int Commands::Run(int argc, char ** argv)
err = mStorage.Init();
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init Storage failure: %s", chip::ErrorStr(err)));

err = GroupInit();
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init Group Data Provider failure: %s", chip::ErrorStr(err)));

chip::Logging::SetLogFilter(mStorage.GetLoggingLevel());

err = RunCommand(argc, argv);
Expand Down
118 changes: 118 additions & 0 deletions examples/light-switch-app/light-switch-common/light-switch-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,35 @@ client cluster Groups = 4 {
readonly attribute bitmap8 nameSupport = 0;
readonly global attribute attrib_id attributeList[] = 65531;
readonly global attribute int16u clusterRevision = 65533;

request struct AddGroupRequest {
INT16U groupId = 0;
CHAR_STRING groupName = 1;
}

request struct AddGroupIfIdentifyingRequest {
INT16U groupId = 0;
CHAR_STRING groupName = 1;
}

request struct GetGroupMembershipRequest {
INT16U groupList[] = 0;
}

request struct RemoveGroupRequest {
INT16U groupId = 0;
}

request struct ViewGroupRequest {
INT16U groupId = 0;
}

command AddGroup(AddGroupRequest): AddGroupResponse = 0;
command AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5;
command GetGroupMembership(GetGroupMembershipRequest): GetGroupMembershipResponse = 2;
command RemoveAllGroups(): DefaultSuccess = 4;
command RemoveGroup(RemoveGroupRequest): RemoveGroupResponse = 3;
command ViewGroup(ViewGroupRequest): ViewGroupResponse = 1;
}

client cluster Identify = 3 {
Expand Down Expand Up @@ -939,6 +968,10 @@ client cluster OnOff = 6 {
readonly global attribute attrib_id attributeList[] = 65531;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

command Off(): DefaultSuccess = 0;
command On(): DefaultSuccess = 1;
command Toggle(): DefaultSuccess = 2;
}

server cluster OperationalCredentials = 62 {
Expand Down Expand Up @@ -1064,6 +1097,91 @@ client cluster Scenes = 5 {
readonly attribute bitmap8 nameSupport = 4;
readonly global attribute attrib_id attributeList[] = 65531;
readonly global attribute int16u clusterRevision = 65533;

request struct AddSceneRequest {
INT16U groupId = 0;
INT8U sceneId = 1;
INT16U transitionTime = 2;
CHAR_STRING sceneName = 3;
SceneExtensionFieldSet extensionFieldSets[] = 4;
}

request struct GetSceneMembershipRequest {
INT16U groupId = 0;
}

request struct RecallSceneRequest {
INT16U groupId = 0;
INT8U sceneId = 1;
INT16U transitionTime = 2;
}

request struct RemoveAllScenesRequest {
INT16U groupId = 0;
}

request struct RemoveSceneRequest {
INT16U groupId = 0;
INT8U sceneId = 1;
}

request struct StoreSceneRequest {
INT16U groupId = 0;
INT8U sceneId = 1;
}

request struct ViewSceneRequest {
INT16U groupId = 0;
INT8U sceneId = 1;
}

response struct AddSceneResponse {
ENUM8 status = 0;
INT16U groupId = 1;
INT8U sceneId = 2;
}

response struct GetSceneMembershipResponse {
ENUM8 status = 0;
INT8U capacity = 1;
INT16U groupId = 2;
INT8U sceneCount = 3;
INT8U sceneList[] = 4;
}

response struct RemoveAllScenesResponse {
ENUM8 status = 0;
INT16U groupId = 1;
}

response struct RemoveSceneResponse {
ENUM8 status = 0;
INT16U groupId = 1;
INT8U sceneId = 2;
}

response struct StoreSceneResponse {
ENUM8 status = 0;
INT16U groupId = 1;
INT8U sceneId = 2;
}

response struct ViewSceneResponse {
ENUM8 status = 0;
INT16U groupId = 1;
INT8U sceneId = 2;
INT16U transitionTime = 3;
CHAR_STRING sceneName = 4;
SceneExtensionFieldSet extensionFieldSets[] = 5;
}

command AddScene(AddSceneRequest): AddSceneResponse = 0;
command GetSceneMembership(GetSceneMembershipRequest): GetSceneMembershipResponse = 6;
command RecallScene(RecallSceneRequest): DefaultSuccess = 5;
command RemoveAllScenes(RemoveAllScenesRequest): RemoveAllScenesResponse = 3;
command RemoveScene(RemoveSceneRequest): RemoveSceneResponse = 2;
command StoreScene(StoreSceneRequest): StoreSceneResponse = 4;
command ViewScene(ViewSceneRequest): ViewSceneResponse = 1;
}

server cluster SoftwareDiagnostics = 52 {
Expand Down
18 changes: 9 additions & 9 deletions examples/thermostat/thermostat-common/thermostat.matter
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,21 @@ server cluster GroupKeyManagement = 63 {
kLowLatency = 1;
}

struct GroupKey {
struct GroupKeyMapStruct {
fabric_idx fabricIndex = 0;
INT16U groupId = 1;
group_id groupId = 1;
INT16U groupKeySetID = 2;
}

struct GroupInfo {
INT16U fabricIndex = 0;
INT16U groupId = 1;
INT16U endpoints[] = 2;
CHAR_STRING<16> groupName = 3;
struct GroupInfoMapStruct {
fabric_idx fabricIndex = 0;
group_id groupId = 1;
endpoint_no endpoints[] = 2;
optional CHAR_STRING<16> groupName = 3;
}

readonly attribute GroupKey groupKeyMap[] = 0;
readonly attribute GroupInfo groupTable[] = 1;
attribute GroupKeyMapStruct groupKeyMap[] = 0;
readonly attribute GroupInfoMapStruct groupTable[] = 1;
readonly global attribute int16u clusterRevision = 65533;
}

Expand Down
18 changes: 9 additions & 9 deletions examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -671,21 +671,21 @@ server cluster GroupKeyManagement = 63 {
kLowLatency = 1;
}

struct GroupKey {
struct GroupKeyMapStruct {
fabric_idx fabricIndex = 0;
INT16U groupId = 1;
group_id groupId = 1;
INT16U groupKeySetID = 2;
}

struct GroupInfo {
INT16U fabricIndex = 0;
INT16U groupId = 1;
INT16U endpoints[] = 2;
CHAR_STRING<16> groupName = 3;
struct GroupInfoMapStruct {
fabric_idx fabricIndex = 0;
group_id groupId = 1;
endpoint_no endpoints[] = 2;
optional CHAR_STRING<16> groupName = 3;
}

readonly attribute GroupKey groupKeyMap[] = 0;
readonly attribute GroupInfo groupTable[] = 1;
attribute GroupKeyMapStruct groupKeyMap[] = 0;
readonly attribute GroupInfoMapStruct groupTable[] = 1;
readonly global attribute int16u clusterRevision = 65533;
}

Expand Down
18 changes: 9 additions & 9 deletions examples/tv-casting-app/tv-casting-common/tv-casting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1171,21 +1171,21 @@ server cluster GroupKeyManagement = 63 {
kLowLatency = 1;
}

struct GroupKey {
struct GroupKeyMapStruct {
fabric_idx fabricIndex = 0;
INT16U groupId = 1;
group_id groupId = 1;
INT16U groupKeySetID = 2;
}

struct GroupInfo {
INT16U fabricIndex = 0;
INT16U groupId = 1;
INT16U endpoints[] = 2;
CHAR_STRING<16> groupName = 3;
struct GroupInfoMapStruct {
fabric_idx fabricIndex = 0;
group_id groupId = 1;
endpoint_no endpoints[] = 2;
optional CHAR_STRING<16> groupName = 3;
}

readonly attribute GroupKey groupKeyMap[] = 0;
readonly attribute GroupInfo groupTable[] = 1;
attribute GroupKeyMapStruct groupKeyMap[] = 0;
readonly attribute GroupInfoMapStruct groupTable[] = 1;
readonly global attribute int16u clusterRevision = 65533;
}

Expand Down
Loading

0 comments on commit 47dbe5e

Please sign in to comment.