Skip to content

Commit 11838c6

Browse files
committed
Removed the changes to add revocation set support to chip-tool and it will be submitted as a followup PR
1 parent 4db45bf commit 11838c6

17 files changed

+132
-336
lines changed

examples/chip-tool/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ static_library("chip-tool-utils") {
109109
"${chip_root}/src/app/tests/suites/commands/interaction_model",
110110
"${chip_root}/src/controller/data_model",
111111
"${chip_root}/src/credentials:file_attestation_trust_store",
112-
"${chip_root}/src/credentials:json_file_revocation_set",
113112
"${chip_root}/src/lib",
114113
"${chip_root}/src/lib/core:types",
115114
"${chip_root}/src/lib/support/jsontlv",

examples/chip-tool/commands/common/CHIPCommand.h

-5
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ class CHIPCommand : public Command
6969
CHIPCommand(const char * commandName, CredentialIssuerCommands * credIssuerCmds, const char * helpText = nullptr) :
7070
Command(commandName, helpText), mCredIssuerCmds(credIssuerCmds)
7171
{
72-
AddArgument(
73-
"revocation-set-path", &mRevocationSetPath,
74-
"Path to file holding a list of Revoked Certificates. Can be absolute or relative to the current working directory.");
7572
AddArgument("paa-trust-store-path", &mPaaTrustStorePath,
7673
"Path to directory holding PAA certificate information. Can be absolute or relative to the current working "
7774
"directory.");
@@ -221,7 +218,6 @@ class CHIPCommand : public Command
221218
chip::Optional<chip::NodeId> mCommissionerNodeId;
222219
chip::Optional<chip::VendorId> mCommissionerVendorId;
223220
chip::Optional<uint16_t> mBleAdapterId;
224-
chip::Optional<char *> mRevocationSetPath;
225221
chip::Optional<char *> mPaaTrustStorePath;
226222
chip::Optional<char *> mCDTrustStorePath;
227223
chip::Optional<bool> mUseMaxSizedCerts;
@@ -230,7 +226,6 @@ class CHIPCommand : public Command
230226
// Cached trust store so commands other than the original startup command
231227
// can spin up commissioners as needed.
232228
static const chip::Credentials::AttestationTrustStore * sTrustStore;
233-
static const chip::Credentials::RevocationSet * sRevocationSet;
234229

235230
static void RunQueuedCommand(intptr_t commandArg);
236231
typedef decltype(RunQueuedCommand) MatterWorkCallback;

examples/chip-tool/commands/common/CredentialIssuerCommands.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ class CredentialIssuerCommands
5959
* @return CHIP_ERROR CHIP_NO_ERROR on success, or corresponding error code.
6060
*/
6161
virtual CHIP_ERROR SetupDeviceAttestation(chip::Controller::SetupParams & setupParams,
62-
const chip::Credentials::AttestationTrustStore * trustStore,
63-
const chip::Credentials::RevocationSet * revocationSet) = 0;
62+
const chip::Credentials::AttestationTrustStore * trustStore) = 0;
6463

6564
/**
6665
* @brief Add a list of additional non-default CD verifying keys (by certificate)

examples/chip-tool/commands/example/ExampleCredentialIssuerCommands.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ class ExampleCredentialIssuerCommands : public CredentialIssuerCommands
3434
return mOpCredsIssuer.Initialize(storage);
3535
}
3636
CHIP_ERROR SetupDeviceAttestation(chip::Controller::SetupParams & setupParams,
37-
const chip::Credentials::AttestationTrustStore * trustStore,
38-
const chip::Credentials::RevocationSet * revocationSet) override
37+
const chip::Credentials::AttestationTrustStore * trustStore) override
3938
{
4039
chip::Credentials::SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider());
4140

42-
mDacVerifier = chip::Credentials::GetDefaultDACVerifier(trustStore, revocationSet);
41+
mDacVerifier = chip::Credentials::GetDefaultDACVerifier(trustStore);
4342
setupParams.deviceAttestationVerifier = mDacVerifier;
4443
mDacVerifier->EnableCdTestKeySupport(mAllowTestCdSigningKey);
4544

scripts/tools/check_includes_config.py

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@
134134

135135
'src/credentials/attestation_verifier/FileAttestationTrustStore.h': {'vector'},
136136
'src/credentials/attestation_verifier/FileAttestationTrustStore.cpp': {'string'},
137-
'src/credentials/attestation_verifier/JSONFileRevocationSet.cpp': {'fstream'},
138137

139138
'src/setup_payload/AdditionalDataPayload.h': {'string'},
140139
'src/setup_payload/AdditionalDataPayloadParser.cpp': {'vector'},

src/controller/AutoCommissioner.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio
388388
case CommissioningStage::kSendAttestationRequest:
389389
return CommissioningStage::kAttestationVerification;
390390
case CommissioningStage::kAttestationVerification:
391+
return CommissioningStage::kAttestationRevocationCheck;
392+
case CommissioningStage::kAttestationRevocationCheck:
391393
return CommissioningStage::kSendOpCertSigningRequest;
392394
case CommissioningStage::kSendOpCertSigningRequest:
393395
return CommissioningStage::kValidateCSR;

src/controller/CHIPDeviceController.cpp

+96-2
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ DeviceCommissioner::DeviceCommissioner() :
392392
mOnDeviceConnectionRetryCallback(OnDeviceConnectionRetryFn, this),
393393
#endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES
394394
mDeviceAttestationInformationVerificationCallback(OnDeviceAttestationInformationVerification, this),
395+
mDACChainRevocationStatusVerificationCallback(OnDACChainRevocationStatusVerification, this),
395396
mDeviceNOCChainCallback(OnDeviceNOCChainGeneration, this), mSetUpCodePairer(this)
396397
{}
397398

@@ -877,7 +878,8 @@ DeviceCommissioner::ContinueCommissioningAfterDeviceAttestation(DeviceProxy * de
877878
return CHIP_ERROR_INCORRECT_STATE;
878879
}
879880

880-
if (mCommissioningStage != CommissioningStage::kAttestationVerification)
881+
if (mCommissioningStage != CommissioningStage::kAttestationVerification &&
882+
mCommissioningStage != CommissioningStage::kAttestationRevocationCheck)
881883
{
882884
ChipLogError(Controller, "Commissioning is not attestation verification phase");
883885
return CHIP_ERROR_INCORRECT_STATE;
@@ -1146,14 +1148,69 @@ void DeviceCommissioner::OnDeviceAttestationInformationVerification(
11461148
}
11471149
}
11481150
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
11491206
{
11501207
if (deviceAttestationDelegate && deviceAttestationDelegate->ShouldWaitAfterDeviceAttestation())
11511208
{
11521209
commissioner->ExtendArmFailSafeForDeviceAttestation(info, result);
11531210
}
11541211
else
11551212
{
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.");
11571214
commissioner->CommissioningStageComplete(CHIP_NO_ERROR);
11581215
}
11591216
}
@@ -1305,6 +1362,18 @@ CHIP_ERROR DeviceCommissioner::ValidateAttestationInfo(const Credentials::Device
13051362
return CHIP_NO_ERROR;
13061363
}
13071364

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+
13081377
CHIP_ERROR DeviceCommissioner::ValidateCSR(DeviceProxy * proxy, const ByteSpan & NOCSRElements,
13091378
const ByteSpan & AttestationSignature, const ByteSpan & dac, const ByteSpan & csrNonce)
13101379
{
@@ -2925,6 +2994,31 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio
29252994
}
29262995
}
29272996
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;
29283022
case CommissioningStage::kSendOpCertSigningRequest: {
29293023
if (!params.GetCSRNonce().HasValue())
29303024
{

src/controller/CHIPDeviceController.h

+13
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,14 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController,
604604
*/
605605
CHIP_ERROR ValidateAttestationInfo(const Credentials::DeviceAttestationVerifier::AttestationInfo & info);
606606

607+
/**
608+
* @brief
609+
* This function validates the revocation status of the DAC Chain sent by the device.
610+
*
611+
* @param[in] info Structure contatining all the required information for validating the device attestation.
612+
*/
613+
CHIP_ERROR ValidateDACChainRevocationStatus(const Credentials::DeviceAttestationVerifier::AttestationInfo & info);
614+
607615
/**
608616
* @brief
609617
* Sends CommissioningStepComplete report to the commissioning delegate. Function will fill in current step.
@@ -884,6 +892,9 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController,
884892
static void OnDeviceAttestationInformationVerification(void * context,
885893
const Credentials::DeviceAttestationVerifier::AttestationInfo & info,
886894
Credentials::AttestationVerificationResult result);
895+
static void OnDACChainRevocationStatusVerification(void * context,
896+
const Credentials::DeviceAttestationVerifier::AttestationInfo & info,
897+
Credentials::AttestationVerificationResult result);
887898

888899
static void OnDeviceNOCChainGeneration(void * context, CHIP_ERROR status, const ByteSpan & noc, const ByteSpan & icac,
889900
const ByteSpan & rcac, Optional<IdentityProtectionKeySpan> ipk,
@@ -1017,6 +1028,8 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController,
10171028

10181029
chip::Callback::Callback<Credentials::DeviceAttestationVerifier::OnAttestationInformationVerification>
10191030
mDeviceAttestationInformationVerificationCallback;
1031+
chip::Callback::Callback<Credentials::DeviceAttestationVerifier::OnAttestationInformationVerification>
1032+
mDACChainRevocationStatusVerificationCallback;
10201033

10211034
chip::Callback::Callback<OnNOCChainGeneration> mDeviceNOCChainCallback;
10221035
SetUpCodePairer mSetUpCodePairer;

src/controller/CommissioningDelegate.h

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum CommissioningStage : uint8_t
4646
kSendDACCertificateRequest, ///< Send DAC CertificateChainRequest (0x3E:2) command to the device
4747
kSendAttestationRequest, ///< Send AttestationRequest (0x3E:0) command to the device
4848
kAttestationVerification, ///< Verify AttestationResponse (0x3E:1) validity
49+
kAttestationRevocationCheck, ///< Verify Revocation Status of device's DAC chain
4950
kSendOpCertSigningRequest, ///< Send CSRRequest (0x3E:4) command to the device
5051
kValidateCSR, ///< Verify CSRResponse (0x3E:5) validity
5152
kGenerateNOCChain, ///< TLV encode Node Operational Credentials (NOC) chain certs

src/controller/python/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ shared_library("ChipDeviceCtrl") {
136136
public_deps += [
137137
"${chip_root}/src/controller/data_model",
138138
"${chip_root}/src/credentials:file_attestation_trust_store",
139-
"${chip_root}/src/credentials:json_file_revocation_set",
140139
"${chip_root}/src/lib/support:testing",
141140
"${chip_root}/src/tracing/json",
142141
"${chip_root}/src/tracing/perfetto",

src/credentials/BUILD.gn

-15
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,3 @@ static_library("file_attestation_trust_store") {
185185
"${nlassert_root}:nlassert",
186186
]
187187
}
188-
189-
static_library("json_file_revocation_set") {
190-
output_name = "libJSONFileRevocationSet"
191-
192-
sources = [
193-
"attestation_verifier/JSONFileRevocationSet.cpp",
194-
"attestation_verifier/JSONFileRevocationSet.h",
195-
]
196-
197-
public_deps = [
198-
":credentials",
199-
"${chip_root}/third_party/jsoncpp",
200-
"${nlassert_root}:nlassert",
201-
]
202-
}

src/credentials/attestation_verifier/DefaultDeviceAttestationVerifier.cpp

+7-40
Original file line numberDiff line numberDiff line change
@@ -458,20 +458,6 @@ void DefaultDACVerifier::VerifyAttestationInformation(const DeviceAttestationVer
458458
VerifyOrExit(attestationError == AttestationVerificationResult::kSuccess, attestationError = attestationError);
459459
}
460460

461-
{
462-
attestationError = IsCertificateRevoked(true, paaVidPid, paaDerBuffer);
463-
VerifyOrExit(attestationError == AttestationVerificationResult::kSuccess,
464-
attestationError = AttestationVerificationResult::kPaaRevoked);
465-
466-
attestationError = IsCertificateRevoked(false, paiVidPid, info.paiDerBuffer);
467-
VerifyOrExit(attestationError == AttestationVerificationResult::kSuccess,
468-
attestationError = AttestationVerificationResult::kPaiRevoked);
469-
470-
attestationError = IsCertificateRevoked(false, dacVidPid, info.dacDerBuffer);
471-
VerifyOrExit(attestationError == AttestationVerificationResult::kSuccess,
472-
attestationError = AttestationVerificationResult::kDacRevoked);
473-
}
474-
475461
exit:
476462
onCompletion->mCall(onCompletion->mContext, info, attestationError);
477463
}
@@ -621,33 +607,14 @@ CHIP_ERROR DefaultDACVerifier::VerifyNodeOperationalCSRInformation(const ByteSpa
621607
return CHIP_NO_ERROR;
622608
}
623609

624-
AttestationVerificationResult DefaultDACVerifier::IsCertificateRevoked(bool isPaa, Crypto::AttestationCertVidPid vidPidUnderTest,
625-
ByteSpan certificate)
610+
void DefaultDACVerifier::ValidateDACChainRevocationStatus(const AttestationInfo & info,
611+
Callback::Callback<OnAttestationInformationVerification> * onCompletion)
626612
{
627-
uint8_t issuerBuf[kMaxCertificateDistinguishedNameLength] = { 0 };
628-
MutableByteSpan issuer(issuerBuf);
629-
uint8_t akidBuf[kAuthorityKeyIdentifierLength];
630-
MutableByteSpan akid(akidBuf);
631-
uint8_t serialNumberBuf[kMaxCertificateSerialNumberLength];
632-
MutableByteSpan serialNumber(serialNumberBuf);
633-
634-
VerifyOrReturnError(ExtractIssuerFromX509Cert(certificate, issuer) == CHIP_NO_ERROR,
635-
AttestationVerificationResult::kPaaFormatInvalid);
636-
VerifyOrReturnError(ExtractAKIDFromX509Cert(certificate, akid) == CHIP_NO_ERROR,
637-
AttestationVerificationResult::kPaaFormatInvalid);
638-
VerifyOrReturnError(ExtractSerialNumberFromX509Cert(certificate, serialNumber) == CHIP_NO_ERROR,
639-
AttestationVerificationResult::kPaaFormatInvalid);
640-
641-
return IsCertificateRevoked(isPaa, vidPidUnderTest, issuer, akid, serialNumber);
642-
}
613+
AttestationVerificationResult attestationError = AttestationVerificationResult::kSuccess;
643614

644-
AttestationVerificationResult DefaultDACVerifier::IsCertificateRevoked(bool isPaa, AttestationCertVidPid vidPidUnderTest,
645-
ByteSpan issuer, ByteSpan authorityKeyId,
646-
ByteSpan serialNumber)
647-
{
648-
VerifyOrReturnError(mRevocationSet != nullptr, AttestationVerificationResult::kSuccess);
615+
// TODO
649616

650-
return mRevocationSet->IsCertificateRevoked(isPaa, vidPidUnderTest, issuer, authorityKeyId, serialNumber);
617+
onCompletion->mCall(onCompletion->mContext, info, attestationError);
651618
}
652619

653620
bool CsaCdKeysTrustStore::IsCdTestKey(const ByteSpan & kid) const
@@ -726,9 +693,9 @@ const AttestationTrustStore * GetTestAttestationTrustStore()
726693
return &gTestAttestationTrustStore.get();
727694
}
728695

729-
DeviceAttestationVerifier * GetDefaultDACVerifier(const AttestationTrustStore * paaRootStore, const RevocationSet * revocationSet)
696+
DeviceAttestationVerifier * GetDefaultDACVerifier(const AttestationTrustStore * paaRootStore)
730697
{
731-
static DefaultDACVerifier defaultDACVerifier{ paaRootStore, revocationSet };
698+
static DefaultDACVerifier defaultDACVerifier{ paaRootStore };
732699

733700
return &defaultDACVerifier;
734701
}

0 commit comments

Comments
 (0)