@@ -109,6 +109,9 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
109
109
// Register for the GroupKeyManagement cluster on all endpoints.
110
110
GroupKeyManagementAttributeAccess () : AttributeAccessInterface(Optional<EndpointId>(0 ), GroupKeyManagement::Id) {}
111
111
112
+ // TODO: Once there is MCSP support, this may need to change.
113
+ static constexpr bool IsMCSPSupported () { return false ; }
114
+
112
115
CHIP_ERROR Read (const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override
113
116
{
114
117
VerifyOrDie (aPath.mClusterId == GroupKeyManagement::Id);
@@ -117,8 +120,15 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
117
120
{
118
121
case GroupKeyManagement::Attributes::ClusterRevision::Id:
119
122
return ReadClusterRevision (aPath.mEndpointId , aEncoder);
120
- case Attributes::FeatureMap::Id:
121
- return aEncoder.Encode (static_cast <uint32_t >(0 ));
123
+ case Attributes::FeatureMap::Id: {
124
+ uint32_t features = 0 ;
125
+ if (IsMCSPSupported ())
126
+ {
127
+ // TODO: Once there is MCSP support, this will need to add the
128
+ // right feature bit.
129
+ }
130
+ return aEncoder.Encode (features);
131
+ }
122
132
case GroupKeyManagement::Attributes::GroupKeyMap::Id:
123
133
return ReadGroupKeyMap (aPath.mEndpointId , aEncoder);
124
134
case GroupKeyManagement::Attributes::GroupTable::Id:
@@ -296,29 +306,32 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback(
296
306
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
297
307
const chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::DecodableType & commandData)
298
308
{
299
- auto provider = GetGroupDataProvider ();
300
- auto fabric = Server::GetInstance ().GetFabricTable ().FindFabricWithIndex (commandObj->GetAccessingFabricIndex ());
301
-
302
- if (nullptr == provider || nullptr == fabric)
309
+ if (commandData.groupKeySet .epochKey0 .IsNull () || commandData.groupKeySet .epochStartTime0 .IsNull () ||
310
+ commandData.groupKeySet .epochKey0 .Value ().empty () || (0 == commandData.groupKeySet .epochStartTime0 .Value ()))
303
311
{
304
- commandObj->AddStatus (commandPath, Status::Failure);
312
+ // If the EpochKey0 field is null or its associated EpochStartTime0 field is null,
313
+ // then this command SHALL fail with an INVALID_COMMAND
314
+ commandObj->AddStatus (commandPath, Status::InvalidCommand);
305
315
return true ;
306
316
}
307
317
308
- uint8_t compressed_fabric_id_buffer[sizeof (uint64_t )];
309
- MutableByteSpan compressed_fabric_id (compressed_fabric_id_buffer);
310
- CHIP_ERROR err = fabric->GetCompressedFabricIdBytes (compressed_fabric_id);
311
- if (CHIP_NO_ERROR != err)
318
+ if (commandData.groupKeySet .groupKeySecurityPolicy == GroupKeySecurityPolicyEnum::kUnknownEnumValue )
312
319
{
313
- commandObj->AddStatus (commandPath, Status::Failure);
320
+ // If a client indicates an enumeration value to the server, that is not
321
+ // supported by the server, because it is ... a new value unrecognized
322
+ // by a legacy server, then the server SHALL generate a general
323
+ // constraint error
324
+ commandObj->AddStatus (commandPath, Status::ConstraintError);
314
325
return true ;
315
326
}
316
327
317
- if (commandData. groupKeySet . epochKey0 . IsNull () || commandData. groupKeySet . epochStartTime0 . IsNull () ||
318
- commandData.groupKeySet .epochKey0 . Value (). empty () || ( 0 == commandData. groupKeySet . epochStartTime0 . Value ()) )
328
+ if (! GroupKeyManagementAttributeAccess::IsMCSPSupported () &&
329
+ commandData.groupKeySet .groupKeySecurityPolicy == GroupKeySecurityPolicyEnum:: kCacheAndSync )
319
330
{
320
- // If the EpochKey0 field is null or its associated EpochStartTime0 field is null,
321
- // then this command SHALL fail with an INVALID_COMMAND
331
+ // When CacheAndSync is not supported in the FeatureMap of this cluster,
332
+ // any action attempting to set CacheAndSync in the
333
+ // GroupKeySecurityPolicy field SHALL fail with an INVALID_COMMAND
334
+ // error.
322
335
commandObj->AddStatus (commandPath, Status::InvalidCommand);
323
336
return true ;
324
337
}
@@ -366,6 +379,24 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback(
366
379
keyset.num_keys_used ++;
367
380
}
368
381
382
+ auto provider = GetGroupDataProvider ();
383
+ auto fabric = Server::GetInstance ().GetFabricTable ().FindFabricWithIndex (commandObj->GetAccessingFabricIndex ());
384
+
385
+ if (nullptr == provider || nullptr == fabric)
386
+ {
387
+ commandObj->AddStatus (commandPath, Status::Failure);
388
+ return true ;
389
+ }
390
+
391
+ uint8_t compressed_fabric_id_buffer[sizeof (uint64_t )];
392
+ MutableByteSpan compressed_fabric_id (compressed_fabric_id_buffer);
393
+ CHIP_ERROR err = fabric->GetCompressedFabricIdBytes (compressed_fabric_id);
394
+ if (CHIP_NO_ERROR != err)
395
+ {
396
+ commandObj->AddStatus (commandPath, Status::Failure);
397
+ return true ;
398
+ }
399
+
369
400
// Set KeySet
370
401
err = provider->SetKeySet (fabric->GetFabricIndex (), compressed_fabric_id, keyset);
371
402
if (CHIP_NO_ERROR == err)
0 commit comments