@@ -392,6 +392,7 @@ DeviceCommissioner::DeviceCommissioner() :
392
392
mOnDeviceConnectionRetryCallback (OnDeviceConnectionRetryFn, this ),
393
393
#endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES
394
394
mDeviceAttestationInformationVerificationCallback (OnDeviceAttestationInformationVerification, this ),
395
+ mDACChainRevocationStatusVerificationCallback (OnDACChainRevocationStatusVerification, this ),
395
396
mDeviceNOCChainCallback (OnDeviceNOCChainGeneration, this ), mSetUpCodePairer (this )
396
397
{}
397
398
@@ -877,7 +878,8 @@ DeviceCommissioner::ContinueCommissioningAfterDeviceAttestation(DeviceProxy * de
877
878
return CHIP_ERROR_INCORRECT_STATE;
878
879
}
879
880
880
- if (mCommissioningStage != CommissioningStage::kAttestationVerification )
881
+ if (mCommissioningStage != CommissioningStage::kAttestationVerification &&
882
+ mCommissioningStage != CommissioningStage::kAttestationRevocationCheck )
881
883
{
882
884
ChipLogError (Controller, " Commissioning is not attestation verification phase" );
883
885
return CHIP_ERROR_INCORRECT_STATE;
@@ -1146,14 +1148,69 @@ void DeviceCommissioner::OnDeviceAttestationInformationVerification(
1146
1148
}
1147
1149
}
1148
1150
else
1151
+ {
1152
+ {
1153
+ ChipLogProgress (Controller, " Successfully validated 'Attestation Information' command received from the device." );
1154
+ commissioner->CommissioningStageComplete (CHIP_NO_ERROR);
1155
+ }
1156
+ }
1157
+ }
1158
+
1159
+ void DeviceCommissioner::OnDACChainRevocationStatusVerification (
1160
+ void * context, const Credentials::DeviceAttestationVerifier::AttestationInfo & info, AttestationVerificationResult result)
1161
+ {
1162
+ MATTER_TRACE_SCOPE (" OnDACChainRevocationStatusVerification" , " DeviceCommissioner" );
1163
+ DeviceCommissioner * commissioner = reinterpret_cast <DeviceCommissioner *>(context);
1164
+
1165
+ if (!commissioner->mDeviceBeingCommissioned )
1166
+ {
1167
+ ChipLogError (Controller, " Device attestation verification result received when we're not commissioning a device" );
1168
+ return ;
1169
+ }
1170
+
1171
+ auto & params = commissioner->mDefaultCommissioner ->GetCommissioningParameters ();
1172
+ Credentials::DeviceAttestationDelegate * deviceAttestationDelegate = params.GetDeviceAttestationDelegate ();
1173
+
1174
+ if (result != AttestationVerificationResult::kSuccess )
1175
+ {
1176
+ CommissioningDelegate::CommissioningReport report;
1177
+ report.Set <AttestationErrorInfo>(result);
1178
+ if (result == AttestationVerificationResult::kNotImplemented )
1179
+ {
1180
+ ChipLogError (Controller,
1181
+ " Failed in verifying 'DAC Chain Revocation Status' command received from the device due to default "
1182
+ " DeviceAttestationVerifier Class not being overridden by a real implementation." );
1183
+ commissioner->CommissioningStageComplete (CHIP_ERROR_NOT_IMPLEMENTED, report);
1184
+ return ;
1185
+ }
1186
+
1187
+ ChipLogError (Controller,
1188
+ " Failed in verifying 'DAC Chain Revocation Status' command received from the device: err %hu. Look at "
1189
+ " AttestationVerificationResult enum to understand the errors" ,
1190
+ static_cast <uint16_t >(result));
1191
+ // Go look at AttestationVerificationResult enum in src/credentials/attestation_verifier/DeviceAttestationVerifier.h to
1192
+ // understand the errors.
1193
+
1194
+ // If a device attestation status delegate is installed, delegate handling of failure to the client and let them decide on
1195
+ // whether to proceed further or not.
1196
+ if (deviceAttestationDelegate)
1197
+ {
1198
+ commissioner->ExtendArmFailSafeForDeviceAttestation (info, result);
1199
+ }
1200
+ else
1201
+ {
1202
+ commissioner->CommissioningStageComplete (CHIP_ERROR_INTERNAL, report);
1203
+ }
1204
+ }
1205
+ else
1149
1206
{
1150
1207
if (deviceAttestationDelegate && deviceAttestationDelegate->ShouldWaitAfterDeviceAttestation ())
1151
1208
{
1152
1209
commissioner->ExtendArmFailSafeForDeviceAttestation (info, result);
1153
1210
}
1154
1211
else
1155
1212
{
1156
- ChipLogProgress (Controller, " Successfully validated 'Attestation Information ' command received from the device." );
1213
+ ChipLogProgress (Controller, " Successfully validated 'DAC Chain Revocation Status ' command received from the device." );
1157
1214
commissioner->CommissioningStageComplete (CHIP_NO_ERROR);
1158
1215
}
1159
1216
}
@@ -1305,6 +1362,18 @@ CHIP_ERROR DeviceCommissioner::ValidateAttestationInfo(const Credentials::Device
1305
1362
return CHIP_NO_ERROR;
1306
1363
}
1307
1364
1365
+ CHIP_ERROR
1366
+ DeviceCommissioner::ValidateDACChainRevocationStatus (const Credentials::DeviceAttestationVerifier::AttestationInfo & info)
1367
+ {
1368
+ MATTER_TRACE_SCOPE (" ValidateDACChainRevocationStatus" , " DeviceCommissioner" );
1369
+ VerifyOrReturnError (mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
1370
+ VerifyOrReturnError (mDeviceAttestationVerifier != nullptr , CHIP_ERROR_INCORRECT_STATE);
1371
+
1372
+ mDeviceAttestationVerifier ->ValidateDACChainRevocationStatus (info, &mDACChainRevocationStatusVerificationCallback );
1373
+
1374
+ return CHIP_NO_ERROR;
1375
+ }
1376
+
1308
1377
CHIP_ERROR DeviceCommissioner::ValidateCSR (DeviceProxy * proxy, const ByteSpan & NOCSRElements,
1309
1378
const ByteSpan & AttestationSignature, const ByteSpan & dac, const ByteSpan & csrNonce)
1310
1379
{
@@ -2925,6 +2994,31 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio
2925
2994
}
2926
2995
}
2927
2996
break ;
2997
+ case CommissioningStage::kAttestationRevocationCheck : {
2998
+ ChipLogProgress (Controller, " Verifying device's DAC chain revocation status" );
2999
+ if (!params.GetAttestationElements ().HasValue () || !params.GetAttestationSignature ().HasValue () ||
3000
+ !params.GetAttestationNonce ().HasValue () || !params.GetDAC ().HasValue () || !params.GetPAI ().HasValue () ||
3001
+ !params.GetRemoteVendorId ().HasValue () || !params.GetRemoteProductId ().HasValue ())
3002
+ {
3003
+ ChipLogError (Controller, " Missing attestation certificates" );
3004
+ CommissioningStageComplete (CHIP_ERROR_INVALID_ARGUMENT);
3005
+ return ;
3006
+ }
3007
+
3008
+ DeviceAttestationVerifier::AttestationInfo info (
3009
+ params.GetAttestationElements ().Value (),
3010
+ proxy->GetSecureSession ().Value ()->AsSecureSession ()->GetCryptoContext ().GetAttestationChallenge (),
3011
+ params.GetAttestationSignature ().Value (), params.GetPAI ().Value (), params.GetDAC ().Value (),
3012
+ params.GetAttestationNonce ().Value (), params.GetRemoteVendorId ().Value (), params.GetRemoteProductId ().Value ());
3013
+
3014
+ if (ValidateDACChainRevocationStatus (info) != CHIP_NO_ERROR)
3015
+ {
3016
+ ChipLogError (Controller, " Error validating device's DAC chain revocation status" );
3017
+ CommissioningStageComplete (CHIP_ERROR_INVALID_ARGUMENT);
3018
+ return ;
3019
+ }
3020
+ }
3021
+ break ;
2928
3022
case CommissioningStage::kSendOpCertSigningRequest : {
2929
3023
if (!params.GetCSRNonce ().HasValue ())
2930
3024
{
0 commit comments