[all-devices-app] Add support for "--dac_provider" (#73129)
* [all-devices-app] Support --dac_provider in all-devices-app POSIX simulator
- Add AllDevicesExampleDACProvider in all-devices-common/providers to support dynamic DAC JSON vector injection.
- Add --dac_provider CLI argument parsing in posix/app_options.
- Update documentation in custom_product_baseline.md and starting_up.md.
- Add unit tests for dac_provider option parsing in TestDeviceTypeParser.
Change-Id: I5677ac47586326d975362170de85248064a4cdd8
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [all-devices-app] Format hardware chip names as inline code in docs
Change-Id: I6ec791072ae544a76d75b9fdf9abb4ac726cc15f
* [all-devices-app] Verify DAC JSON file path before initialization
Change-Id: I6db43b32174041e812bc6375c90d31814ae7410b
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [all-devices-app] Format BUILD.gn with gn format
Change-Id: Ibf6e1aa492d3871a845ba8a5d9a80e51760f4efe
* [all-devices-app] Document PIMPL idiom in AllDevicesExampleDACProvider
Change-Id: I9a7762917e5409b5622baadcad76078c6b8ae800
* [all-devices-app] Fix clang-tidy optional access in tests and unused-variable warning in LoggingSpeaker
Change-Id: I323cac2226fa7c41c661a4ec9bd78771043718b0
* [all-devices-app] Guard CHIP_CONFIG_KVS_PATH in AppOptions help string
Change-Id: I1b320c27f6d3f4a2bd8fb031886b7afd3303b6cc
* [all-devices-app] Address review feedback on DAC provider
- Document DAC JSON schema and pointer to pre-existing test vectors in README.md.
- Replace local absolute file URLs with relative markdown links.
- Add explanatory comment on AllDevicesExampleDACProvider PIMPL constructor/destructor.
Change-Id: I0f2246d6bb45102b3bdfdb23bb2b551691ac2b13
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [all-devices-app] Simplify AllDevicesExampleDACProvider by using base class pointer
- Use std::unique_ptr<Credentials::DeviceAttestationCredentialsProvider> to store dynamic instance.
- Define default constructor and destructor inline in the header without leaking test suite headers.
- Eliminate FileProviderContext wrapper struct.
Change-Id: Ic13940e2100027d124510048f8bf283057ff2935
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [all-devices-app] Fix spelling of P-256 in README.md
Change-Id: Id2ff06c7770a0fe89f52519f4c84f9e18116f00b
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update examples/all-devices-app/docs/custom_product_baseline.md
Co-authored-by: C Freeman <cecille@google.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update all-devices-app DAC documentation to use valid test credentials
Updated the documentation in examples/all-devices-app/all-devices-common/providers/README.md
to point to the new valid test credentials in credentials/development/attestation/
instead of the old ones in commissioner_dut/ which were a mix of working and
non-working vectors.
### Testing
- Verified all-devices-app builds successfully with the linux-x64-all-devices-boringssl target.
- Verified that all-devices-app starts successfully and loads the new TestCredentials-FFF1-8000.json vector.
- Verified that all-devices-app fails to start when an invalid/missing file is provided.
TAG=agy
CONV=9f92e77c-e0fe-4f5d-a70a-62164207fcab
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: C Freeman <cecille@google.com>
diff --git a/examples/all-devices-app/all-devices-common/device/types/speaker/impl/LoggingSpeaker.cpp b/examples/all-devices-app/all-devices-common/device/types/speaker/impl/LoggingSpeaker.cpp
index f099914..7edae1a 100644
--- a/examples/all-devices-app/all-devices-common/device/types/speaker/impl/LoggingSpeaker.cpp
+++ b/examples/all-devices-app/all-devices-common/device/types/speaker/impl/LoggingSpeaker.cpp
@@ -31,9 +31,9 @@
void LoggingSpeaker::OnLevelChanged(uint8_t value)
{
- uint8_t min = LevelControlCluster().GetMinLevel();
- uint8_t max = LevelControlCluster().GetMaxLevel();
- uint32_t pct = (max > min) ? (static_cast<uint32_t>(value - min) * 100) / (max - min) : 0;
+ uint8_t min = LevelControlCluster().GetMinLevel();
+ uint8_t max = LevelControlCluster().GetMaxLevel();
+ [[maybe_unused]] uint32_t pct = (max > min) ? (static_cast<uint32_t>(value - min) * 100) / (max - min) : 0;
ChipLogProgress(AppServer, "LoggingSpeaker: Volume set to %u (%" PRIu32 "%%)", value, pct);
}
diff --git a/examples/all-devices-app/all-devices-common/providers/AllDevicesExampleDACProvider.cpp b/examples/all-devices-app/all-devices-common/providers/AllDevicesExampleDACProvider.cpp
new file mode 100644
index 0000000..eee4ac0
--- /dev/null
+++ b/examples/all-devices-app/all-devices-common/providers/AllDevicesExampleDACProvider.cpp
@@ -0,0 +1,82 @@
+/*
+ *
+ * Copyright (c) 2026 Project CHIP Authors
+ * All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "AllDevicesExampleDACProvider.h"
+
+#include <app/tests/suites/credentials/TestHarnessDACProvider.h>
+#include <credentials/examples/DeviceAttestationCredsExample.h>
+#include <lib/support/CodeUtils.h>
+
+#include <fstream>
+
+namespace chip {
+namespace DeviceLayer {
+
+CHIP_ERROR AllDevicesExampleDACProvider::Init(const std::optional<std::string> & filePath)
+{
+ if (filePath.has_value() && !filePath.value().empty())
+ {
+ std::ifstream jsonFile(filePath.value().c_str(), std::ifstream::binary);
+ VerifyOrReturnError(jsonFile.is_open(), CHIP_ERROR_INVALID_ARGUMENT);
+
+ auto fileProvider = std::make_unique<Credentials::Examples::TestHarnessDACProvider>();
+ fileProvider->Init(filePath.value().c_str());
+ mDynamicProvider = std::move(fileProvider);
+ mDelegate = mDynamicProvider.get();
+ }
+ else
+ {
+ mDynamicProvider.reset();
+ mDelegate = Credentials::Examples::GetExampleDACProvider();
+ }
+ return CHIP_NO_ERROR;
+}
+
+CHIP_ERROR AllDevicesExampleDACProvider::GetCertificationDeclaration(MutableByteSpan & out_cd_buffer)
+{
+ VerifyOrReturnError(mDelegate != nullptr, CHIP_ERROR_INCORRECT_STATE);
+ return mDelegate->GetCertificationDeclaration(out_cd_buffer);
+}
+
+CHIP_ERROR AllDevicesExampleDACProvider::GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer)
+{
+ VerifyOrReturnError(mDelegate != nullptr, CHIP_ERROR_INCORRECT_STATE);
+ return mDelegate->GetFirmwareInformation(out_firmware_info_buffer);
+}
+
+CHIP_ERROR AllDevicesExampleDACProvider::GetDeviceAttestationCert(MutableByteSpan & out_dac_buffer)
+{
+ VerifyOrReturnError(mDelegate != nullptr, CHIP_ERROR_INCORRECT_STATE);
+ return mDelegate->GetDeviceAttestationCert(out_dac_buffer);
+}
+
+CHIP_ERROR AllDevicesExampleDACProvider::GetProductAttestationIntermediateCert(MutableByteSpan & out_pai_buffer)
+{
+ VerifyOrReturnError(mDelegate != nullptr, CHIP_ERROR_INCORRECT_STATE);
+ return mDelegate->GetProductAttestationIntermediateCert(out_pai_buffer);
+}
+
+CHIP_ERROR AllDevicesExampleDACProvider::SignWithDeviceAttestationKey(const ByteSpan & message_to_sign,
+ MutableByteSpan & out_signature_buffer)
+{
+ VerifyOrReturnError(mDelegate != nullptr, CHIP_ERROR_INCORRECT_STATE);
+ return mDelegate->SignWithDeviceAttestationKey(message_to_sign, out_signature_buffer);
+}
+
+} // namespace DeviceLayer
+} // namespace chip
diff --git a/examples/all-devices-app/all-devices-common/providers/AllDevicesExampleDACProvider.h b/examples/all-devices-app/all-devices-common/providers/AllDevicesExampleDACProvider.h
new file mode 100644
index 0000000..b3e348a
--- /dev/null
+++ b/examples/all-devices-app/all-devices-common/providers/AllDevicesExampleDACProvider.h
@@ -0,0 +1,66 @@
+/*
+ *
+ * Copyright (c) 2026 Project CHIP Authors
+ * All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <credentials/DeviceAttestationCredsProvider.h>
+#include <lib/core/CHIPError.h>
+#include <memory>
+#include <optional>
+#include <string>
+
+namespace chip {
+namespace DeviceLayer {
+
+/**
+ * @brief DeviceAttestationCredentialsProvider implementation for all-devices-app.
+ *
+ * In simulation / test harness environments (such as POSIX CLI executions), this provider can load
+ * test DAC credentials dynamically from a JSON file path. If no path is provided, it falls back to
+ * the default example credentials.
+ *
+ * For commercial products, developers should replace this with a provider that binds directly to
+ * secure hardware storage (e.g. Hardware Secure Element, TPM, TrustZone, or platform factory partition).
+ */
+class AllDevicesExampleDACProvider : public Credentials::DeviceAttestationCredentialsProvider
+{
+public:
+ AllDevicesExampleDACProvider() = default;
+ ~AllDevicesExampleDACProvider() override = default;
+
+ /**
+ * @brief Initializes the DAC credentials provider.
+ *
+ * @param[in] filePath Optional file path to a JSON DAC test vector. If not provided or empty,
+ * the default SDK example DAC provider is used.
+ */
+ CHIP_ERROR Init(const std::optional<std::string> & filePath = std::nullopt);
+
+ CHIP_ERROR GetCertificationDeclaration(MutableByteSpan & out_cd_buffer) override;
+ CHIP_ERROR GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) override;
+ CHIP_ERROR GetDeviceAttestationCert(MutableByteSpan & out_dac_buffer) override;
+ CHIP_ERROR GetProductAttestationIntermediateCert(MutableByteSpan & out_pai_buffer) override;
+ CHIP_ERROR SignWithDeviceAttestationKey(const ByteSpan & message_to_sign, MutableByteSpan & out_signature_buffer) override;
+
+private:
+ Credentials::DeviceAttestationCredentialsProvider * mDelegate = nullptr;
+ std::unique_ptr<Credentials::DeviceAttestationCredentialsProvider> mDynamicProvider;
+};
+
+} // namespace DeviceLayer
+} // namespace chip
diff --git a/examples/all-devices-app/all-devices-common/providers/BUILD.gn b/examples/all-devices-app/all-devices-common/providers/BUILD.gn
index 9e895e4..2cff81a 100644
--- a/examples/all-devices-app/all-devices-common/providers/BUILD.gn
+++ b/examples/all-devices-app/all-devices-common/providers/BUILD.gn
@@ -53,3 +53,22 @@
"${chip_root}/src:includes",
]
}
+
+source_set("all-devices-example-dac-provider") {
+ sources = [
+ "AllDevicesExampleDACProvider.cpp",
+ "AllDevicesExampleDACProvider.h",
+ ]
+
+ public_deps = [
+ "${chip_root}/src/credentials",
+ "${chip_root}/src/lib/support",
+ ]
+
+ deps = [ "${chip_root}/src/app/tests/suites/credentials:dac_provider" ]
+
+ public_configs = [
+ ":includes",
+ "${chip_root}/src:includes",
+ ]
+}
diff --git a/examples/all-devices-app/all-devices-common/providers/README.md b/examples/all-devices-app/all-devices-common/providers/README.md
new file mode 100644
index 0000000..6593707
--- /dev/null
+++ b/examples/all-devices-app/all-devices-common/providers/README.md
@@ -0,0 +1,92 @@
+# All-Devices Providers
+
+This directory contains `all-devices-app` providers that implement or wrap core
+Matter SDK provider interfaces.
+
+They provide clean separation between the application data model, POSIX test
+simulator overrides (such as dynamic CLI options), and platform hardware
+delegates.
+
+---
+
+## Provider Overview
+
+| Provider Class | Base SDK Interface | Description |
+| :----------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| [`AllDevicesExampleDACProvider`](AllDevicesExampleDACProvider.h) | [`chip::Credentials::DeviceAttestationCredentialsProvider`](../../../../src/credentials/DeviceAttestationCredsProvider.h) | Handles Device Attestation Credentials (DAC, PAI, CD, and DAC private key signing). In POSIX test/simulation environments, supports loading test credentials from a JSON vector file (`--dac_provider <path>`), falling back to default SDK example credentials. |
+| [`AllDevicesExampleDeviceInfoProviderImpl`](AllDevicesExampleDeviceInfoProviderImpl.h) | [`chip::DeviceLayer::DeviceInfoProvider`](../../../../src/platform/DeviceInfoProvider.h) | Provides fixed labels, user labels, supported locales, and calendar types across dynamic endpoints in `all-devices-app`. |
+| [`AllDevicesExampleDeviceInstanceInfoProviderImpl`](AllDevicesExampleDeviceInstanceInfoProviderImpl.h) | [`chip::DeviceLayer::DeviceInstanceInfoProvider`](../../../../src/platform/DeviceInstanceInfoProvider.h) | Wraps the underlying platform `DeviceInstanceInfoProvider` delegate and overrides Vendor ID and Product ID when custom `--vendor-id` and `--product-id` CLI options are passed. |
+
+---
+
+## DAC Test Vector JSON Schema
+
+When supplying a custom test vector file via `--dac_provider <path>`, the JSON
+file is parsed by `TestHarnessDACProvider`
+(`src/app/tests/suites/credentials/TestHarnessDACProvider.cpp`).
+
+The supported JSON keys are:
+
+| JSON Key | Type | Description |
+| :-------------------------- | :---------------------- | :------------------------------------------------------------------------------------ |
+| `dac_cert` | Hex String | DER-encoded Device Attestation Certificate (DAC). |
+| `dac_private_key` | Hex String | 32-byte P-256 ECDSA private key scalar used to sign the device attestation challenge. |
+| `dac_public_key` | Hex String _(Optional)_ | 65-byte uncompressed P-256 public key corresponding to `dac_private_key`. |
+| `pai_cert` | Hex String | DER-encoded Product Attestation Intermediate (PAI) certificate. |
+| `certification_declaration` | Hex String | CMS-signed DER-encoded Certification Declaration (CD) payload. |
+| `firmware_information` | Hex String _(Optional)_ | Optional firmware information payload. |
+| `basic_info_pid` | Integer _(Optional)_ | Expected Product ID matching the test vector. |
+| `description` | String _(Optional)_ | Human-readable description of the test scenario. |
+| `is_success_case` | Boolean _(Optional)_ | Indicates whether the test vector is expected to pass or fail attestation. |
+
+### Pre-Existing Test Vectors
+
+Pre-existing test vector JSON files are available in the Matter SDK repository
+under:
+[`credentials/development/attestation/`](../../../../credentials/development/attestation/)
+
+Examples:
+
+- **Test Credentials for VID=0xFFF1 PID=0x8000**:
+ `credentials/development/attestation/TestCredentials-FFF1-8000.json`
+- **Test Credentials for VID=0xFFF2 PID=0x8001**:
+ `credentials/development/attestation/TestCredentials-FFF2-8001.json`
+
+Example invocation:
+
+```bash
+./out/linux-x64-all-devices-clang/all-devices-app \
+ --dac_provider credentials/development/attestation/TestCredentials-FFF1-8000.json \
+ --vendor-id 0xFFF1 \
+ --product-id 0x8000
+```
+
+---
+
+## Production vs. Simulation Usage
+
+### 1. Device Attestation Credentials (DAC)
+
+In real commercial products, DAC private keys must never be stored in plaintext
+JSON files or memory accessible to user space.
+
+- **Simulation / Test Harnesses (POSIX)**: The POSIX entrypoint
+ ([`posix/main.cpp`](../../posix/main.cpp)) initializes
+ `AllDevicesExampleDACProvider` with `AppOptions::GetConfig().dacProvider` to
+ allow test runners (such as WOCA and Python certification scripts) to supply
+ test vectors dynamically.
+- **Embedded MCUs (ESP32, Silicon Labs, Nordic)**: Hardware platforms
+ initialize a `FactoryDataProvider` (which reads from secure flash or NVM)
+ and register it at boot.
+- **Commercial Linux Gateways**: Real products replace
+ `AllDevicesExampleDACProvider` with a provider that delegates signing
+ directly to a Hardware Secure Element (e.g., `ATECC608`, NXP `SE050`), TPM,
+ or platform Secure Enclave / TrustZone
+ ([`TrustyDACProvider`](../../../../src/platform/Linux/DeviceAttestationCredsTrusty.h)).
+
+### 2. Device Instance Info
+
+`AllDevicesExampleDeviceInstanceInfoProviderImpl` demonstrates the decorator
+pattern: it intercepts basic info queries to allow CLI customization during
+development while forwarding hardware-level queries (such as rotating device ID,
+serial numbers, and manufacturing dates) to the underlying platform delegate.
diff --git a/examples/all-devices-app/docs/custom_product_baseline.md b/examples/all-devices-app/docs/custom_product_baseline.md
index 9ebf690..f0c3134 100644
--- a/examples/all-devices-app/docs/custom_product_baseline.md
+++ b/examples/all-devices-app/docs/custom_product_baseline.md
@@ -164,7 +164,65 @@
---
-## 5. Commercial Firmware Guidelines
+## 5. Device Attestation Credentials (DAC) Implementation & Production
+
+In the Matter data model, Device Attestation Credentials (DAC) provide
+cryptographic proof of a device's identity, vendor ID, product ID, and Matter
+certification.
+
+### DAC Implementation in `all-devices-app`
+
+The `all-devices-app` implementation provides a decoupled provider architecture:
+
+- **Reference Provider**:
+ [`AllDevicesExampleDACProvider`](../all-devices-common/providers/AllDevicesExampleDACProvider.h)
+ located in
+ [`all-devices-common/providers/`](../all-devices-common/providers/).
+- **POSIX Simulator Boot**: In [`posix/main.cpp`](../posix/main.cpp), the
+ application initializes `AllDevicesExampleDACProvider` with
+ `AppOptions::GetConfig().dacProvider`. This allows passing
+ `--dac_provider <path.json>` on the command line to dynamically load JSON
+ test vectors during testing, or falling back to the SDK's built-in example
+ credentials (`chip::Credentials::Examples::GetExampleDACProvider()`).
+- **Embedded MCU Boot**: On hardware targets like ESP32
+ ([`esp32/main/main.cpp`](../esp32/main/main.cpp)) or Silicon Labs
+ ([`silabs/src/AppTask.cpp`](../silabs/src/AppTask.cpp)), the platform boots
+ with a hardware `FactoryDataProvider` that reads credentials from encrypted
+ flash partitions.
+
+### Transitioning to Production Hardware
+
+Commercial products **must never use JSON files or plaintext DAC private keys on
+disk**. In real products:
+
+1. **Implement `DeviceAttestationCredentialsProvider`**: Implement the pure
+ abstract interface
+ [`chip::Credentials::DeviceAttestationCredentialsProvider`](../../../src/credentials/DeviceAttestationCredsProvider.h).
+ Cryptographic signing operations (`SignWithDeviceAttestationKey`) must
+ delegate directly to your secure hardware without exporting the private key
+ into system RAM.
+2. **Platform Hardware Binding**:
+ - **Linux / Android Gateways**: Delegate signing to a Hardware Secure
+ Element (e.g. `ATECC608`, NXP `SE050` via I2C/PKCS#11), TPM, or platform
+ Secure Enclave / TrustZone (see
+ [`TrustyDACProvider`](../../../src/platform/Linux/DeviceAttestationCredsTrusty.h)).
+ - **Embedded MCUs (ESP32, Nordic, Silicon Labs)**: Use the platform's
+ hardware factory data provider (e.g.,
+ [`ESP32FactoryDataProvider`](../../../src/platform/ESP32/ESP32FactoryDataProvider.h))
+ to read factory-flashed credentials and utilize on-chip crypto hardware.
+3. **Register at Boot**: Register your hardware provider before initializing the
+ Matter server or starting the event loop:
+
+ ```cpp
+ #include <credentials/DeviceAttestationCredsProvider.h>
+
+ // Initialize your hardware/platform secure element DAC provider
+ SetDeviceAttestationCredentialsProvider(&gProductHardwareDACProvider);
+ ```
+
+---
+
+## 6. Commercial Firmware Guidelines
1. **Link Specific Devices**: In `BUILD.gn` or `CMakeLists.txt`, link directly
against required device modules (e.g.,
@@ -175,3 +233,6 @@
3. **Persist Hardware State**: Replace simulated cluster implementations with
hardware drivers (e.g., binding a PWM driver to WriteAttribute callbacks) and
persist calibration data via storage delegates.
+4. **Hardware-Isolated Attestation**: Bind
+ `DeviceAttestationCredentialsProvider` directly to your secure element or
+ factory partition driver rather than using CLI/file-based credentials.
diff --git a/examples/all-devices-app/docs/starting_up.md b/examples/all-devices-app/docs/starting_up.md
index 695b5f2..d6cf9b2 100644
--- a/examples/all-devices-app/docs/starting_up.md
+++ b/examples/all-devices-app/docs/starting_up.md
@@ -57,7 +57,8 @@
> [!TIP] This application inherits the Matter SDK's complete baseline option
> parser. For the complete, live list of available network commissioning
> (`--wifi`, `--ble-controller`), operational binding (`--port`,
-> `--interface-id`), descriptor (`--discriminator`, `--vendor-id`), and
+> `--interface-id`), descriptor (`--discriminator`, `--vendor-id`,
+> `--product-id`), device attestation credentials (`--dac_provider`), and
> persistent storage (`--KVS`) arguments, execute the binary with `--help`:
>
> ```bash
diff --git a/examples/all-devices-app/posix/BUILD.gn b/examples/all-devices-app/posix/BUILD.gn
index c0de987..28c36fa 100644
--- a/examples/all-devices-app/posix/BUILD.gn
+++ b/examples/all-devices-app/posix/BUILD.gn
@@ -76,6 +76,7 @@
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/speaker",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/water-valve",
"${chip_root}/examples/all-devices-app/all-devices-common/oob-accessors:oob-accessors",
+ "${chip_root}/examples/all-devices-app/all-devices-common/providers:all-devices-example-dac-provider",
"${chip_root}/examples/all-devices-app/all-devices-common/providers:all-devices-example-device-info-provider",
"${chip_root}/examples/all-devices-app/all-devices-common/providers:all-devices-example-device-instance-info-provider",
"${chip_root}/examples/all-devices-app/posix/app_options:app-options",
diff --git a/examples/all-devices-app/posix/app_options/AppOptions.cpp b/examples/all-devices-app/posix/app_options/AppOptions.cpp
index 5bdf4d6..56e9feb 100644
--- a/examples/all-devices-app/posix/app_options/AppOptions.cpp
+++ b/examples/all-devices-app/posix/app_options/AppOptions.cpp
@@ -57,6 +57,7 @@
constexpr uint16_t kOptionGroupcast = 0xffda;
constexpr uint16_t kOptionAppPipe = 0xffdb;
constexpr uint16_t kOptionTraceTo = 0xffdc;
+constexpr uint16_t kOptionDacProvider = 0xffdd;
DeviceTypeParser AppOptions::sParser;
AppOptions::AppConfig AppOptions::mConfig;
@@ -172,6 +173,10 @@
mConfig.traceTo.push_back(value);
ChipLogProgress(AppServer, "Added trace destination: %s", value);
return true;
+ case kOptionDacProvider:
+ mConfig.dacProvider = value;
+ ChipLogProgress(AppServer, "DAC provider file set to %s", value);
+ return true;
default:
ChipLogError(Support, "%s: INTERNAL ERROR: Unhandled option: %s\n", program, name);
return false;
@@ -199,6 +204,7 @@
{ "groupcast", kNoArgument, kOptionGroupcast },
{ "app-pipe", kArgumentRequired, kOptionAppPipe },
{ "trace-to", kArgumentRequired, kOptionTraceTo },
+ { "dac_provider", kArgumentRequired, kOptionDacProvider },
{}, // need empty terminator
};
@@ -231,7 +237,11 @@
#endif
result += " --KVS <path>\n";
+#if defined(CHIP_CONFIG_KVS_PATH)
result += " Path to the Key Value Store file (default: " CHIP_CONFIG_KVS_PATH ")\n\n";
+#else
+ result += " Path to the Key Value Store file\n\n";
+#endif
result += " --discriminator <number>\n";
result += " Discriminator value for commissioning (default: 3840)\n\n";
@@ -257,6 +267,9 @@
result += " --trace-to <destination>\n";
result += " Enable tracing destination (e.g., json:log, json:file_path)\n\n";
+ result += " --dac_provider <path>\n";
+ result += " Path to JSON file containing device attestation credentials\n\n";
+
return result;
}();
diff --git a/examples/all-devices-app/posix/app_options/AppOptions.h b/examples/all-devices-app/posix/app_options/AppOptions.h
index 2d6655f..d9d47ed 100644
--- a/examples/all-devices-app/posix/app_options/AppOptions.h
+++ b/examples/all-devices-app/posix/app_options/AppOptions.h
@@ -43,6 +43,7 @@
std::optional<uint16_t> productId;
std::optional<uint32_t> interfaceId;
std::string kvsPath;
+ std::optional<std::string> dacProvider;
bool enableWiFi = false;
uint32_t bleController = 0;
};
diff --git a/examples/all-devices-app/posix/app_options/tests/BUILD.gn b/examples/all-devices-app/posix/app_options/tests/BUILD.gn
index 67150f3..23d15e6 100644
--- a/examples/all-devices-app/posix/app_options/tests/BUILD.gn
+++ b/examples/all-devices-app/posix/app_options/tests/BUILD.gn
@@ -26,6 +26,7 @@
cflags = [ "-Wconversion" ]
public_deps = [
+ "${chip_root}/examples/all-devices-app/posix/app_options:app-options",
"${chip_root}/examples/all-devices-app/posix/app_options:device-type-parser",
"${chip_root}/src/lib/support:testing",
"${chip_root}/src/platform",
diff --git a/examples/all-devices-app/posix/app_options/tests/TestDeviceTypeParser.cpp b/examples/all-devices-app/posix/app_options/tests/TestDeviceTypeParser.cpp
index f652356..f6d2dbd 100644
--- a/examples/all-devices-app/posix/app_options/tests/TestDeviceTypeParser.cpp
+++ b/examples/all-devices-app/posix/app_options/tests/TestDeviceTypeParser.cpp
@@ -16,7 +16,9 @@
* limitations under the License.
*/
+#include <app_options/AppOptions.h>
#include <app_options/DeviceTypeParser.h>
+#include <lib/support/CHIPArgParser.hpp>
#include <pw_unit_test/framework.h>
using namespace chip;
@@ -449,3 +451,12 @@
{ .type = "speaker", .endpoint = 3, .parentId = 2 } };
EXPECT_NE(DeviceTypeParser::ValidateConfig(entries), CHIP_NO_ERROR);
}
+
+TEST(TestAppOptions, Parse_DacProvider)
+{
+ const char * argv[] = { "all-devices-app", "--dac_provider", "path/to/dac.json", nullptr };
+ ArgParser::OptionSet * options[] = { AppOptions::GetOptions(), nullptr };
+ EXPECT_TRUE(ArgParser::ParseArgs("all-devices-app", 3, const_cast<char * const *>(argv), options));
+ EXPECT_EQ(AppOptions::ValidateConfig(), CHIP_NO_ERROR);
+ EXPECT_EQ(AppOptions::GetConfig().dacProvider.value_or(""), "path/to/dac.json");
+}
diff --git a/examples/all-devices-app/posix/main.cpp b/examples/all-devices-app/posix/main.cpp
index 9b77bfa..066f261 100644
--- a/examples/all-devices-app/posix/main.cpp
+++ b/examples/all-devices-app/posix/main.cpp
@@ -35,12 +35,12 @@
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
#include <app/server/Dnssd.h>
#include <app/server/Server.h>
+#include <providers/AllDevicesExampleDACProvider.h>
#include <providers/AllDevicesExampleDeviceInfoProviderImpl.h>
#include <providers/AllDevicesExampleDeviceInstanceInfoProviderImpl.h>
#include <app_options/AppOptions.h>
#include <app_options/DeviceTypeParser.h>
-#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <device-factory/DeviceFactory.h>
#include <device/api/allocator/DynamicEndpointIdAllocator.h>
#include <oob-accessors/OOBAccessor.h>
@@ -346,7 +346,9 @@
// Set the global DAC provider before server/cluster init so any integration path that
// snapshots the provider during construction sees a valid implementation.
- SetDeviceAttestationCredentialsProvider(Credentials::Examples::GetExampleDACProvider());
+ static DeviceLayer::AllDevicesExampleDACProvider sDacProvider;
+ SuccessOrDie(sDacProvider.Init(AppOptions::GetConfig().dacProvider));
+ SetDeviceAttestationCredentialsProvider(&sDacProvider);
static CodeDrivenDataModelDevices devices({
.storageDelegate = *initParams.persistentStorageDelegate, //