Skip to content

Commit 4691473

Browse files
caipiblackrestyled-commitsbzbarsky-apple
authored andcommitted
[chip-tool] Add a parameter on pairing commands to bypass attestation verifier (#24155)
* Add the parameter 'bypass-attestation-verifier' in chip-tool pairing commands. * Restyled by whitespace * Restyled by clang-format * Update examples/chip-tool/commands/pairing/PairingCommand.h Co-authored-by: Boris Zbarsky <[email protected]> * Update examples/chip-tool/commands/pairing/PairingCommand.h Co-authored-by: Boris Zbarsky <[email protected]> Co-authored-by: Restyled.io <[email protected]> Co-authored-by: Boris Zbarsky <[email protected]>
1 parent 88484d4 commit 4691473

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

examples/chip-tool/commands/pairing/PairingCommand.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
7272
{
7373
auto params = CommissioningParameters();
7474
params.SetSkipCommissioningComplete(mSkipCommissioningComplete.ValueOr(false));
75+
if (mBypassAttestationVerifier.ValueOr(false))
76+
{
77+
params.SetDeviceAttestationDelegate(this);
78+
}
7579

7680
switch (mNetworkType)
7781
{
@@ -281,3 +285,19 @@ void PairingCommand::OnCurrentFabricRemove(void * context, NodeId nodeId, CHIP_E
281285

282286
command->SetCommandExitStatus(err);
283287
}
288+
289+
chip::Optional<uint16_t> PairingCommand::FailSafeExpiryTimeoutSecs() const
290+
{
291+
// We don't need to set additional failsafe timeout as we don't ask the final user if he wants to continue
292+
return chip::Optional<uint16_t>();
293+
}
294+
295+
void PairingCommand::OnDeviceAttestationCompleted(chip::Controller::DeviceCommissioner * deviceCommissioner,
296+
chip::DeviceProxy * device,
297+
const chip::Credentials::DeviceAttestationVerifier::AttestationDeviceInfo & info,
298+
chip::Credentials::AttestationVerificationResult attestationResult)
299+
{
300+
// Bypass attestation verification, continue with success
301+
deviceCommissioner->ContinueCommissioningAfterDeviceAttestation(device,
302+
chip::Credentials::AttestationVerificationResult::kSuccess);
303+
}

examples/chip-tool/commands/pairing/PairingCommand.h

+12-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ enum class PairingNetworkType
4848

4949
class PairingCommand : public CHIPCommand,
5050
public chip::Controller::DevicePairingDelegate,
51-
public chip::Controller::DeviceDiscoveryDelegate
51+
public chip::Controller::DeviceDiscoveryDelegate,
52+
public chip::Credentials::DeviceAttestationDelegate
5253
{
5354
public:
5455
PairingCommand(const char * commandName, PairingMode mode, PairingNetworkType networkType,
@@ -60,6 +61,9 @@ class PairingCommand : public CHIPCommand,
6061
mCurrentFabricRemoveCallback(OnCurrentFabricRemove, this)
6162
{
6263
AddArgument("node-id", 0, UINT64_MAX, &mNodeId);
64+
AddArgument("bypass-attestation-verifier", 0, 1, &mBypassAttestationVerifier,
65+
"Bypass the attestation verifier. If not provided or false, the attestation verifier is not bypassed."
66+
" If true, the commissioning will continue in case of attestation verification failure.");
6367

6468
switch (networkType)
6569
{
@@ -158,6 +162,12 @@ class PairingCommand : public CHIPCommand,
158162
void OnDiscoveredDevice(const chip::Dnssd::DiscoveredNodeData & nodeData) override;
159163
bool IsDiscoverOnce() { return mDiscoverOnce.ValueOr(false); }
160164

165+
/////////// DeviceAttestationDelegate /////////
166+
chip::Optional<uint16_t> FailSafeExpiryTimeoutSecs() const override;
167+
void OnDeviceAttestationCompleted(chip::Controller::DeviceCommissioner * deviceCommissioner, chip::DeviceProxy * device,
168+
const chip::Credentials::DeviceAttestationVerifier::AttestationDeviceInfo & info,
169+
chip::Credentials::AttestationVerificationResult attestationResult) override;
170+
161171
private:
162172
CHIP_ERROR RunInternal(NodeId remoteId);
163173
CHIP_ERROR Pair(NodeId remoteId, PeerAddress address);
@@ -177,6 +187,7 @@ class PairingCommand : public CHIPCommand,
177187
chip::Optional<bool> mUseOnlyOnNetworkDiscovery;
178188
chip::Optional<bool> mPaseOnly;
179189
chip::Optional<bool> mSkipCommissioningComplete;
190+
chip::Optional<bool> mBypassAttestationVerifier;
180191
uint16_t mRemotePort;
181192
uint16_t mDiscriminator;
182193
uint32_t mSetupPINCode;

0 commit comments

Comments
 (0)