Skip to content

Commit

Permalink
Remove needless OpcredsIssuer dependency
Browse files Browse the repository at this point in the history
- Dependency on ExampleOperationalCredentialsIssuer was in
  many files where not needed, making other refactors more
  difficult.

Remove this dependency and make CHIPCommand own its ephemeral
operational credentials issuer.
  • Loading branch information
tcarmelveilleux committed Nov 29, 2021
1 parent 7d55d2e commit cf81575
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 12 deletions.
1 change: 0 additions & 1 deletion examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "../../config/PersistentStorage.h"
#include "../common/CHIPCommand.h"
#include <app/chip-zcl-zpro-codec.h>
#include <controller/ExampleOperationalCredentialsIssuer.h>
#include <lib/core/CHIPEncoding.h>

class ModelCommand : public CHIPCommand
Expand Down
9 changes: 6 additions & 3 deletions examples/chip-tool/commands/common/CHIPCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "CHIPCommand.h"

#include <controller/CHIPDeviceControllerFactory.h>
#include "controller/ExampleOperationalCredentialsIssuer.h"
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/DeviceAttestationVerifier.h>
#include <credentials/examples/DefaultDeviceAttestationVerifier.h>
Expand All @@ -31,13 +32,15 @@ using DeviceControllerFactory = chip::Controller::DeviceControllerFactory;

CHIP_ERROR CHIPCommand::Run()
{
chip::Controller::ExampleOperationalCredentialsIssuer opCredsIssuer;

#if CHIP_DEVICE_LAYER_TARGET_LINUX && CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
// By default, Linux device is configured as a BLE peripheral while the controller needs a BLE central.
ReturnLogErrorOnFailure(chip::DeviceLayer::Internal::BLEMgrImpl().ConfigureBle(0, true));
#endif

ReturnLogErrorOnFailure(mStorage.Init());
ReturnLogErrorOnFailure(mOpCredsIssuer.Initialize(mStorage));
ReturnLogErrorOnFailure(opCredsIssuer.Initialize(mStorage));
ReturnLogErrorOnFailure(mFabricStorage.Initialize(&mStorage));

chip::Platform::ScopedMemoryBuffer<uint8_t> noc;
Expand All @@ -64,7 +67,7 @@ CHIP_ERROR CHIPCommand::Run()
// TODO - OpCreds should only be generated for pairing command
// store the credentials in persistent storage, and
// generate when not available in the storage.
ReturnLogErrorOnFailure(mOpCredsIssuer.GenerateNOCChainAfterValidation(mStorage.GetLocalNodeId(), mStorage.GetFabricId(),
ReturnLogErrorOnFailure(opCredsIssuer.GenerateNOCChainAfterValidation(mStorage.GetLocalNodeId(), mStorage.GetFabricId(),
ephemeralKey.Pubkey(), rcacSpan, icacSpan, nocSpan));

chip::Controller::FactoryInitParams factoryInitParams;
Expand All @@ -73,7 +76,7 @@ CHIP_ERROR CHIPCommand::Run()

chip::Controller::SetupParams commissionerParams;
commissionerParams.storageDelegate = &mStorage;
commissionerParams.operationalCredentialsDelegate = &mOpCredsIssuer;
commissionerParams.operationalCredentialsDelegate = &opCredsIssuer;
commissionerParams.ephemeralKeypair = &ephemeralKey;
commissionerParams.controllerRCAC = rcacSpan;
commissionerParams.controllerICAC = icacSpan;
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/commands/common/CHIPCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class CHIPCommand : public Command
static void RunQueuedCommand(intptr_t commandArg);

CHIP_ERROR mCommandExitStatus = CHIP_ERROR_INTERNAL;
chip::Controller::ExampleOperationalCredentialsIssuer mOpCredsIssuer;

CHIP_ERROR StartWaiting(chip::System::Clock::Timeout seconds);
void StopWaiting();
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/commands/common/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#pragma once

#include "controller/ExampleOperationalCredentialsIssuer.h"
#include <app/data-model/Nullable.h>
#include <controller/CHIPDeviceController.h>
#include <inet/InetInterface.h>
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/commands/common/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "../../config/PersistentStorage.h"
#include "Command.h"
#include <controller/ExampleOperationalCredentialsIssuer.h>
#include <map>

class Commands
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/commands/discover/DiscoverCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "../../config/PersistentStorage.h"
#include "../common/CHIPCommand.h"
#include <controller/ExampleOperationalCredentialsIssuer.h>

class DiscoverCommand : public CHIPCommand, public chip::Controller::DeviceAddressUpdateDelegate
{
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/commands/pairing/PairingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <zap-generated/CHIPClientCallbacks.h>
#include <zap-generated/CHIPClusters.h>

#include <controller/ExampleOperationalCredentialsIssuer.h>
#include <lib/support/Span.h>
#include <lib/support/ThreadOperationalDataset.h>
#include <setup_payload/SetupPayload.h>
Expand Down
2 changes: 0 additions & 2 deletions examples/chip-tool/commands/reporting/ReportingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include "../../config/PersistentStorage.h"
#include "../common/CHIPCommand.h"

#include <controller/ExampleOperationalCredentialsIssuer.h>

class ReportingCommand : public CHIPCommand
{
public:
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/commands/tests/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <app/data-model/DecodableList.h>
#include <app/tests/suites/pics/PICSBooleanExpressionParser.h>
#include <app/tests/suites/pics/PICSBooleanReader.h>
#include <controller/ExampleOperationalCredentialsIssuer.h>
#include <lib/support/BitFlags.h>
#include <lib/support/TypeTraits.h>
#include <lib/support/UnitTestUtils.h>
Expand Down

0 comments on commit cf81575

Please sign in to comment.