From 191b0b5c701d5f691986b873264be7284f3a1b60 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 5 Jan 2023 07:26:37 -0500 Subject: [PATCH 01/14] Move weakly typed enum list back into Matter repository. (#24270) Instead of hardcoding this list in the helper (in the ZAP repository), it should be data in the Matter repository. Then we can remove things from the list without having to synchronize with ZAP changes. This change on its own does not make ZAP use this YAML instead of the hardcoded list; that will need to be a separate ZAP change after this merges. --- src/app/common/templates/templates.json | 3 ++ src/app/common/templates/weak-enum-list.yaml | 39 ++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/app/common/templates/weak-enum-list.yaml diff --git a/src/app/common/templates/templates.json b/src/app/common/templates/templates.json index 03327d0469b013..400511cce6ff86 100644 --- a/src/app/common/templates/templates.json +++ b/src/app/common/templates/templates.json @@ -8,6 +8,9 @@ "templates/app/helper.js", "templates/chip/helper.js" ], + "resources": { + "weak-enum-list": "weak-enum-list.yaml" + }, "override": "../../zap-templates/common/override.js", "partials": [ { diff --git a/src/app/common/templates/weak-enum-list.yaml b/src/app/common/templates/weak-enum-list.yaml new file mode 100644 index 00000000000000..24e3fc3b89de4a --- /dev/null +++ b/src/app/common/templates/weak-enum-list.yaml @@ -0,0 +1,39 @@ +# Allow-list of enums that we generate as enums, not enum classes. The goal is +# to drive this down to 0. +- AttributeWritePermission +- BarrierControlBarrierPosition +- BarrierControlMovingState +- ColorControlOptions +- ColorLoopAction +- ColorLoopDirection +- ColorMode +- ContentLaunchStatus +- ContentLaunchStreamingType +- EnhancedColorMode +- HardwareFaultType +- HueDirection +- HueMoveMode +- HueStepMode +- IdentifyEffectIdentifier +- IdentifyEffectVariant +- IdentifyIdentifyType +- InterfaceType +- KeypadLockout +- LevelControlOptions +- MoveMode +- NetworkFaultType +- OnOffDelayedAllOffEffectVariant +- OnOffDyingLightEffectVariant +- OnOffEffectIdentifier +- PHYRateType +- RadioFaultType +- RoutingRole +- SaturationMoveMode +- SaturationStepMode +- SecurityType +- SetpointAdjustMode +- StartUpOnOffValue +- StatusCode +- StepMode +- TemperatureDisplayMode +- WiFiVersionType From b1b899465918c5cf1b7157ba485adada5b4b413c Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 5 Jan 2023 15:14:00 +0100 Subject: [PATCH 02/14] [chip-tool] Add busyWaitMs optional argument to chip-tool to lock the main thread and the reception of messages for a given duration once a message is sent (#23886) --- .../commands/clusters/ClusterCommand.h | 2 + .../commands/clusters/WriteAttributeCommand.h | 2 + .../interaction_model/InteractionModel.cpp | 15 +++++++ .../interaction_model/InteractionModel.h | 44 +++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/examples/chip-tool/commands/clusters/ClusterCommand.h b/examples/chip-tool/commands/clusters/ClusterCommand.h index f6cb307021ac5d..c2562843e024a8 100644 --- a/examples/chip-tool/commands/clusters/ClusterCommand.h +++ b/examples/chip-tool/commands/clusters/ClusterCommand.h @@ -173,6 +173,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs, "If provided, do a timed invoke with the given timed interaction timeout. See \"7.6.10. Timed Interaction\" in " "the Matter specification."); + AddArgument("busyWaitForMs", 0, UINT16_MAX, &mBusyWaitForMs, + "If provided, block the main thread processing for the given time right after sending a command."); AddArgument("suppressResponse", 0, 1, &mSuppressResponse); AddArgument("repeat-count", 1, UINT16_MAX, &mRepeatCount); AddArgument("repeat-delay-ms", 0, UINT16_MAX, &mRepeatDelayInMs); diff --git a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h index 56363cb481721d..9b5e8f3ef70728 100644 --- a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h +++ b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h @@ -228,6 +228,8 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs, "If provided, do a timed write with the given timed interaction timeout. See \"7.6.10. Timed Interaction\" in " "the Matter specification."); + AddArgument("busyWaitForMs", 0, UINT16_MAX, &mBusyWaitForMs, + "If provided, block the main thread processing for the given time right after sending a command."); AddArgument("data-version", 0, UINT32_MAX, &mDataVersions, "Comma-separated list of data versions for the clusters being written."); AddArgument("suppressResponse", 0, 1, &mSuppressResponse); diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp index ad4bf1603a258d..542f4ffd29368f 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp @@ -21,6 +21,21 @@ using namespace chip; using namespace chip::app; +namespace chip { +namespace test_utils { +void BusyWaitMillis(uint16_t busyWaitForMs) +{ + auto & clock = chip::System::SystemClock(); + auto start = clock.GetMonotonicTimestamp(); + chip::System::Clock::Milliseconds32 durationInMs(busyWaitForMs); + while (clock.GetMonotonicTimestamp() - start < durationInMs) + { + // nothing to do. + }; +} +} // namespace test_utils +} // namespace chip + CHIP_ERROR InteractionModel::ReadAttribute(const char * identity, EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, bool fabricFiltered, const Optional & dataVersion) { diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.h b/src/app/tests/suites/commands/interaction_model/InteractionModel.h index 83a0d6fff769b6..1d3e2eb735e116 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.h +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.h @@ -30,6 +30,12 @@ constexpr uint8_t kMaxAllowedPaths = 10; +namespace chip { +namespace test_utils { +void BusyWaitMillis(uint16_t busyWaitForMs); +} // namespace test_utils +} // namespace chip + class InteractionModelConfig { public: @@ -237,6 +243,11 @@ class InteractionModelCommands ReturnErrorOnFailure(commandSender->SendCommandRequest(device->GetSecureSession().Value())); mCommandSender.push_back(std::move(commandSender)); + if (mBusyWaitForMs.HasValue()) + { + chip::test_utils::BusyWaitMillis(mBusyWaitForMs.Value()); + } + if (mRepeatDelayInMs.HasValue()) { chip::test_utils::SleepMillis(mRepeatDelayInMs.Value()); @@ -321,18 +332,32 @@ class InteractionModelCommands return *this; } + InteractionModelCommands & SetBusyWaitForMs(uint16_t busyWaitForMs) + { + mBusyWaitForMs.SetValue(busyWaitForMs); + return *this; + } + + InteractionModelCommands & SetBusyWaitForMs(const chip::Optional & busyWaitForMs) + { + mBusyWaitForMs = busyWaitForMs; + return *this; + } + void ResetOptions() { mTimedInteractionTimeoutMs = chip::NullOptional; mSuppressResponse = chip::NullOptional; mRepeatCount = chip::NullOptional; mRepeatDelayInMs = chip::NullOptional; + mBusyWaitForMs = chip::NullOptional; } chip::Optional mTimedInteractionTimeoutMs; chip::Optional mSuppressResponse; chip::Optional mRepeatCount; chip::Optional mRepeatDelayInMs; + chip::Optional mBusyWaitForMs; }; class InteractionModelWriter @@ -370,6 +395,11 @@ class InteractionModelWriter ReturnErrorOnFailure(mWriteClient->SendWriteRequest(device->GetSecureSession().Value())); + if (mBusyWaitForMs.HasValue()) + { + chip::test_utils::BusyWaitMillis(mBusyWaitForMs.Value()); + } + if (mRepeatDelayInMs.HasValue()) { chip::test_utils::SleepMillis(mRepeatDelayInMs.Value()); @@ -487,6 +517,18 @@ class InteractionModelWriter return *this; } + InteractionModelWriter & SetBusyWaitForMs(uint16_t busyWaitForMs) + { + mBusyWaitForMs.SetValue(busyWaitForMs); + return *this; + } + + InteractionModelWriter & SetBusyWaitForMs(const chip::Optional & busyWaitForMs) + { + mBusyWaitForMs = busyWaitForMs; + return *this; + } + void ResetOptions() { mTimedInteractionTimeoutMs = chip::NullOptional; @@ -494,6 +536,7 @@ class InteractionModelWriter mDataVersions = chip::NullOptional; mRepeatCount = chip::NullOptional; mRepeatDelayInMs = chip::NullOptional; + mBusyWaitForMs = chip::NullOptional; } chip::Optional mTimedInteractionTimeoutMs; @@ -501,6 +544,7 @@ class InteractionModelWriter chip::Optional mSuppressResponse; chip::Optional mRepeatCount; chip::Optional mRepeatDelayInMs; + chip::Optional mBusyWaitForMs; private: template From c3a4bc9ab3d8bbd4f05c765e79775a99a73a5b00 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 5 Jan 2023 09:20:11 -0500 Subject: [PATCH 03/14] Align naming in Network Commissioning cluster XML with the spec. (#24264) * Align naming in Network Commissioning cluster XML with the spec. * Regenerate generated files. --- .../all-clusters-common/all-clusters-app.matter | 2 +- .../all-clusters-minimal-app.matter | 2 +- examples/bridge-app/bridge-common/bridge-app.matter | 2 +- .../rootnode_colortemperaturelight_hbUnzYVeyn.matter | 2 +- .../devices/rootnode_contactsensor_lFAGG1bfRO.matter | 2 +- .../devices/rootnode_dimmablelight_bCwGYSDpoe.matter | 2 +- .../chef/devices/rootnode_doorlock_aNKYAreMXE.matter | 2 +- .../rootnode_extendedcolorlight_8lcaaYJVAa.matter | 2 +- examples/chef/devices/rootnode_fan_7N2TobIlOX.matter | 2 +- .../devices/rootnode_flowsensor_1zVxHedlaV.matter | 2 +- .../rootnode_heatingcoolingunit_ncdGai1E5a.matter | 2 +- .../devices/rootnode_humiditysensor_Xyj4gda6Hb.matter | 2 +- .../devices/rootnode_lightsensor_lZQycTFcJK.matter | 2 +- .../rootnode_occupancysensor_iHyVgifZuo.matter | 2 +- .../devices/rootnode_onofflight_bbs1b7IaOV.matter | 2 +- .../rootnode_onofflightswitch_FsPlMr090Q.matter | 2 +- .../rootnode_onoffpluginunit_Wtf8ss5EBY.matter | 2 +- .../devices/rootnode_pressuresensor_s0qC9wLH4k.matter | 2 +- .../chef/devices/rootnode_speaker_RpzeXdimqA.matter | 2 +- .../rootnode_temperaturesensor_Qy1zkNW7c3.matter | 2 +- .../devices/rootnode_thermostat_bm3fb8dhYi.matter | 2 +- .../devices/rootnode_windowcovering_RLCxaGi9Yx.matter | 2 +- .../contact-sensor-common/contact-sensor-app.matter | 2 +- .../bridge-common/bridge-app.matter | 2 +- .../light-switch-common/light-switch-app.matter | 2 +- .../lighting-app/lighting-common/lighting-app.matter | 2 +- examples/lighting-app/nxp/zap/lighting-on-off.matter | 2 +- examples/lock-app/lock-common/lock-app.matter | 2 +- .../log-source-common/log-source-app.matter | 2 +- .../ota-provider-common/ota-provider-app.matter | 2 +- .../ota-requestor-common/ota-requestor-app.matter | 2 +- examples/placeholder/linux/apps/app1/config.matter | 2 +- examples/placeholder/linux/apps/app2/config.matter | 2 +- examples/pump-app/pump-common/pump-app.matter | 2 +- .../pump-controller-common/pump-controller-app.matter | 2 +- .../esp32/main/temperature-measurement.matter | 2 +- .../thermostat/thermostat-common/thermostat.matter | 2 +- examples/tv-app/tv-common/tv-app.matter | 4 ++-- .../tv-casting-common/tv-casting-app.matter | 2 +- examples/window-app/common/window-app.matter | 2 +- .../data-model/chip/network-commissioning-cluster.xml | 8 ++++---- src/controller/data_model/controller-clusters.matter | 2 +- .../Framework/CHIP/templates/MTRBaseClusters.zapt | 2 +- src/darwin/Framework/CHIP/templates/availability.yaml | 11 +++++++++++ .../Framework/CHIP/zap-generated/MTRBaseClusters.h | 5 ++++- .../Darwin/WiFi/NetworkCommissioningWiFiDriver.mm | 2 +- .../silabs/NetworkCommissioningWiFiDriver.cpp | 2 +- .../app-common/zap-generated/cluster-enums.h | 2 +- .../app-common/app-common/zap-generated/enums.h | 4 ++-- 49 files changed, 67 insertions(+), 53 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 2999f27a55bdb4..d3c4b3c21e166e 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -979,7 +979,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 0ea0a312a80a70..78a720bf22610c 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -908,7 +908,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/bridge-app/bridge-common/bridge-app.matter b/examples/bridge-app/bridge-common/bridge-app.matter index bc512081ede0c3..9e196b071bb2df 100644 --- a/examples/bridge-app/bridge-common/bridge-app.matter +++ b/examples/bridge-app/bridge-common/bridge-app.matter @@ -654,7 +654,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter index b581d736f30482..64f4e158311dc2 100644 --- a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter +++ b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter @@ -624,7 +624,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter index cfaef808114702..92c6d0e9a303bd 100644 --- a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter +++ b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter @@ -497,7 +497,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter index 7c314a9211d015..5d9520811f7de6 100644 --- a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter @@ -646,7 +646,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter index 472e9477262e0a..d60f528e15b86f 100644 --- a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter +++ b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter @@ -497,7 +497,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter index dff1a98eed5aa3..9657afc4259cea 100644 --- a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter +++ b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter @@ -646,7 +646,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter b/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter index 15e0a1034d897c..0da03778068ce3 100644 --- a/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter +++ b/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter @@ -499,7 +499,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter index 7c6446e1e8cc9b..f1551f204ef330 100644 --- a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter +++ b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter @@ -510,7 +510,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter index 3b36f2ae987519..ee51f83d2e671b 100644 --- a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter +++ b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter @@ -639,7 +639,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter index 39ad6dd5f3013c..b8d3088688c159 100644 --- a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter +++ b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter @@ -510,7 +510,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter index a0a6b310a10319..3c337b37201a94 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter @@ -510,7 +510,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter index 770f2495594654..dbe0949d0bef74 100644 --- a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter +++ b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter @@ -510,7 +510,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter index f3f026c679f961..736958cc69273b 100644 --- a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter +++ b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter @@ -646,7 +646,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter index 647f5be459e9da..2d3dab4480ef7b 100644 --- a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter +++ b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter @@ -589,7 +589,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter index e5a1c171203196..9c6d87a08b45a2 100644 --- a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter +++ b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter @@ -547,7 +547,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter index efb2f5ebbb9e58..a05ec34df74a70 100644 --- a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter +++ b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter @@ -515,7 +515,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter index 0a3f54e975dfb5..b22236fb5eaad6 100644 --- a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter +++ b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter @@ -637,7 +637,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter index 4ca3f3231e275f..956938cf4a91a1 100644 --- a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter +++ b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter @@ -510,7 +510,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter index 35202e6eb9c2e6..c15a487a642a67 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter @@ -497,7 +497,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter index 455c6dc74ddb73..729ceff4fe6636 100644 --- a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter +++ b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter @@ -497,7 +497,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter index 108218687f5598..0696014926b2f5 100644 --- a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter +++ b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter @@ -500,7 +500,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/dynamic-bridge-app/bridge-common/bridge-app.matter b/examples/dynamic-bridge-app/bridge-common/bridge-app.matter index bc512081ede0c3..9e196b071bb2df 100644 --- a/examples/dynamic-bridge-app/bridge-common/bridge-app.matter +++ b/examples/dynamic-bridge-app/bridge-common/bridge-app.matter @@ -654,7 +654,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index 60163b655d90a8..af2fc54a7ec4ee 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -702,7 +702,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index 7b2c429fd448c4..34d79e80f4df80 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -658,7 +658,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.matter b/examples/lighting-app/nxp/zap/lighting-on-off.matter index 35d6253d4f3e75..ce768f1eda4bbe 100644 --- a/examples/lighting-app/nxp/zap/lighting-on-off.matter +++ b/examples/lighting-app/nxp/zap/lighting-on-off.matter @@ -612,7 +612,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index 283c91d72fed46..2e7ff08d46cbaa 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -574,7 +574,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/log-source-app/log-source-common/log-source-app.matter b/examples/log-source-app/log-source-common/log-source-app.matter index 28341bb99c23f0..e00f69ca61edc0 100644 --- a/examples/log-source-app/log-source-common/log-source-app.matter +++ b/examples/log-source-app/log-source-common/log-source-app.matter @@ -157,7 +157,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter b/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter index dafc45b9628fc9..631d8303ffa7c8 100644 --- a/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter +++ b/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter @@ -393,7 +393,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter index 00ec6a26d82721..a2ce3e2b02aa6f 100644 --- a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter +++ b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter @@ -558,7 +558,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 4ad37a9e6f581b..f8ffde9dff6c9b 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -819,7 +819,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index 4ad37a9e6f581b..f8ffde9dff6c9b 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -819,7 +819,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/pump-app/pump-common/pump-app.matter b/examples/pump-app/pump-common/pump-app.matter index 9f7d9dd521d959..729a6ad9012a7d 100644 --- a/examples/pump-app/pump-common/pump-app.matter +++ b/examples/pump-app/pump-common/pump-app.matter @@ -561,7 +561,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter index fbbb3ad0e1a546..da44ef42b0a06b 100644 --- a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter +++ b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter @@ -460,7 +460,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter b/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter index bf88563db716ce..c49f2ec01f56e4 100644 --- a/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter +++ b/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter @@ -274,7 +274,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index 28f3870a5a281c..15d06410def29c 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -662,7 +662,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/tv-app/tv-common/tv-app.matter b/examples/tv-app/tv-common/tv-app.matter index 98b68bf8f34b43..e3c07dd6d3bd8b 100644 --- a/examples/tv-app/tv-common/tv-app.matter +++ b/examples/tv-app/tv-common/tv-app.matter @@ -573,7 +573,7 @@ client cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; @@ -707,7 +707,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index ea6c92a294542b..b073a35a99aea5 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -879,7 +879,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index cd0a0e789a10de..c29a4d437cd2d4 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -740,7 +740,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml index eaf97404c4365b..57d469de794daa 100644 --- a/src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml @@ -43,7 +43,7 @@ limitations under the License. - + @@ -171,8 +171,8 @@ limitations under the License. - - - + + + diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 4de517ed5d514e..f7573977ba4a49 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -1143,7 +1143,7 @@ client cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt index 433c778543c4dd..99a43ecc41aadc 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt @@ -121,7 +121,7 @@ typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitm {{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel label}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=(objCEnumItemLabel label) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex mask}}, {{#*inline "oldNameItemDecl"}} {{#if oldItemName}} - {{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName bitmap=../enumName bitmapValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex value 2}}, + {{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex mask}}, {{/if}} {{/inline}} {{> oldNameItemDecl oldItemName=(oldName ../clusterName bitmap=../bitmapName bitmapValue=(objCEnumItemLabel label))}} diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index bc301ada0ea09e..fb9685f8ad5539 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -5205,6 +5205,9 @@ LevelControlOptions: - ExecuteIfOff - CoupleColorTempToLevel + NetworkCommissioning: + WiFiSecurity: + - WEP deprecated: clusters: - OtaSoftwareUpdateProvider @@ -5269,6 +5272,10 @@ PowerSource: BatChargeLevel: - Ok + bitmap values: + NetworkCommissioning: + WiFiSecurity: + - WepPersonal apis: - Timed Invoke for server to client commands - Deprecated global attribute names @@ -5347,3 +5354,7 @@ PowerSource: BatChargeLevel: OK: Ok + bitmap values: + NetworkCommissioning: + WiFiSecurity: + WEP: WepPersonal diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index 7999ed99518178..0387e8cc9334ac 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -17522,7 +17522,10 @@ typedef NS_OPTIONS(uint32_t, MTRNetworkCommissioningFeature) { typedef NS_OPTIONS(uint8_t, MTRNetworkCommissioningWiFiSecurity) { MTRNetworkCommissioningWiFiSecurityUnencrypted API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x1, - MTRNetworkCommissioningWiFiSecurityWepPersonal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x2, + MTRNetworkCommissioningWiFiSecurityWEP MTR_NEWLY_AVAILABLE = 0x2, + MTRNetworkCommissioningWiFiSecurityWepPersonal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRNetworkCommissioningWiFiSecurityWEP") + = 0x2, MTRNetworkCommissioningWiFiSecurityWpaPersonal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x4, MTRNetworkCommissioningWiFiSecurityWpa2Personal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x8, MTRNetworkCommissioningWiFiSecurityWpa3Personal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x10, diff --git a/src/platform/Darwin/WiFi/NetworkCommissioningWiFiDriver.mm b/src/platform/Darwin/WiFi/NetworkCommissioningWiFiDriver.mm index 94a67373de41aa..a393e79996f9c9 100644 --- a/src/platform/Darwin/WiFi/NetworkCommissioningWiFiDriver.mm +++ b/src/platform/Darwin/WiFi/NetworkCommissioningWiFiDriver.mm @@ -93,7 +93,7 @@ WiFiSecurity GetWiFiSecurity(CWNetwork * network) } if ([network supportsSecurity:kCWSecurityWEP]) { - return WiFiSecurity::kWepPersonal; + return WiFiSecurity::kWep; } if ([network supportsSecurity:kCWSecurityWPAPersonal]) { diff --git a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp index b63d617befcec8..98af04b7319a2f 100644 --- a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp @@ -203,7 +203,7 @@ chip::BitFlags SlWiFiDriver::ConvertSecuritytype(uint8_t security) } else if (security & WFX_SEC_WEP) { - securityType = WiFiSecurity::kWepPersonal; + securityType = WiFiSecurity::kWep; } else if (security & WFX_SEC_WPA) { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index c29a4d426ea87d..bb5cf6a6e78b5d 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -622,7 +622,7 @@ enum class NetworkCommissioningFeature : uint32_t enum class WiFiSecurity : uint8_t { kUnencrypted = 0x1, - kWepPersonal = 0x2, + kWep = 0x2, kWpaPersonal = 0x4, kWpa2Personal = 0x8, kWpa3Personal = 0x10, diff --git a/zzz_generated/app-common/app-common/zap-generated/enums.h b/zzz_generated/app-common/app-common/zap-generated/enums.h index f2d3e87a8a3812..5e0312ef23de4c 100644 --- a/zzz_generated/app-common/app-common/zap-generated/enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/enums.h @@ -962,8 +962,8 @@ enum EmberAfWiFiVersionType : uint8_t #define EMBER_AF_WI_FI_NETWORK_DIAGNOSTICS_FEATURE_ERROR_COUNTS_OFFSET (1) #define EMBER_AF_WI_FI_SECURITY_UNENCRYPTED (1) #define EMBER_AF_WI_FI_SECURITY_UNENCRYPTED_OFFSET (0) -#define EMBER_AF_WI_FI_SECURITY_WEP_PERSONAL (2) -#define EMBER_AF_WI_FI_SECURITY_WEP_PERSONAL_OFFSET (1) +#define EMBER_AF_WI_FI_SECURITY_WEP (2) +#define EMBER_AF_WI_FI_SECURITY_WEP_OFFSET (1) #define EMBER_AF_WI_FI_SECURITY_WPA_PERSONAL (4) #define EMBER_AF_WI_FI_SECURITY_WPA_PERSONAL_OFFSET (2) #define EMBER_AF_WI_FI_SECURITY_WPA2_PERSONAL (8) From 631e2c4656d6f5127be1865878ceb9d325e77791 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 5 Jan 2023 09:48:20 -0500 Subject: [PATCH 04/14] Increase build timeout for cc13x2x7_26x2x7 builds (#24282) --- .github/workflows/examples-cc13x2x7_26x2x7.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index d8598c6561eba9..aa11433edd9fa6 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -28,7 +28,7 @@ env: jobs: cc26x2x7: name: cc26x2x7 - timeout-minutes: 60 + timeout-minutes: 120 env: BUILD_TYPE: gn_cc26x2x7 @@ -68,7 +68,7 @@ jobs: .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log - name: Build examples - timeout-minutes: 60 + timeout-minutes: 100 run: | scripts/run_in_build_env.sh "\ ./scripts/build/build_examples.py \ From 7fe65779c7cd1f61a67f9728f5418ad0144b9129 Mon Sep 17 00:00:00 2001 From: Sharad Binjola <31142146+sharadb-amazon@users.noreply.github.com> Date: Thu, 5 Jan 2023 06:49:14 -0800 Subject: [PATCH 05/14] tv-casting-app: On kBindingsChangedViaCluster, connect to VideoPlayer if already commissioned with it (#24268) * tv-casting-app: On kBindingsChangedViaCluster, connect to VideoPlayer if already commissioned with it * Addressing chrisdecenzo@'s feedback * Addressing bzbarsky-apple@'s feedback --- .../tv-casting-common/include/CastingServer.h | 3 +- .../include/TargetVideoPlayerInfo.h | 1 + .../tv-casting-common/src/CastingServer.cpp | 73 ++++++++++++++++++- .../src/TargetVideoPlayerInfo.cpp | 27 ++++--- 4 files changed, 90 insertions(+), 14 deletions(-) diff --git a/examples/tv-casting-app/tv-casting-common/include/CastingServer.h b/examples/tv-casting-app/tv-casting-common/include/CastingServer.h index 09fb76d21525df..0eab5ab0311dcb 100644 --- a/examples/tv-casting-app/tv-casting-common/include/CastingServer.h +++ b/examples/tv-casting-app/tv-casting-common/include/CastingServer.h @@ -415,7 +415,8 @@ class CastingServer void ReadServerClusters(chip::EndpointId endpointId); PersistenceManager mPersistenceManager; - bool mInited = false; + bool mInited = false; + bool mUdcInProgress = false; TargetVideoPlayerInfo mActiveTargetVideoPlayerInfo; TargetVideoPlayerInfo mCachedTargetVideoPlayerInfo[kMaxCachedVideoPlayers]; uint16_t mTargetVideoPlayerVendorId = 0; diff --git a/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h b/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h index c362ec95c99a24..4c0fd1455e7ea1 100644 --- a/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h +++ b/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h @@ -43,6 +43,7 @@ class TargetVideoPlayerInfo size_t GetNumIPs() const { return mNumIPs; } const chip::Inet::IPAddress * GetIpAddresses() const { return mIpAddress; } bool IsSameAs(const chip::Dnssd::DiscoveredNodeData * discoveredNodeData); + bool IsSameAs(const char * deviceName, size_t numIPs, const chip::Inet::IPAddress * ipAddresses); chip::OperationalDeviceProxy * GetOperationalDeviceProxy() { diff --git a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp index 1fa2965abcbff6..558139f3cff155 100644 --- a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp @@ -130,6 +130,7 @@ CHIP_ERROR CastingServer::SendUserDirectedCommissioningRequest(chip::Transport:: CHIP_ERROR CastingServer::SendUserDirectedCommissioningRequest(Dnssd::DiscoveredNodeData * selectedCommissioner) { + mUdcInProgress = true; // Send User Directed commissioning request ReturnErrorOnFailure(SendUserDirectedCommissioningRequest(chip::Transport::PeerAddress::UDP( selectedCommissioner->resolutionData.ipAddress[0], selectedCommissioner->resolutionData.port, @@ -320,24 +321,92 @@ CastingServer::ContentLauncherLaunchURL(TargetEndpointInfo * endpoint, const cha void CastingServer::DeviceEventCallback(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg) { + bool runPostCommissioning = false; + chip::NodeId targetPeerNodeId = 0; + chip::FabricIndex targetFabricIndex = 0; if (event->Type == DeviceLayer::DeviceEventType::kBindingsChangedViaCluster) { + ChipLogProgress(AppServer, "CastingServer::DeviceEventCallback kBindingsChangedViaCluster received"); if (CastingServer::GetInstance()->GetActiveTargetVideoPlayer()->IsInitialized()) { + ChipLogProgress(AppServer, + "CastingServer::DeviceEventCallback already connected to video player, reading server clusters"); CastingServer::GetInstance()->ReadServerClustersForNode( CastingServer::GetInstance()->GetActiveTargetVideoPlayer()->GetNodeId()); } + else if (CastingServer::GetInstance()->mUdcInProgress) + { + ChipLogProgress(AppServer, + "CastingServer::DeviceEventCallback UDC is in progress while handling kBindingsChangedViaCluster"); + CastingServer::GetInstance()->mUdcInProgress = false; + if (CastingServer::GetInstance()->mTargetVideoPlayerNumIPs > 0) + { + TargetVideoPlayerInfo * connectableVideoPlayerList = + CastingServer::GetInstance()->ReadCachedTargetVideoPlayerInfos(); + if (connectableVideoPlayerList == nullptr || !connectableVideoPlayerList[0].IsInitialized()) + { + ChipLogError(AppServer, "CastingServer::DeviceEventCallback No cached video players found"); + CastingServer::GetInstance()->mCommissioningCompleteCallback(CHIP_ERROR_INCORRECT_STATE); + return; + } + + for (size_t i = 0; i < kMaxCachedVideoPlayers && connectableVideoPlayerList[i].IsInitialized(); i++) + { + if (connectableVideoPlayerList[i].IsSameAs(CastingServer::GetInstance()->mTargetVideoPlayerDeviceName, + CastingServer::GetInstance()->mTargetVideoPlayerNumIPs, + CastingServer::GetInstance()->mTargetVideoPlayerIpAddress)) + { + ChipLogProgress(AppServer, + "CastingServer::DeviceEventCallback found the video player to initialize/connect to"); + targetPeerNodeId = connectableVideoPlayerList[i].GetNodeId(); + targetFabricIndex = connectableVideoPlayerList[i].GetFabricIndex(); + runPostCommissioning = true; + } + } + + if (targetPeerNodeId == 0 && runPostCommissioning == false) + { + ChipLogError(AppServer, + "CastingServer::DeviceEventCallback did NOT find the video player to initialize/connect to"); + CastingServer::GetInstance()->mCommissioningCompleteCallback(CHIP_ERROR_INCORRECT_STATE); + return; + } + } + } } else if (event->Type == DeviceLayer::DeviceEventType::kCommissioningComplete) { + ChipLogProgress(AppServer, "CastingServer::DeviceEventCallback kCommissioningComplete received"); + CastingServer::GetInstance()->mUdcInProgress = false; + targetPeerNodeId = event->CommissioningComplete.nodeId; + targetFabricIndex = event->CommissioningComplete.fabricIndex; + runPostCommissioning = true; + } + + if (runPostCommissioning) + { + ChipLogProgress(AppServer, + "CastingServer::DeviceEventCallback will connect with nodeId=0x" ChipLogFormatX64 " fabricIndex=%d", + ChipLogValueX64(targetPeerNodeId), targetFabricIndex); CHIP_ERROR err = CastingServer::GetInstance()->GetActiveTargetVideoPlayer()->Initialize( - event->CommissioningComplete.nodeId, event->CommissioningComplete.fabricIndex, - CastingServer::GetInstance()->mOnConnectionSuccessClientCallback, + targetPeerNodeId, targetFabricIndex, CastingServer::GetInstance()->mOnConnectionSuccessClientCallback, CastingServer::GetInstance()->mOnConnectionFailureClientCallback, CastingServer::GetInstance()->mTargetVideoPlayerVendorId, CastingServer::GetInstance()->mTargetVideoPlayerProductId, CastingServer::GetInstance()->mTargetVideoPlayerDeviceType, CastingServer::GetInstance()->mTargetVideoPlayerDeviceName, CastingServer::GetInstance()->mTargetVideoPlayerNumIPs, CastingServer::GetInstance()->mTargetVideoPlayerIpAddress); + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Failed to initialize target video player"); + } + + err = CastingServer::GetInstance()->mPersistenceManager.AddVideoPlayer( + &CastingServer::GetInstance()->mActiveTargetVideoPlayerInfo); + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "AddVideoPlayer(ToCache) error: %" CHIP_ERROR_FORMAT, err.Format()); + } + CastingServer::GetInstance()->mCommissioningCompleteCallback(err); } } diff --git a/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp b/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp index 70609f328fc5ef..7e1d13f7e4677a 100644 --- a/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp @@ -126,16 +126,10 @@ void TargetVideoPlayerInfo::PrintInfo() } } -bool TargetVideoPlayerInfo::IsSameAs(const chip::Dnssd::DiscoveredNodeData * discoveredNodeData) +bool TargetVideoPlayerInfo::IsSameAs(const char * deviceName, size_t numIPs, const chip::Inet::IPAddress * ipAddresses) { - // return false because 'this' VideoPlayer is not null - if (discoveredNodeData == nullptr) - { - return false; - } - // return false because deviceNames are different - if (strcmp(mDeviceName, discoveredNodeData->commissionData.deviceName) != 0) + if (strcmp(mDeviceName, deviceName) != 0) { return false; } @@ -146,10 +140,9 @@ bool TargetVideoPlayerInfo::IsSameAs(const chip::Dnssd::DiscoveredNodeData * dis bool matchFound = false; for (size_t i = 0; i < mNumIPs && i < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; i++) { - for (size_t j = 0; - j < discoveredNodeData->resolutionData.numIPs && j < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; j++) + for (size_t j = 0; j < numIPs && j < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; j++) { - if (mIpAddress[i] == discoveredNodeData->resolutionData.ipAddress[j]) + if (mIpAddress[i] == ipAddresses[j]) { matchFound = true; break; @@ -169,3 +162,15 @@ bool TargetVideoPlayerInfo::IsSameAs(const chip::Dnssd::DiscoveredNodeData * dis return true; } + +bool TargetVideoPlayerInfo::IsSameAs(const chip::Dnssd::DiscoveredNodeData * discoveredNodeData) +{ + // return false because 'this' VideoPlayer is not null + if (discoveredNodeData == nullptr) + { + return false; + } + + return IsSameAs(discoveredNodeData->commissionData.deviceName, discoveredNodeData->resolutionData.numIPs, + discoveredNodeData->resolutionData.ipAddress); +} From 08e1711e969d5ed90404e5a854052371acffd92e Mon Sep 17 00:00:00 2001 From: Alexander Mazuruk Date: Thu, 5 Jan 2023 15:54:54 +0100 Subject: [PATCH 06/14] Cleanup devcontainer dockerfile (#23908) - group similiar things into single layers (e.g. apt-get stuff, creating user and setting it up or chowning everything in /opt) - move cpptools installation to devcontainer.json instead of current manual installation in the dockerfile - adds noop : on end of each multi-line RUN - move restyle-path binary to /usr/local/bin rather than add a new location to the PATH - add ms-vscode.cpptools to recommended extensions for vscode Signed-off-by: Alexander Mazuruk Signed-off-by: Alexander Mazuruk --- .devcontainer/Dockerfile | 75 +++++++++++++-------------------- .devcontainer/devcontainer.json | 1 + .vscode/extensions.json | 1 + 3 files changed, 31 insertions(+), 46 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b860db10af8d43..f8e46241763eb4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -25,9 +25,10 @@ ENV LANG en_US.utf8 # these are installed for terminal/dev convenience. If more tooling for build is required, please # add them to chip-build (in integrations/docker/images/chip-build) -RUN apt-get update -RUN apt-get install -y locales && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 -RUN apt-get -fy install git vim emacs sudo \ +RUN apt-get update \ + && apt-get install -y locales \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \ + && apt-get -fy install git vim emacs sudo \ apt-utils dialog zsh \ iproute2 procps lsb-release \ bash-completion \ @@ -36,49 +37,31 @@ RUN apt-get -fy install git vim emacs sudo \ docker.io \ iputils-ping net-tools \ libncurses5 \ - libpython2.7 - -RUN groupadd -g $USER_GID $USERNAME -RUN useradd -s /bin/bash -u $USER_UID -g $USER_GID -G docker -m $USERNAME -RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME -RUN chmod 0440 /etc/sudoers.d/$USERNAME - -RUN mkdir -p /var/downloads -RUN cd /var/downloads -RUN curl -JL https://github.com/microsoft/vscode-cpptools/releases/download/0.27.0/cpptools-linux.vsix > extension.zip -RUN unzip extension.zip -RUN mkdir -p /home/$USERNAME/.vscode-server/extensions -RUN mv extension /home/$USERNAME/.vscode-server/extensions/ms-vscode.cpptools-0.27.0 -RUN mkdir -p /home/$USERNAME/bin -RUN curl https://raw.githubusercontent.com/restyled-io/restyler/master/bin/restyle-path -o /home/$USERNAME/bin/restyle-path -RUN chmod +x /home/$USERNAME/bin/restyle-path -RUN chown -R $USERNAME:$USERNAME /home/$USERNAME -RUN echo "PATH=/home/$USERNAME/bin:${PATH}" >> /home/$USERNAME/.bashrc - -# $USERNAME needs to own the esp-idf and tools for the examples to build -RUN chown -R $USERNAME:$USERNAME /opt/espressif/esp-idf -RUN chown -R $USERNAME:$USERNAME /opt/espressif/tools - -# $USERNAME needs to own west configuration to build nRF Connect examples -RUN chown -R $USERNAME:$USERNAME /opt/NordicSemiconductor/nrfconnect/ - -# allow read/write access to header and libraries -RUN chown -R $USERNAME:$USERNAME /opt/ubuntu-21.04-aarch64-sysroot/usr/ - -# allow licenses to be accepted -RUN chown -R $USERNAME:$USERNAME /opt/android/sdk - -# AmebaD requires access to change build_info.h -RUN chown -R $USERNAME:$USERNAME /opt/ameba/ambd_sdk_with_chip_non_NDA/ - -# NXP uses a patch_sdk script to change SDK files -RUN mkdir -p /opt/sdk/sdks/ -RUN chown -R $USERNAME:$USERNAME /opt/sdk/sdks/ - -RUN chown -R $USERNAME:$USERNAME /opt/fsl-imx-xwayland/5.15-kirkstone/ - -# Add access to openocd for VSCode debugging -RUN chown -R $USERNAME:$USERNAME /opt/openocd + libpython2.7 \ + && : + +RUN groupadd -g $USER_GID $USERNAME \ + && useradd -s /bin/bash -u $USER_UID -g $USER_GID -G docker,sudo -m $USERNAME \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME \ + && : + +RUN curl https://raw.githubusercontent.com/restyled-io/restyler/master/bin/restyle-path -o /usr/local/bin/restyle-path \ + && chmod +x /usr/local/bin/restyle-path \ + && : + +RUN mkdir -p /opt/sdk/sdks/ \ + && chown -R $USERNAME:$USERNAME \ + /opt/sdk/sdks/ `# NXP uses a patch_sdk script to change SDK files` \ + /opt/espressif/esp-idf `# $USERNAME needs to own the esp-idf and tools for the examples to build` \ + /opt/espressif/tools \ + /opt/NordicSemiconductor/nrfconnect/ `# $USERNAME needs to own west configuration to build nRF Connect examples` \ + /opt/ubuntu-21.04-aarch64-sysroot/usr/ `# allow read/write access to header and libraries` \ + /opt/android/sdk `# allow licenses to be accepted` \ + /opt/ameba/ambd_sdk_with_chip_non_NDA/ `# AmebaD requires access to change build_info.h` \ + /opt/fsl-imx-xwayland/5.15-kirkstone/ \ + /opt/openocd \ + && : # Fix Tizen SDK paths for new user RUN sed -i '/^TIZEN_SDK_DATA_PATH/d' $TIZEN_SDK_ROOT/sdk.info \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 70c206f1058ce3..95625da71a1e40 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -34,6 +34,7 @@ "maelvalais.autoconf", "marus25.cortex-debug", "ms-azuretools.vscode-docker", + "ms-vscode.cpptools", "msedge-dev.gnls", "redhat.vscode-yaml", "vadimcn.vscode-lldb", diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 352fb19ae65035..d5969bc3ae58f2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -15,6 +15,7 @@ "maelvalais.autoconf", "marus25.cortex-debug", "ms-azuretools.vscode-docker", + "ms-vscode.cpptools", "msedge-dev.gnls", "redhat.vscode-yaml", "vadimcn.vscode-lldb", From 260307bf2d72fd27c010357da4be76990198f05a Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 5 Jan 2023 09:56:23 -0500 Subject: [PATCH 07/14] Python packaging idl and yamltests (#24140) * Initial attempt at modularizing python packages in scripts * Put packages into separate directories with stutter * hopefully fix codegen path to idl * Fix issue with building yamltests_distribution * Hopefully fix CI * Hopefully fix CI * Hopefully fix CI * Restyle * Hopefully fix CI * Restyle * Remove directory repitition and prepend matter to py package names * Restyle * Restyle --- .github/workflows/lint.yml | 14 +- .github/workflows/tests.yaml | 2 +- .restyled.yaml | 2 +- BUILD.gn | 8 +- build/chip/chip_codegen.gni | 2 +- docs/code_generation.md | 9 +- scripts/BUILD.gn | 17 +- scripts/codegen.py | 10 +- scripts/common_setup.cfg | 19 + scripts/idl/BUILD.gn | 79 ---- scripts/idl/files.gni | 37 -- scripts/idl_lint.py | 10 +- scripts/py_matter_idl/BUILD.gn | 83 ++++ scripts/py_matter_idl/files.gni | 37 ++ .../matter_idl}/README.md | 2 +- .../matter_idl}/__init__.py | 0 .../matter_idl}/generators/__init__.py | 5 +- .../bridge/BridgeClustersCommon.jinja | 0 .../generators/bridge/BridgeClustersCpp.jinja | 0 .../bridge/BridgeClustersGlobalStructs.jinja | 0 .../bridge/BridgeClustersHeader.jinja | 0 .../matter_idl}/generators/bridge/__init__.py | 16 +- .../matter_idl}/generators/cpp/__init__.py | 0 .../cpp/application/CallbackStubSource.jinja | 0 .../PluginApplicationCallbacksHeader.jinja | 0 .../generators/cpp/application/__init__.py | 8 +- .../matter_idl}/generators/filters.py | 0 .../generators/java/ChipClustersCpp.jinja | 0 .../generators/java/ChipClustersRead.jinja | 0 .../matter_idl}/generators/java/__init__.py | 8 +- .../matter_idl}/generators/registry.py | 6 +- .../matter_idl}/generators/types.py | 4 +- .../matter_idl}/lint/__init__.py | 0 .../matter_idl}/lint/lint_rules_grammar.lark | 0 .../matter_idl}/lint/lint_rules_parser.py | 23 +- .../matter_idl}/lint/types.py | 20 +- .../matter_idl}/matter_grammar.lark | 0 .../matter_idl}/matter_idl_parser.py | 0 .../matter_idl}/matter_idl_types.py | 0 .../matter_idl}/test_generators.py | 14 +- .../matter_idl}/test_matter_idl_parser.py | 0 .../matter_idl}/test_xml_parser.py | 41 +- .../matter_idl}/tests/available_tests.yaml | 0 .../inputs/cluster_struct_attribute.matter | 0 .../inputs/global_struct_attribute.matter | 0 .../inputs/large_all_clusters_app.matter | 0 .../tests/inputs/large_lighting_app.matter | 0 .../tests/inputs/optional_argument.matter | 0 .../tests/inputs/several_clusters.matter | 0 .../tests/inputs/simple_attribute.matter | 0 .../bridge/BridgeClustersImpl.h | 0 .../bridge/BridgeGlobalStructs.h | 0 .../bridge/DemoClusterServer.h | 0 .../DemoClusterClient-InvokeSubscribeImpl.cpp | 0 .../jni/DemoClusterClient-ReadImpl.cpp | 0 .../bridge/BridgeClustersImpl.h | 0 .../bridge/BridgeGlobalStructs.h | 0 .../bridge/DemoClusterServer.h | 0 .../DemoClusterClient-InvokeSubscribeImpl.cpp | 0 .../jni/DemoClusterClient-ReadImpl.cpp | 0 .../cpp-app/PluginApplicationCallbacks.h | 0 .../cpp-app/callback-stub.cpp | 0 .../cpp-app/PluginApplicationCallbacks.h | 0 .../cpp-app/callback-stub.cpp | 0 .../MyClusterClient-InvokeSubscribeImpl.cpp | 0 .../jni/MyClusterClient-ReadImpl.cpp | 0 .../bridge/BridgeClustersImpl.h | 0 .../bridge/BridgeGlobalStructs.h | 0 .../several_clusters/bridge/FirstServer.h | 0 .../several_clusters/bridge/SecondServer.h | 0 .../outputs/several_clusters/bridge/Third.h | 0 .../several_clusters/bridge/ThirdServer.h | 0 .../cpp-app/PluginApplicationCallbacks.h | 0 .../cpp-app/callback-stub.cpp | 0 .../jni/FirstClient-InvokeSubscribeImpl.cpp | 0 .../jni/FirstClient-ReadImpl.cpp | 0 .../jni/SecondClient-InvokeSubscribeImpl.cpp | 0 .../jni/SecondClient-ReadImpl.cpp | 0 .../jni/ThirdClient-InvokeSubscribeImpl.cpp | 0 .../jni/ThirdClient-ReadImpl.cpp | 0 .../bridge/BridgeClustersImpl.h | 0 .../bridge/BridgeGlobalStructs.h | 0 .../simple_attribute/bridge/MyClusterServer.h | 0 .../MyClusterClient-InvokeSubscribeImpl.cpp | 0 .../jni/MyClusterClient-ReadImpl.cpp | 0 .../matter_idl}/xml_parser.py | 6 +- .../matter_idl}/zapxml/__init__.py | 12 +- .../matter_idl}/zapxml/handlers/__init__.py | 2 +- .../matter_idl}/zapxml/handlers/base.py | 0 .../matter_idl}/zapxml/handlers/context.py | 5 +- .../matter_idl}/zapxml/handlers/handlers.py | 23 +- .../matter_idl}/zapxml/handlers/parsing.py | 2 +- scripts/py_matter_idl/pyproject.toml | 17 + scripts/py_matter_idl/setup.cfg | 36 ++ scripts/{idl => py_matter_idl}/setup.py | 12 +- .../BUILD.gn | 20 +- .../matter_yamltests}/__init__.py | 0 .../matter_yamltests}/constraints.py | 0 .../matter_yamltests}/definitions.py | 56 +-- .../matter_yamltests}/fixes.py | 0 .../matter_yamltests}/parser.py | 0 scripts/py_matter_yamltests/pyproject.toml | 17 + scripts/py_matter_yamltests/setup.cfg | 24 ++ .../setup.py | 12 +- .../test_spec_definitions.py | 358 ++++++++++++++++++ .../test_yaml_parser.py | 7 +- scripts/requirements.txt | 3 +- .../tests/yamltests/test_spec_definitions.py | 291 -------------- 108 files changed, 808 insertions(+), 571 deletions(-) create mode 100644 scripts/common_setup.cfg delete mode 100644 scripts/idl/BUILD.gn delete mode 100644 scripts/idl/files.gni create mode 100644 scripts/py_matter_idl/BUILD.gn create mode 100644 scripts/py_matter_idl/files.gni rename scripts/{idl => py_matter_idl/matter_idl}/README.md (99%) rename scripts/{idl => py_matter_idl/matter_idl}/__init__.py (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/__init__.py (97%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/bridge/BridgeClustersCommon.jinja (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/bridge/BridgeClustersCpp.jinja (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/bridge/BridgeClustersGlobalStructs.jinja (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/bridge/BridgeClustersHeader.jinja (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/bridge/__init__.py (91%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/cpp/__init__.py (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/cpp/application/CallbackStubSource.jinja (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/cpp/application/PluginApplicationCallbacksHeader.jinja (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/cpp/application/__init__.py (84%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/filters.py (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/java/ChipClustersCpp.jinja (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/java/ChipClustersRead.jinja (100%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/java/__init__.py (97%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/registry.py (90%) rename scripts/{idl => py_matter_idl/matter_idl}/generators/types.py (99%) rename scripts/{idl => py_matter_idl/matter_idl}/lint/__init__.py (100%) rename scripts/{idl => py_matter_idl/matter_idl}/lint/lint_rules_grammar.lark (100%) rename scripts/{idl => py_matter_idl/matter_idl}/lint/lint_rules_parser.py (91%) rename scripts/{idl => py_matter_idl/matter_idl}/lint/types.py (92%) rename scripts/{idl => py_matter_idl/matter_idl}/matter_grammar.lark (100%) rename scripts/{idl => py_matter_idl/matter_idl}/matter_idl_parser.py (100%) rename scripts/{idl => py_matter_idl/matter_idl}/matter_idl_types.py (100%) rename scripts/{idl => py_matter_idl/matter_idl}/test_generators.py (93%) rename scripts/{idl => py_matter_idl/matter_idl}/test_matter_idl_parser.py (100%) rename scripts/{idl => py_matter_idl/matter_idl}/test_xml_parser.py (90%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/available_tests.yaml (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/inputs/cluster_struct_attribute.matter (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/inputs/global_struct_attribute.matter (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/inputs/large_all_clusters_app.matter (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/inputs/large_lighting_app.matter (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/inputs/optional_argument.matter (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/inputs/several_clusters.matter (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/inputs/simple_attribute.matter (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/bridge/FirstServer.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/bridge/SecondServer.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/bridge/Third.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/bridge/ThirdServer.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/cpp-app/callback-stub.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/simple_attribute/bridge/MyClusterServer.h (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp (100%) rename scripts/{idl => py_matter_idl/matter_idl}/xml_parser.py (93%) rename scripts/{idl => py_matter_idl/matter_idl}/zapxml/__init__.py (90%) rename scripts/{idl => py_matter_idl/matter_idl}/zapxml/handlers/__init__.py (96%) rename scripts/{idl => py_matter_idl/matter_idl}/zapxml/handlers/base.py (100%) rename scripts/{idl => py_matter_idl/matter_idl}/zapxml/handlers/context.py (95%) rename scripts/{idl => py_matter_idl/matter_idl}/zapxml/handlers/handlers.py (96%) rename scripts/{idl => py_matter_idl/matter_idl}/zapxml/handlers/parsing.py (98%) create mode 100644 scripts/py_matter_idl/pyproject.toml create mode 100644 scripts/py_matter_idl/setup.cfg rename scripts/{idl => py_matter_idl}/setup.py (70%) rename scripts/{tests/yamltests => py_matter_yamltests}/BUILD.gn (72%) rename scripts/{tests/yamltests => py_matter_yamltests/matter_yamltests}/__init__.py (100%) rename scripts/{tests/yamltests => py_matter_yamltests/matter_yamltests}/constraints.py (100%) rename scripts/{tests/yamltests => py_matter_yamltests/matter_yamltests}/definitions.py (82%) rename scripts/{tests/yamltests => py_matter_yamltests/matter_yamltests}/fixes.py (100%) rename scripts/{tests/yamltests => py_matter_yamltests/matter_yamltests}/parser.py (100%) create mode 100644 scripts/py_matter_yamltests/pyproject.toml create mode 100644 scripts/py_matter_yamltests/setup.cfg rename scripts/{tests/yamltests => py_matter_yamltests}/setup.py (68%) create mode 100644 scripts/py_matter_yamltests/test_spec_definitions.py rename scripts/{tests => py_matter_yamltests}/test_yaml_parser.py (92%) delete mode 100644 scripts/tests/yamltests/test_spec_definitions.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 89e8c44d26a37f..3bfcc32bd9da4c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -98,13 +98,13 @@ jobs: if [ "$idl_file" = './examples/window-app/common/window-app.matter' ]; then continue; fi # Test files are intentionally small and not spec-compilant, just parse-compliant - if [ "$idl_file" = "./scripts/idl/tests/inputs/cluster_struct_attribute.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/global_struct_attribute.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/optional_argument.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/several_clusters.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/simple_attribute.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/large_lighting_app.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/large_all_clusters_app.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/cluster_struct_attribute.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/global_struct_attribute.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/optional_argument.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/several_clusters.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/simple_attribute.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/large_lighting_app.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/large_all_clusters_app.matter" ]; then continue; fi ./scripts/run_in_build_env.sh "./scripts/idl_lint.py --log-level warn $idl_file" >/dev/null || exit 1 done diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 7d35cde0db27ff..8f96c75a1e280b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -105,7 +105,7 @@ jobs: # things. run: | ./scripts/run_in_build_env.sh \ - "./scripts/idl/xml_parser.py \ + "./scripts/py_matter_idl/matter_idl/xml_parser.py \ --no-print \ --log-level info \ src/app/zap-templates/zcl/data-model/chip/global-attributes.xml \ diff --git a/.restyled.yaml b/.restyled.yaml index 13d499b2b8967f..75b649d9e4242d 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -69,7 +69,7 @@ exclude: - "third_party/android_deps/gradlew" # gradle wrapper generated file - "src/controller/python/chip/clusters/Objects.py" # generated file, no point to restyle - "src/controller/python/chip/clusters/CHIPClusters.py" # generated file, no point to restyle - - "scripts/idl/tests/outputs/**/*" # Matches generated output 1:1 + - "scripts/py_matter_idl/matter_idl/tests/outputs/**/*" # Matches generated output 1:1 - "examples/chef/sample_app_util/test_files/*.yaml" - "examples/chef/zzz_generated/**/*" - "examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/**/*" diff --git a/BUILD.gn b/BUILD.gn index e4e1b8e02da1b5..23bc58926aac8d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -120,7 +120,10 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { } pw_python_pip_install("pip_install_matter_packages") { - packages = [ "//examples/common/pigweed/rpc_console:chip_rpc_distribution" ] + packages = [ + "//examples/common/pigweed/rpc_console:chip_rpc_distribution", + "//scripts:yamltests_distribution", + ] } # Python packages installed during bootstrap. @@ -260,7 +263,8 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { "//:fake_platform_tests", "//examples/chef:chef.tests", "//scripts/build:build_examples.tests", - "//scripts/idl:idl.tests", + "//scripts/py_matter_idl:matter_idl.tests", + "//scripts/py_matter_yamltests:matter_yamltests.tests", "//src:tests_run", ] } diff --git a/build/chip/chip_codegen.gni b/build/chip/chip_codegen.gni index 533cd02b27ea76..d59277ae1e484d 100644 --- a/build/chip/chip_codegen.gni +++ b/build/chip/chip_codegen.gni @@ -17,7 +17,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/pigweed.gni") import("$dir_pw_build/python.gni") -import("${chip_root}/scripts/idl/files.gni") +import("${chip_root}/scripts/py_matter_idl/files.gni") declare_args() { # Location where code has been pre-generated diff --git a/docs/code_generation.md b/docs/code_generation.md index 7deed7ba05fb1a..c676fa887ebd7c 100644 --- a/docs/code_generation.md +++ b/docs/code_generation.md @@ -84,9 +84,10 @@ specific codegen. ### `*.matter` parsing and codegen `*.matter` files are both human and machine readable. Code that can process -these files is available at `scripts/idl` and `scripts/codegen.py`. You can read -the [scripts/idl/README.md](../scripts/idl/README.md) for details of how things -work. +these files is available at `scripts/py_matter_idl` and `scripts/codegen.py`. +You can read the +[scripts/py_matter_idl/matter_idl/README.md](../scripts/py_matter_idl/matter_idl/README.md) +for details of how things work. `scripts/codegen.py` can generate various outputs based on an input `*.matter` file. @@ -198,7 +199,7 @@ Code pre-generation can be used: generation at build time or to save the code generation time at the expense of running code generation for every possible zap/generation type - To check changes in generated code across versions, beyond the comparisons - of golden image tests in `scripts/idl/tests` + of golden image tests in `scripts/py_matter_idl/matter_idl/tests` The script to trigger code pre-generation is `scripts/code_pregenerate.py` and requires the pre-generation output directory as an argument diff --git a/scripts/BUILD.gn b/scripts/BUILD.gn index 141e262d5db3e4..878102414b89ce 100644 --- a/scripts/BUILD.gn +++ b/scripts/BUILD.gn @@ -12,6 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + import("//build_overrides/pigweed.gni") +import("$dir_pw_build/python_dist.gni") -import("$dir_pw_build/python.gni") +# This target creates a single Python package and wheel for yamltests. It will +# merge all Python dependencies Matter. The output is located in: +# out/obj/yamltests_distribution/ <- source files here +# out/obj/yamltests_distribution._build_wheel/yamltests-0.0.1-py3-none-any.whl +pw_python_distribution("yamltests_distribution") { + packages = [ "${chip_root}/scripts/py_matter_yamltests:matter_yamltests" ] + generate_setup_cfg = { + common_config_file = "common_setup.cfg" + include_default_pyproject_file = true + append_date_to_version = true + } +} diff --git a/scripts/codegen.py b/scripts/codegen.py index 67898af6ebce5f..5d824be7bfebf8 100755 --- a/scripts/codegen.py +++ b/scripts/codegen.py @@ -25,14 +25,14 @@ _has_coloredlogs = False try: - from idl.matter_idl_parser import CreateParser + from matter_idl.matter_idl_parser import CreateParser except: import os - sys.path.append(os.path.abspath(os.path.dirname(__file__))) - from idl.matter_idl_parser import CreateParser + sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'py_matter_idl'))) + from matter_idl.matter_idl_parser import CreateParser -from idl.generators import FileSystemGeneratorStorage, GeneratorStorage -from idl.generators.registry import CodeGenerator, GENERATORS +from matter_idl.generators import FileSystemGeneratorStorage, GeneratorStorage +from matter_idl.generators.registry import CodeGenerator, GENERATORS class ListGeneratedFilesStorage(GeneratorStorage): diff --git a/scripts/common_setup.cfg b/scripts/common_setup.cfg new file mode 100644 index 00000000000000..76987454de4736 --- /dev/null +++ b/scripts/common_setup.cfg @@ -0,0 +1,19 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# 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. +[metadata] +name = matter_yamltests +version = 0.0.1 + +[options] +zip_safe = False diff --git a/scripts/idl/BUILD.gn b/scripts/idl/BUILD.gn deleted file mode 100644 index 324ed3a737bbf0..00000000000000 --- a/scripts/idl/BUILD.gn +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (c) 2022 Project CHIP Authors -# -# 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. - -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") - -import("//build_overrides/pigweed.gni") -import("$dir_pw_build/python.gni") - -import("${chip_root}/scripts/idl/files.gni") - -pw_python_package("idl") { - setup = [ "setup.py" ] - inputs = matter_idl_generator_templates - inputs += [ - # Dependency grammar - "matter_grammar.lark", - - # Unit test data - "tests/available_tests.yaml", - "tests/inputs/cluster_struct_attribute.matter", - "tests/inputs/global_struct_attribute.matter", - "tests/inputs/optional_argument.matter", - "tests/inputs/several_clusters.matter", - "tests/inputs/simple_attribute.matter", - "tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h", - "tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h", - "tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h", - "tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp", - "tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp", - "tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h", - "tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h", - "tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h", - "tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp", - "tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp", - "tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp", - "tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp", - "tests/outputs/several_clusters/bridge/BridgeClustersImpl.h", - "tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h", - "tests/outputs/several_clusters/bridge/FirstServer.h", - "tests/outputs/several_clusters/bridge/SecondServer.h", - "tests/outputs/several_clusters/bridge/Third.h", - "tests/outputs/several_clusters/bridge/ThirdServer.h", - "tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp", - "tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp", - "tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp", - "tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp", - "tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp", - "tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp", - "tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h", - "tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h", - "tests/outputs/simple_attribute/bridge/MyClusterServer.h", - "tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp", - "tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp", - ] - - sources = matter_idl_generator_sources - - tests = [ - "test_matter_idl_parser.py", - "test_generators.py", - "test_xml_parser.py", - ] - - # TODO: at a future time consider enabling all (* or missing) here to get - # pylint checking these files - static_analysis = [] -} diff --git a/scripts/idl/files.gni b/scripts/idl/files.gni deleted file mode 100644 index 997f1eab8b06c5..00000000000000 --- a/scripts/idl/files.gni +++ /dev/null @@ -1,37 +0,0 @@ -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") - -# Templates used for generation -matter_idl_generator_templates = [ - "${chip_root}/scripts/idl/generators/bridge/BridgeClustersCpp.jinja", - "${chip_root}/scripts/idl/generators/bridge/BridgeClustersCommon.jinja", - "${chip_root}/scripts/idl/generators/bridge/BridgeClustersGlobalStructs.jinja", - "${chip_root}/scripts/idl/generators/java/ChipClustersCpp.jinja", - "${chip_root}/scripts/idl/generators/java/ChipClustersRead.jinja", - "${chip_root}/scripts/idl/generators/cpp/application/CallbackStubSource.jinja", - "${chip_root}/scripts/idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja", -] - -matter_idl_generator_sources = [ - "${chip_root}/scripts/idl/__init__.py", - "${chip_root}/scripts/idl/generators/__init__.py", - "${chip_root}/scripts/idl/generators/bridge/__init__.py", - "${chip_root}/scripts/idl/generators/cpp/__init__.py", - "${chip_root}/scripts/idl/generators/cpp/application/__init__.py", - "${chip_root}/scripts/idl/generators/filters.py", - "${chip_root}/scripts/idl/generators/java/__init__.py", - "${chip_root}/scripts/idl/generators/types.py", - "${chip_root}/scripts/idl/matter_idl_parser.py", - "${chip_root}/scripts/idl/matter_idl_types.py", - "${chip_root}/scripts/idl/xml_parser.py", - "${chip_root}/scripts/idl/zapxml/__init__.py", - "${chip_root}/scripts/idl/zapxml/handlers/__init__.py", - "${chip_root}/scripts/idl/zapxml/handlers/base.py", - "${chip_root}/scripts/idl/zapxml/handlers/context.py", - "${chip_root}/scripts/idl/zapxml/handlers/handlers.py", - "${chip_root}/scripts/idl/zapxml/handlers/parsing.py", -] - -# All the files that the matter idl infrastructure will use -matter_idl_generator_files = - matter_idl_generator_templates + matter_idl_generator_sources diff --git a/scripts/idl_lint.py b/scripts/idl_lint.py index 83f606201f8bac..a9271afbd73fc0 100755 --- a/scripts/idl_lint.py +++ b/scripts/idl_lint.py @@ -23,12 +23,12 @@ from typing import List, Optional try: - from idl import matter_idl_parser + from matter_idl import matter_idl_parser except: - sys.path.append(os.path.abspath(os.path.dirname(__file__))) - from idl import matter_idl_parser + sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'py_matter_idl'))) + from matter_idl import matter_idl_parser -import idl.lint +import matter_idl.lint # Supported log levels, mapping string values required for argument # parsing into logging constants @@ -64,7 +64,7 @@ def main(log_level, rules, idl_path): lint_rules = [] logging.info("Loading rules from %s" % rules) - lint_rules.extend(idl.lint.CreateParser(rules).parse()) + lint_rules.extend(matter_idl.lint.CreateParser(rules).parse()) logging.info("Parsing idl from %s" % idl_path) idl_tree = matter_idl_parser.CreateParser().parse(open(idl_path, "rt").read(), file_name=idl_path) diff --git a/scripts/py_matter_idl/BUILD.gn b/scripts/py_matter_idl/BUILD.gn new file mode 100644 index 00000000000000..7e3254573e9cac --- /dev/null +++ b/scripts/py_matter_idl/BUILD.gn @@ -0,0 +1,83 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# 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. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +import("//build_overrides/pigweed.gni") +import("$dir_pw_build/python.gni") + +import("${chip_root}/scripts/py_matter_idl/files.gni") + +pw_python_package("matter_idl") { + setup = [ + "setup.py", + "setup.cfg", + "pyproject.toml", + ] + inputs = matter_idl_generator_templates + inputs += [ + # Dependency grammar + "matter_idl/matter_grammar.lark", + + # Unit test data + "matter_idl/tests/available_tests.yaml", + "matter_idl/tests/inputs/cluster_struct_attribute.matter", + "matter_idl/tests/inputs/global_struct_attribute.matter", + "matter_idl/tests/inputs/optional_argument.matter", + "matter_idl/tests/inputs/several_clusters.matter", + "matter_idl/tests/inputs/simple_attribute.matter", + "matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h", + "matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h", + "matter_idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h", + "matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp", + "matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h", + "matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h", + "matter_idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h", + "matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp", + "matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp", + "matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h", + "matter_idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h", + "matter_idl/tests/outputs/several_clusters/bridge/FirstServer.h", + "matter_idl/tests/outputs/several_clusters/bridge/SecondServer.h", + "matter_idl/tests/outputs/several_clusters/bridge/Third.h", + "matter_idl/tests/outputs/several_clusters/bridge/ThirdServer.h", + "matter_idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp", + "matter_idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp", + "matter_idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp", + "matter_idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h", + "matter_idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h", + "matter_idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h", + "matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp", + "matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp", + ] + + sources = matter_idl_generator_sources + + tests = [ + "matter_idl/test_matter_idl_parser.py", + "matter_idl/test_generators.py", + "matter_idl/test_xml_parser.py", + ] + + # TODO: at a future time consider enabling all (* or missing) here to get + # pylint checking these files + static_analysis = [] +} diff --git a/scripts/py_matter_idl/files.gni b/scripts/py_matter_idl/files.gni new file mode 100644 index 00000000000000..aa22f705caff2d --- /dev/null +++ b/scripts/py_matter_idl/files.gni @@ -0,0 +1,37 @@ +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +# Templates used for generation +matter_idl_generator_templates = [ + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCpp.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCommon.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersGlobalStructs.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersCpp.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersRead.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/CallbackStubSource.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja", +] + +matter_idl_generator_sources = [ + "${chip_root}/scripts/py_matter_idl/matter_idl/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/filters.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/java/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/types.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/matter_idl_parser.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/matter_idl_types.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/xml_parser.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/base.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py", +] + +# All the files that the matter idl infrastructure will use +matter_idl_generator_files = + matter_idl_generator_templates + matter_idl_generator_sources diff --git a/scripts/idl/README.md b/scripts/py_matter_idl/matter_idl/README.md similarity index 99% rename from scripts/idl/README.md rename to scripts/py_matter_idl/matter_idl/README.md index ac3ddf517f8277..e46fb4d00c853a 100644 --- a/scripts/idl/README.md +++ b/scripts/py_matter_idl/matter_idl/README.md @@ -184,7 +184,7 @@ endpoint 0 { ## Parsing of IDLs -IDL parsing is done within the `idl` python package (this is the current +IDL parsing is done within the `matter_idl` python package (this is the current directory of this README). Most of the heavy lifting is done by the lark using [matter_grammar.lark](./matter_grammar.lark), which is then turned into an AST: diff --git a/scripts/idl/__init__.py b/scripts/py_matter_idl/matter_idl/__init__.py similarity index 100% rename from scripts/idl/__init__.py rename to scripts/py_matter_idl/matter_idl/__init__.py diff --git a/scripts/idl/generators/__init__.py b/scripts/py_matter_idl/matter_idl/generators/__init__.py similarity index 97% rename from scripts/idl/generators/__init__.py rename to scripts/py_matter_idl/matter_idl/generators/__init__.py index 1adbb6d4d0071b..779c5ad800ace2 100644 --- a/scripts/idl/generators/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/__init__.py @@ -18,7 +18,7 @@ import jinja2 from typing import Dict -from idl.matter_idl_types import Idl +from matter_idl.matter_idl_types import Idl from .filters import RegisterCommonFilters @@ -113,7 +113,8 @@ def __init__(self, storage: GeneratorStorage, idl: Idl): self.storage = storage self.idl = idl self.jinja_env = jinja2.Environment( - loader=jinja2.FileSystemLoader(searchpath=os.path.dirname(__file__)), + loader=jinja2.FileSystemLoader( + searchpath=os.path.dirname(__file__)), keep_trailing_newline=True) self.dry_run = False diff --git a/scripts/idl/generators/bridge/BridgeClustersCommon.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCommon.jinja similarity index 100% rename from scripts/idl/generators/bridge/BridgeClustersCommon.jinja rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCommon.jinja diff --git a/scripts/idl/generators/bridge/BridgeClustersCpp.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCpp.jinja similarity index 100% rename from scripts/idl/generators/bridge/BridgeClustersCpp.jinja rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCpp.jinja diff --git a/scripts/idl/generators/bridge/BridgeClustersGlobalStructs.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersGlobalStructs.jinja similarity index 100% rename from scripts/idl/generators/bridge/BridgeClustersGlobalStructs.jinja rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersGlobalStructs.jinja diff --git a/scripts/idl/generators/bridge/BridgeClustersHeader.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersHeader.jinja similarity index 100% rename from scripts/idl/generators/bridge/BridgeClustersHeader.jinja rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersHeader.jinja diff --git a/scripts/idl/generators/bridge/__init__.py b/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py similarity index 91% rename from scripts/idl/generators/bridge/__init__.py rename to scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py index 7a43c9e802b88a..149e6cf33e1d04 100644 --- a/scripts/idl/generators/bridge/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py @@ -17,11 +17,11 @@ import logging import re -from idl.generators import CodeGenerator, GeneratorStorage -from idl.matter_idl_types import Idl, Field, Attribute, Cluster, ClusterSide -from idl import matter_idl_types -from idl.generators.types import (ParseDataType, BasicString, BasicInteger, FundamentalType, - IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext) +from matter_idl.generators import CodeGenerator, GeneratorStorage +from matter_idl.matter_idl_types import Idl, Field, Attribute, Cluster, ClusterSide +from matter_idl import matter_idl_types +from matter_idl.generators.types import (ParseDataType, BasicString, BasicInteger, FundamentalType, + IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext) from typing import Union, List, Set @@ -74,14 +74,16 @@ def get_field_info(definition: Field, cluster: Cluster, idl: Idl): def get_raw_size_and_type(attr: Attribute, cluster: Cluster, idl: Idl): - container, cType, size, matterType = get_field_info(attr.definition, cluster, idl) + container, cType, size, matterType = get_field_info( + attr.definition, cluster, idl) if attr.definition.is_list: return 'ZCL_ARRAY_ATTRIBUTE_TYPE, {}'.format(size) return '{}, {}'.format(matterType, size) def get_field_type(definition: Field, cluster: Cluster, idl: Idl): - container, cType, size, matterType = get_field_info(definition, cluster, idl) + container, cType, size, matterType = get_field_info( + definition, cluster, idl) if container == 'OctetString': return 'std::string' if definition.is_list: diff --git a/scripts/idl/generators/cpp/__init__.py b/scripts/py_matter_idl/matter_idl/generators/cpp/__init__.py similarity index 100% rename from scripts/idl/generators/cpp/__init__.py rename to scripts/py_matter_idl/matter_idl/generators/cpp/__init__.py diff --git a/scripts/idl/generators/cpp/application/CallbackStubSource.jinja b/scripts/py_matter_idl/matter_idl/generators/cpp/application/CallbackStubSource.jinja similarity index 100% rename from scripts/idl/generators/cpp/application/CallbackStubSource.jinja rename to scripts/py_matter_idl/matter_idl/generators/cpp/application/CallbackStubSource.jinja diff --git a/scripts/idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja b/scripts/py_matter_idl/matter_idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja similarity index 100% rename from scripts/idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja rename to scripts/py_matter_idl/matter_idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja diff --git a/scripts/idl/generators/cpp/application/__init__.py b/scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py similarity index 84% rename from scripts/idl/generators/cpp/application/__init__.py rename to scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py index 4a7a3b0035ce75..ead462b2c33cb0 100644 --- a/scripts/idl/generators/cpp/application/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from idl.generators import CodeGenerator, GeneratorStorage -from idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType -from idl import matter_idl_types -from idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext +from matter_idl.generators import CodeGenerator, GeneratorStorage +from matter_idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType +from matter_idl import matter_idl_types +from matter_idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext from typing import Union, List, Set from stringcase import capitalcase diff --git a/scripts/idl/generators/filters.py b/scripts/py_matter_idl/matter_idl/generators/filters.py similarity index 100% rename from scripts/idl/generators/filters.py rename to scripts/py_matter_idl/matter_idl/generators/filters.py diff --git a/scripts/idl/generators/java/ChipClustersCpp.jinja b/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersCpp.jinja similarity index 100% rename from scripts/idl/generators/java/ChipClustersCpp.jinja rename to scripts/py_matter_idl/matter_idl/generators/java/ChipClustersCpp.jinja diff --git a/scripts/idl/generators/java/ChipClustersRead.jinja b/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersRead.jinja similarity index 100% rename from scripts/idl/generators/java/ChipClustersRead.jinja rename to scripts/py_matter_idl/matter_idl/generators/java/ChipClustersRead.jinja diff --git a/scripts/idl/generators/java/__init__.py b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py similarity index 97% rename from scripts/idl/generators/java/__init__.py rename to scripts/py_matter_idl/matter_idl/generators/java/__init__.py index 6f18e9629304e5..a0f465b4e2f416 100644 --- a/scripts/idl/generators/java/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py @@ -13,10 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from idl.generators import CodeGenerator, GeneratorStorage -from idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType -from idl import matter_idl_types -from idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext +from matter_idl.generators import CodeGenerator, GeneratorStorage +from matter_idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType +from matter_idl import matter_idl_types +from matter_idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext from typing import Union, List, Set from stringcase import capitalcase diff --git a/scripts/idl/generators/registry.py b/scripts/py_matter_idl/matter_idl/generators/registry.py similarity index 90% rename from scripts/idl/generators/registry.py rename to scripts/py_matter_idl/matter_idl/generators/registry.py index 8feeb2c48d1124..5510d3976dc623 100644 --- a/scripts/idl/generators/registry.py +++ b/scripts/py_matter_idl/matter_idl/generators/registry.py @@ -14,9 +14,9 @@ import enum -from idl.generators.java import JavaGenerator -from idl.generators.bridge import BridgeGenerator -from idl.generators.cpp.application import CppApplicationGenerator +from matter_idl.generators.java import JavaGenerator +from matter_idl.generators.bridge import BridgeGenerator +from matter_idl.generators.cpp.application import CppApplicationGenerator class CodeGenerator(enum.Enum): diff --git a/scripts/idl/generators/types.py b/scripts/py_matter_idl/matter_idl/generators/types.py similarity index 99% rename from scripts/idl/generators/types.py rename to scripts/py_matter_idl/matter_idl/generators/types.py index b6f216802de0d8..dd7705dc7070f9 100644 --- a/scripts/idl/generators/types.py +++ b/scripts/py_matter_idl/matter_idl/generators/types.py @@ -15,8 +15,8 @@ import logging import enum -from idl.matter_idl_types import DataType -from idl import matter_idl_types # to explicitly say 'Enum' +from matter_idl.matter_idl_types import DataType +from matter_idl import matter_idl_types # to explicitly say 'Enum' from typing import Union, List, Optional from dataclasses import dataclass diff --git a/scripts/idl/lint/__init__.py b/scripts/py_matter_idl/matter_idl/lint/__init__.py similarity index 100% rename from scripts/idl/lint/__init__.py rename to scripts/py_matter_idl/matter_idl/lint/__init__.py diff --git a/scripts/idl/lint/lint_rules_grammar.lark b/scripts/py_matter_idl/matter_idl/lint/lint_rules_grammar.lark similarity index 100% rename from scripts/idl/lint/lint_rules_grammar.lark rename to scripts/py_matter_idl/matter_idl/lint/lint_rules_grammar.lark diff --git a/scripts/idl/lint/lint_rules_parser.py b/scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py similarity index 91% rename from scripts/idl/lint/lint_rules_parser.py rename to scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py index fdd507cdbc383e..18bbb473b7871c 100755 --- a/scripts/idl/lint/lint_rules_parser.py +++ b/scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py @@ -16,8 +16,9 @@ except: import sys - sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "..")) - from idl.lint.types import RequiredAttributesRule, AttributeRequirement, ClusterRequirement, RequiredCommandsRule, ClusterCommandRequirement + sys.path.append(os.path.join(os.path.abspath( + os.path.dirname(__file__)), "..", "..")) + from matter_idl.lint.types import RequiredAttributesRule, AttributeRequirement, ClusterRequirement, RequiredCommandsRule, ClusterCommandRequirement def parseNumberString(n): @@ -90,7 +91,8 @@ def DecodeClusterFromXml(element: xml.etree.ElementTree.Element): if 'optional' in cmd.attrib and cmd.attrib['optional'] == 'true': continue - required_commands.append(RequiredCommand(name=cmd.attrib["name"], code=parseNumberString(cmd.attrib['code']))) + required_commands.append(RequiredCommand( + name=cmd.attrib["name"], code=parseNumberString(cmd.attrib['code']))) return DecodedCluster( name=name, @@ -124,8 +126,10 @@ class LintRulesContext: """ def __init__(self): - self._required_attributes_rule = RequiredAttributesRule("Required attributes") - self._required_commands_rule = RequiredCommandsRule("Required commands") + self._required_attributes_rule = RequiredAttributesRule( + "Required attributes") + self._required_commands_rule = RequiredCommandsRule( + "Required commands") # Map cluster names to the underlying code self._cluster_codes: Mapping[str, int] = {} @@ -146,7 +150,8 @@ def RequireClusterInEndpoint(self, name: str, code: int): name = "ID_%s" % name except ValueError: logging.error("UNKNOWN cluster name %s" % name) - logging.error("Known names: %s" % (",".join(self._cluster_codes.keys()), )) + logging.error("Known names: %s" % + (",".join(self._cluster_codes.keys()), )) return else: cluster_code = self._cluster_codes[name] @@ -237,7 +242,8 @@ def all_endpoint_rule(self, attributes): @v_args(inline=True) def load_xml(self, path): if not os.path.isabs(path): - path = os.path.abspath(os.path.join(os.path.dirname(self.file_name), path)) + path = os.path.abspath(os.path.join( + os.path.dirname(self.file_name), path)) self.context.LoadXml(path) @@ -262,7 +268,8 @@ def __init__(self, parser, file_name: str): self.file_name = file_name def parse(self): - data = LintRulesTransformer(self.file_name).transform(self.parser.parse(open(self.file_name, "rt").read())) + data = LintRulesTransformer(self.file_name).transform( + self.parser.parse(open(self.file_name, "rt").read())) return data diff --git a/scripts/idl/lint/types.py b/scripts/py_matter_idl/matter_idl/lint/types.py similarity index 92% rename from scripts/idl/lint/types.py rename to scripts/py_matter_idl/matter_idl/lint/types.py index 85dfbdeacd0bc3..8ee6a805ec4d4e 100644 --- a/scripts/idl/lint/types.py +++ b/scripts/py_matter_idl/matter_idl/lint/types.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from idl.matter_idl_types import Idl, ParseMetaData, ClusterSide +from matter_idl.matter_idl_types import Idl, ParseMetaData, ClusterSide from abc import ABC, abstractmethod from typing import List, Optional from dataclasses import dataclass, field @@ -40,7 +40,8 @@ class LintError: def __init__(self, text: str, location: Optional[LocationInFile] = None): self.message = text if location: - self.message += " at %s:%d:%d" % (location.file_name, location.line, location.column) + self.message += " at %s:%d:%d" % (location.file_name, + location.line, location.column) def __str__(self): return self.message @@ -84,7 +85,8 @@ def __init__(self, name): self._idl = None def _AddLintError(self, text, location): - self._lint_errors.append(LintError("%s: %s" % (self.name, text), location)) + self._lint_errors.append( + LintError("%s: %s" % (self.name, text), location)) def _ParseLocation(self, meta: Optional[ParseMetaData]) -> Optional[LocationInFile]: """Create a location in the current file that is being parsed. """ @@ -146,11 +148,13 @@ def _ServerClusterDefinition(self, name: str, location: Optional[LocationInFile] c for c in self._idl.clusters if c.name == name and c.side == ClusterSide.SERVER ] if not cluster_definition: - self._AddLintError("Cluster definition for %s not found" % cluster.name, location) + self._AddLintError( + "Cluster definition for %s not found" % cluster.name, location) return None if len(cluster_definition) > 1: - self._AddLintError("Multiple cluster definitions found for %s" % cluster.name, location) + self._AddLintError( + "Multiple cluster definitions found for %s" % cluster.name, location) return None return cluster_definition[0] @@ -161,7 +165,8 @@ def _LintImpl(self): cluster_codes = set() for cluster in endpoint.server_clusters: - cluster_definition = self._ServerClusterDefinition(cluster.name, self._ParseLocation(cluster.parse_meta)) + cluster_definition = self._ServerClusterDefinition( + cluster.name, self._ParseLocation(cluster.parse_meta)) if not cluster_definition: continue @@ -215,7 +220,8 @@ def __init__(self, name): super(RequiredCommandsRule, self).__init__(name) # Maps cluster id to mandatory cluster requirement - self._mandatory_commands: Maping[int, List[ClusterCommandRequirement]] = {} + self._mandatory_commands: Maping[int, + List[ClusterCommandRequirement]] = {} def __repr__(self): result = "RequiredCommandsRule{\n" diff --git a/scripts/idl/matter_grammar.lark b/scripts/py_matter_idl/matter_idl/matter_grammar.lark similarity index 100% rename from scripts/idl/matter_grammar.lark rename to scripts/py_matter_idl/matter_idl/matter_grammar.lark diff --git a/scripts/idl/matter_idl_parser.py b/scripts/py_matter_idl/matter_idl/matter_idl_parser.py similarity index 100% rename from scripts/idl/matter_idl_parser.py rename to scripts/py_matter_idl/matter_idl/matter_idl_parser.py diff --git a/scripts/idl/matter_idl_types.py b/scripts/py_matter_idl/matter_idl/matter_idl_types.py similarity index 100% rename from scripts/idl/matter_idl_types.py rename to scripts/py_matter_idl/matter_idl/matter_idl_types.py diff --git a/scripts/idl/test_generators.py b/scripts/py_matter_idl/matter_idl/test_generators.py similarity index 93% rename from scripts/idl/test_generators.py rename to scripts/py_matter_idl/matter_idl/test_generators.py index 730bfdbc610762..9fb21aecf565dd 100755 --- a/scripts/idl/test_generators.py +++ b/scripts/py_matter_idl/matter_idl/test_generators.py @@ -22,19 +22,19 @@ from dataclasses import dataclass, field try: - from idl.matter_idl_parser import CreateParser + from matter_idl.matter_idl_parser import CreateParser except: import sys sys.path.append(os.path.abspath( os.path.join(os.path.dirname(__file__), '..'))) - from idl.matter_idl_parser import CreateParser + from matter_idl.matter_idl_parser import CreateParser -from idl.matter_idl_types import Idl -from idl.generators.java import JavaGenerator -from idl.generators.bridge import BridgeGenerator -from idl.generators.cpp.application import CppApplicationGenerator -from idl.generators import GeneratorStorage +from matter_idl.matter_idl_types import Idl +from matter_idl.generators.java import JavaGenerator +from matter_idl.generators.bridge import BridgeGenerator +from matter_idl.generators.cpp.application import CppApplicationGenerator +from matter_idl.generators import GeneratorStorage TESTS_DIR = os.path.join(os.path.dirname(__file__), "tests") diff --git a/scripts/idl/test_matter_idl_parser.py b/scripts/py_matter_idl/matter_idl/test_matter_idl_parser.py similarity index 100% rename from scripts/idl/test_matter_idl_parser.py rename to scripts/py_matter_idl/matter_idl/test_matter_idl_parser.py diff --git a/scripts/idl/test_xml_parser.py b/scripts/py_matter_idl/matter_idl/test_xml_parser.py similarity index 90% rename from scripts/idl/test_xml_parser.py rename to scripts/py_matter_idl/matter_idl/test_xml_parser.py index 932a5731d59268..e8645cb0f4043d 100755 --- a/scripts/idl/test_xml_parser.py +++ b/scripts/py_matter_idl/matter_idl/test_xml_parser.py @@ -19,16 +19,17 @@ from typing import Optional, Union, List try: - from idl.matter_idl_types import * - from idl.zapxml import ParseSource, ParseXmls + from matter_idl.matter_idl_types import * + from matter_idl.zapxml import ParseSource, ParseXmls except: import os import sys - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) + sys.path.append(os.path.abspath( + os.path.join(os.path.dirname(__file__), '..'))) - from idl.matter_idl_types import * - from idl.zapxml import ParseSource, ParseXmls + from matter_idl.matter_idl_types import * + from matter_idl.zapxml import ParseSource, ParseXmls def XmlToIdl(what: Union[str, List[str]]) -> Idl: @@ -37,7 +38,8 @@ def XmlToIdl(what: Union[str, List[str]]) -> Idl: sources = [] for idx, txt in enumerate(what): - sources.append(ParseSource(source=io.StringIO(txt), name=("Input %d" % (idx + 1)))) + sources.append(ParseSource(source=io.StringIO( + txt), name=("Input %d" % (idx + 1)))) return ParseXmls(sources, include_meta_data=False) @@ -97,8 +99,10 @@ def testCluster(self): structs=[ Struct(name='GetSomeDataRequest', fields=[ - Field(data_type=DataType(name='INT8U'), code=0, name='firstInput'), - Field(data_type=DataType(name='INT16U'), code=1, name='secondInput') + Field(data_type=DataType( + name='INT8U'), code=0, name='firstInput'), + Field(data_type=DataType( + name='INT16U'), code=1, name='secondInput') ], tag=StructTag.REQUEST), Struct(name='GetSomeDataResponse', @@ -142,8 +146,10 @@ def testBitmap(self): self.assertEqual(idl, Idl(clusters=[ - Cluster(side=ClusterSide.CLIENT, name='Test1', code=1, bitmaps=[bitmap]), - Cluster(side=ClusterSide.CLIENT, name='Test2', code=2, bitmaps=[bitmap]), + Cluster(side=ClusterSide.CLIENT, + name='Test1', code=1, bitmaps=[bitmap]), + Cluster(side=ClusterSide.CLIENT, + name='Test2', code=2, bitmaps=[bitmap]), ])) def testFabricScopedAndSensitive(self): @@ -226,19 +232,23 @@ def testStruct(self): name='SomeStruct', qualities=StructQuality.FABRIC_SCOPED, fields=[ - Field(data_type=DataType(name='int16u'), code=0, name='FirstMember'), - Field(data_type=DataType(name='int32u'), code=1, name='SecondMember') + Field(data_type=DataType(name='int16u'), + code=0, name='FirstMember'), + Field(data_type=DataType(name='int32u'), + code=1, name='SecondMember') ] ) self.assertEqual(idl, Idl(clusters=[ - Cluster(side=ClusterSide.CLIENT, name='Test1', code=10, structs=[struct]), + Cluster(side=ClusterSide.CLIENT, + name='Test1', code=10, structs=[struct]), Cluster(side=ClusterSide.CLIENT, name='Test2', code=20, structs=[struct], attributes=[ Attribute( definition=Field( - data_type=DataType(name='SomeStruct'), + data_type=DataType( + name='SomeStruct'), code=123, name='FabricAttribute', qualities=FieldQuality.NULLABLE @@ -287,7 +297,8 @@ def testSkipsNotProcessedFields(self): attributes=[ Attribute( definition=Field( - data_type=DataType(name='Type'), + data_type=DataType( + name='Type'), code=0, name='Type', ), diff --git a/scripts/idl/tests/available_tests.yaml b/scripts/py_matter_idl/matter_idl/tests/available_tests.yaml similarity index 100% rename from scripts/idl/tests/available_tests.yaml rename to scripts/py_matter_idl/matter_idl/tests/available_tests.yaml diff --git a/scripts/idl/tests/inputs/cluster_struct_attribute.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/cluster_struct_attribute.matter similarity index 100% rename from scripts/idl/tests/inputs/cluster_struct_attribute.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/cluster_struct_attribute.matter diff --git a/scripts/idl/tests/inputs/global_struct_attribute.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/global_struct_attribute.matter similarity index 100% rename from scripts/idl/tests/inputs/global_struct_attribute.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/global_struct_attribute.matter diff --git a/scripts/idl/tests/inputs/large_all_clusters_app.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/large_all_clusters_app.matter similarity index 100% rename from scripts/idl/tests/inputs/large_all_clusters_app.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/large_all_clusters_app.matter diff --git a/scripts/idl/tests/inputs/large_lighting_app.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/large_lighting_app.matter similarity index 100% rename from scripts/idl/tests/inputs/large_lighting_app.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/large_lighting_app.matter diff --git a/scripts/idl/tests/inputs/optional_argument.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/optional_argument.matter similarity index 100% rename from scripts/idl/tests/inputs/optional_argument.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/optional_argument.matter diff --git a/scripts/idl/tests/inputs/several_clusters.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/several_clusters.matter similarity index 100% rename from scripts/idl/tests/inputs/several_clusters.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/several_clusters.matter diff --git a/scripts/idl/tests/inputs/simple_attribute.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/simple_attribute.matter similarity index 100% rename from scripts/idl/tests/inputs/simple_attribute.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/simple_attribute.matter diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h similarity index 100% rename from scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h similarity index 100% rename from scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h similarity index 100% rename from scripts/idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h similarity index 100% rename from scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h diff --git a/scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h similarity index 100% rename from scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h diff --git a/scripts/idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h similarity index 100% rename from scripts/idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h diff --git a/scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h b/scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h similarity index 100% rename from scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h diff --git a/scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp similarity index 100% rename from scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp diff --git a/scripts/idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h b/scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h similarity index 100% rename from scripts/idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h diff --git a/scripts/idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp similarity index 100% rename from scripts/idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp diff --git a/scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/FirstServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/FirstServer.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/FirstServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/FirstServer.h diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/SecondServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/SecondServer.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/SecondServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/SecondServer.h diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/Third.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/Third.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/Third.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/Third.h diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/ThirdServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/ThirdServer.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/ThirdServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/ThirdServer.h diff --git a/scripts/idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h diff --git a/scripts/idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h similarity index 100% rename from scripts/idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h diff --git a/scripts/idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h similarity index 100% rename from scripts/idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h diff --git a/scripts/idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h similarity index 100% rename from scripts/idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h diff --git a/scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp diff --git a/scripts/idl/xml_parser.py b/scripts/py_matter_idl/matter_idl/xml_parser.py similarity index 93% rename from scripts/idl/xml_parser.py rename to scripts/py_matter_idl/matter_idl/xml_parser.py index f2955c973ef632..5ef145ee377462 100755 --- a/scripts/idl/xml_parser.py +++ b/scripts/py_matter_idl/matter_idl/xml_parser.py @@ -21,15 +21,15 @@ import xml.sax.handler try: - from idl.matter_idl_types import Idl + from matter_idl.matter_idl_types import Idl except: import sys sys.path.append(os.path.abspath( os.path.join(os.path.dirname(__file__), '..'))) - from idl.matter_idl_types import Idl + from matter_idl.matter_idl_types import Idl -from idl.zapxml import ParseSource, ParseXmls +from matter_idl.zapxml import ParseSource, ParseXmls if __name__ == '__main__': diff --git a/scripts/idl/zapxml/__init__.py b/scripts/py_matter_idl/matter_idl/zapxml/__init__.py similarity index 90% rename from scripts/idl/zapxml/__init__.py rename to scripts/py_matter_idl/matter_idl/zapxml/__init__.py index 332d1c244bea3b..41b31b452ae066 100644 --- a/scripts/idl/zapxml/__init__.py +++ b/scripts/py_matter_idl/matter_idl/zapxml/__init__.py @@ -19,8 +19,8 @@ from dataclasses import dataclass from typing import Optional, Union, List -from idl.zapxml.handlers import Context, ZapXmlHandler -from idl.matter_idl_types import Idl +from matter_idl.zapxml.handlers import Context, ZapXmlHandler +from matter_idl.matter_idl_types import Idl class ParseHandler(xml.sax.handler.ContentHandler): @@ -32,7 +32,7 @@ class ParseHandler(xml.sax.handler.ContentHandler): - sets up parsing location within the context - keeps track of ParsePath - Overall converts a python SAX handler into idl.zapxml.handlers + Overall converts a python SAX handler into matter_idl.zapxml.handlers """ def __init__(self, include_meta_data=True): @@ -66,7 +66,8 @@ def endDocument(self): def startElement(self, name: str, attrs): logging.debug("ELEMENT START: %r / %r" % (name, attrs)) self._context.path.push(name) - self._processing_stack.append(self._processing_stack[-1].GetNextProcessor(name, attrs)) + self._processing_stack.append( + self._processing_stack[-1].GetNextProcessor(name, attrs)) def endElement(self, name: str): logging.debug("ELEMENT END: %r" % name) @@ -89,7 +90,8 @@ class ParseSource: Allows for named data sources to be parsed. """ source: Union[str, typing.IO] # filename or stream - name: Optional[str] = None # actual filename to use, None if the source is a filename already + # actual filename to use, None if the source is a filename already + name: Optional[str] = None @ property def source_file_name(self): diff --git a/scripts/idl/zapxml/handlers/__init__.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py similarity index 96% rename from scripts/idl/zapxml/handlers/__init__.py rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py index 7a6bfa04682921..3745954a195cfd 100644 --- a/scripts/idl/zapxml/handlers/__init__.py +++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py @@ -16,7 +16,7 @@ from .context import Context from .handlers import ConfiguratorHandler -from idl.matter_idl_types import Idl +from matter_idl.matter_idl_types import Idl class ZapXmlHandler(BaseHandler): diff --git a/scripts/idl/zapxml/handlers/base.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/base.py similarity index 100% rename from scripts/idl/zapxml/handlers/base.py rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/base.py diff --git a/scripts/idl/zapxml/handlers/context.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py similarity index 95% rename from scripts/idl/zapxml/handlers/context.py rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py index 2d82153d76d959..b8fd748dfdcfd2 100644 --- a/scripts/idl/zapxml/handlers/context.py +++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py @@ -15,7 +15,7 @@ import logging import xml.sax.xmlreader -from idl.matter_idl_types import Idl, ParseMetaData, Attribute +from matter_idl.matter_idl_types import Idl, ParseMetaData, Attribute from typing import Optional, List @@ -104,7 +104,8 @@ def AddGlobalAttribute(self, attribute: Attribute): # NOTE: this may get added several times as both 'client' and 'server' # however matter should not differentiate between the two code = attribute.definition.code - logging.info('Adding global attribute 0x%X (%d): %s' % (code, code, attribute.definition.name)) + logging.info('Adding global attribute 0x%X (%d): %s' % + (code, code, attribute.definition.name)) self._global_attributes[code] = attribute diff --git a/scripts/idl/zapxml/handlers/handlers.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py similarity index 96% rename from scripts/idl/zapxml/handlers/handlers.py rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py index 313fc61e8cdbb7..f1396627247a36 100644 --- a/scripts/idl/zapxml/handlers/handlers.py +++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py @@ -14,7 +14,7 @@ import logging -from idl.matter_idl_types import * +from matter_idl.matter_idl_types import * from typing import Optional, Union, List from .context import Context, IdlPostProcessor @@ -245,7 +245,8 @@ class EnumHandler(BaseHandler, IdlPostProcessor): def __init__(self, context: Context, attrs): super().__init__(context) self._cluster_code = None # if set, enum belongs to a specific cluster - self._enum = Enum(name=attrs['name'], base_type=attrs['type'], entries=[]) + self._enum = Enum(name=attrs['name'], + base_type=attrs['type'], entries=[]) def GetNextProcessor(self, name, attrs): if name.lower() == 'item': @@ -256,7 +257,8 @@ def GetNextProcessor(self, name, attrs): return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) elif name.lower() == 'cluster': if self._cluster_code is not None: - raise Exception('Multiple cluster codes for enum %s' % self._enum.name) + raise Exception( + 'Multiple cluster codes for enum %s' % self._enum.name) self._cluster_code = ParseInt(attrs['code']) return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) else: @@ -290,7 +292,8 @@ class BitmapHandler(BaseHandler): def __init__(self, context: Context, attrs): super().__init__(context) self._cluster_codes = set() - self._bitmap = Bitmap(name=attrs['name'], base_type=attrs['type'], entries=[]) + self._bitmap = Bitmap( + name=attrs['name'], base_type=attrs['type'], entries=[]) def GetNextProcessor(self, name, attrs): if name.lower() == 'cluster': @@ -410,7 +413,8 @@ def GetNextProcessor(self, name: str, attrs): if self._command: self._command.invokeacl = AttrsToAccessPrivilege(attrs) else: - logging.warning("Ignored access role for reply %r" % self._struct) + logging.warning( + "Ignored access role for reply %r" % self._struct) return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) elif name.lower() == 'arg': self._struct.fields.append(self.GetArgumentField(attrs)) @@ -444,13 +448,15 @@ def GetNextProcessor(self, name: str, attrs): if name.lower() == 'featurebit': # It is uncler what featurebits mean. likely a bitmap should be created # here, however only one such example exists currently: door-lock-cluster.xml - logging.info('Ignoring featurebit tag for global attribute 0x%X (%d)' % (self._code, self._code)) + logging.info('Ignoring featurebit tag for global attribute 0x%X (%d)' % ( + self._code, self._code)) return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) else: return BaseHandler(self.context) def EndProcessing(self): - self._cluster.attributes.append(self.context.GetGlobalAttribute(self._code)) + self._cluster.attributes.append( + self.context.GetGlobalAttribute(self._code)) class ClusterHandler(BaseHandler): @@ -566,7 +572,8 @@ def GetNextProcessor(self, name, attrs): if attrs['side'].lower() == 'client': # We expect to also have 'server' equivalent, so ignore client # side attributes - logging.debug('Ignoring global client-side attribute %s' % (attrs['code'])) + logging.debug( + 'Ignoring global client-side attribute %s' % (attrs['code'])) return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) return GlobalAttributeHandler(self.context, AttrsToAttribute(attrs)) diff --git a/scripts/idl/zapxml/handlers/parsing.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py similarity index 98% rename from scripts/idl/zapxml/handlers/parsing.py rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py index f9315f3dab6875..40553edc0d4d1e 100644 --- a/scripts/idl/zapxml/handlers/parsing.py +++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from idl.matter_idl_types import * +from matter_idl.matter_idl_types import * def ParseInt(value: str) -> int: diff --git a/scripts/py_matter_idl/pyproject.toml b/scripts/py_matter_idl/pyproject.toml new file mode 100644 index 00000000000000..ab9c08adaab8b5 --- /dev/null +++ b/scripts/py_matter_idl/pyproject.toml @@ -0,0 +1,17 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# 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. + +[build-system] +requires = ['setuptools', 'wheel'] +build-backend = 'setuptools.build_meta' diff --git a/scripts/py_matter_idl/setup.cfg b/scripts/py_matter_idl/setup.cfg new file mode 100644 index 00000000000000..91e84f82ca8990 --- /dev/null +++ b/scripts/py_matter_idl/setup.cfg @@ -0,0 +1,36 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# 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. + +[metadata] +name = matter_idl +version = 0.0.1 +author = Project CHIP Authors +description = Parse matter idl files + +[options] +packages = find: +zip_safe = False + +[options.package_data] +matter_idl = + lint/lint_rules_grammar.lark + matter_grammar.lark + generators/java/ChipClustersRead.jinja + generators/java/ChipClustersCpp.jinja + generators/cpp/application/CallbackStubSource.jinja + generators/cpp/application/PluginApplicationCallbacksHeader.jinja + generators/bridge/BridgeClustersHeader.jinja + generators/bridge/BridgeClustersCommon.jinja + generators/bridge/BridgeClustersCpp.jinja + generators/bridge/BridgeClustersGlobalStructs.jinja diff --git a/scripts/idl/setup.py b/scripts/py_matter_idl/setup.py similarity index 70% rename from scripts/idl/setup.py rename to scripts/py_matter_idl/setup.py index 4566792c40074a..5c10e05ae39916 100644 --- a/scripts/idl/setup.py +++ b/scripts/py_matter_idl/setup.py @@ -13,16 +13,8 @@ # limitations under the License. -"""The idl package.""" +"""The matter_idl package.""" import setuptools # type: ignore -setuptools.setup( - name='idl', - version='0.0.1', - author='Project CHIP Authors', - description='Parse matter idl files', - packages=setuptools.find_packages(), - package_data={'idl': ['py.typed']}, - zip_safe=False, -) +setuptools.setup() # Package definition in setup.cfg diff --git a/scripts/tests/yamltests/BUILD.gn b/scripts/py_matter_yamltests/BUILD.gn similarity index 72% rename from scripts/tests/yamltests/BUILD.gn rename to scripts/py_matter_yamltests/BUILD.gn index 2f9a49c0744181..88ba5a41b1cc19 100644 --- a/scripts/tests/yamltests/BUILD.gn +++ b/scripts/py_matter_yamltests/BUILD.gn @@ -18,18 +18,22 @@ import("//build_overrides/chip.gni") import("//build_overrides/pigweed.gni") import("$dir_pw_build/python.gni") -pw_python_package("yamltests") { - setup = [ "setup.py" ] +pw_python_package("matter_yamltests") { + setup = [ + "setup.py", + "setup.cfg", + "pyproject.toml", + ] sources = [ - "__init__.py", - "constraints.py", - "definitions.py", - "fixes.py", - "parser.py", + "matter_yamltests/__init__.py", + "matter_yamltests/constraints.py", + "matter_yamltests/definitions.py", + "matter_yamltests/fixes.py", + "matter_yamltests/parser.py", ] - python_deps = [ "${chip_root}/scripts/idl" ] + python_deps = [ "${chip_root}/scripts/py_matter_idl:matter_idl" ] tests = [ "test_spec_definitions.py" ] diff --git a/scripts/tests/yamltests/__init__.py b/scripts/py_matter_yamltests/matter_yamltests/__init__.py similarity index 100% rename from scripts/tests/yamltests/__init__.py rename to scripts/py_matter_yamltests/matter_yamltests/__init__.py diff --git a/scripts/tests/yamltests/constraints.py b/scripts/py_matter_yamltests/matter_yamltests/constraints.py similarity index 100% rename from scripts/tests/yamltests/constraints.py rename to scripts/py_matter_yamltests/matter_yamltests/constraints.py diff --git a/scripts/tests/yamltests/definitions.py b/scripts/py_matter_yamltests/matter_yamltests/definitions.py similarity index 82% rename from scripts/tests/yamltests/definitions.py rename to scripts/py_matter_yamltests/matter_yamltests/definitions.py index 006704993d7bab..f4b39b134e3f1a 100644 --- a/scripts/tests/yamltests/definitions.py +++ b/scripts/py_matter_yamltests/matter_yamltests/definitions.py @@ -16,16 +16,8 @@ from typing import List import enum -try: - from idl.zapxml import ParseSource, ParseXmls - from idl.matter_idl_types import * -except: - import os - import sys - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) - - from idl.zapxml import ParseSource, ParseXmls - from idl.matter_idl_types import * +from matter_idl.zapxml import ParseSource, ParseXmls +from matter_idl.matter_idl_types import * class _ItemType(enum.Enum): @@ -66,23 +58,31 @@ def __init__(self, sources: List[ParseSource]): self.__clusters_by_id[code] = cluster self.__commands_by_id[code] = {c.code: c for c in cluster.commands} self.__responses_by_id[code] = {} - self.__attributes_by_id[code] = {a.definition.code: a for a in cluster.attributes} + self.__attributes_by_id[code] = { + a.definition.code: a for a in cluster.attributes} self.__events_by_id[code] = {e.code: e for e in cluster.events} self.__clusters_by_name[name] = cluster.code - self.__commands_by_name[name] = {c.name.lower(): c.code for c in cluster.commands} + self.__commands_by_name[name] = { + c.name.lower(): c.code for c in cluster.commands} self.__responses_by_name[name] = {} - self.__attributes_by_name[name] = {a.definition.name.lower(): a.definition.code for a in cluster.attributes} - self.__events_by_name[name] = {e.name.lower(): e.code for e in cluster.events} - - self.__bitmaps_by_name[name] = {b.name.lower(): b for b in cluster.bitmaps} - self.__enums_by_name[name] = {e.name.lower(): e for e in cluster.enums} - self.__structs_by_name[name] = {s.name.lower(): s for s in cluster.structs} + self.__attributes_by_name[name] = { + a.definition.name.lower(): a.definition.code for a in cluster.attributes} + self.__events_by_name[name] = { + e.name.lower(): e.code for e in cluster.events} + + self.__bitmaps_by_name[name] = { + b.name.lower(): b for b in cluster.bitmaps} + self.__enums_by_name[name] = { + e.name.lower(): e for e in cluster.enums} + self.__structs_by_name[name] = { + s.name.lower(): s for s in cluster.structs} for struct in cluster.structs: if struct.tag == StructTag.RESPONSE: self.__responses_by_id[code][struct.code] = struct - self.__responses_by_name[name][struct.name.lower()] = struct.code + self.__responses_by_name[name][struct.name.lower( + )] = struct.code def get_cluster_name(self, cluster_id: int) -> str: cluster = self.__clusters_by_id.get(cluster_id) @@ -93,11 +93,13 @@ def get_command_name(self, cluster_id: int, command_id: int) -> str: return command.name if command else None def get_response_name(self, cluster_id: int, response_id: int) -> str: - response = self.__get_by_id(cluster_id, response_id, _ItemType.Response) + response = self.__get_by_id( + cluster_id, response_id, _ItemType.Response) return response.name if response else None def get_attribute_name(self, cluster_id: int, attribute_id: int) -> str: - attribute = self.__get_by_id(cluster_id, attribute_id, _ItemType.Attribute) + attribute = self.__get_by_id( + cluster_id, attribute_id, _ItemType.Attribute) return attribute.definition.name if attribute else None def get_event_name(self, cluster_id: int, event_id: int) -> str: @@ -162,16 +164,20 @@ def __get_by_name(self, cluster_name: str, target_name: str, target_type: _ItemT target = None if target_type == _ItemType.Request: - target_id = self.__commands_by_name.get(cluster_name).get(target_name) + target_id = self.__commands_by_name.get( + cluster_name).get(target_name) target = self.__get_by_id(cluster_id, target_id, target_type) elif target_type == _ItemType.Response: - target_id = self.__responses_by_name.get(cluster_name).get(target_name) + target_id = self.__responses_by_name.get( + cluster_name).get(target_name) target = self.__get_by_id(cluster_id, target_id, target_type) elif target_type == _ItemType.Event: - target_id = self.__events_by_name.get(cluster_name).get(target_name) + target_id = self.__events_by_name.get( + cluster_name).get(target_name) target = self.__get_by_id(cluster_id, target_id, target_type) elif target_type == _ItemType.Attribute: - target_id = self.__attributes_by_name.get(cluster_name).get(target_name) + target_id = self.__attributes_by_name.get( + cluster_name).get(target_name) target = self.__get_by_id(cluster_id, target_id, target_type) elif target_type == _ItemType.Bitmap: target = self.__bitmaps_by_name.get(cluster_name).get(target_name) diff --git a/scripts/tests/yamltests/fixes.py b/scripts/py_matter_yamltests/matter_yamltests/fixes.py similarity index 100% rename from scripts/tests/yamltests/fixes.py rename to scripts/py_matter_yamltests/matter_yamltests/fixes.py diff --git a/scripts/tests/yamltests/parser.py b/scripts/py_matter_yamltests/matter_yamltests/parser.py similarity index 100% rename from scripts/tests/yamltests/parser.py rename to scripts/py_matter_yamltests/matter_yamltests/parser.py diff --git a/scripts/py_matter_yamltests/pyproject.toml b/scripts/py_matter_yamltests/pyproject.toml new file mode 100644 index 00000000000000..ab9c08adaab8b5 --- /dev/null +++ b/scripts/py_matter_yamltests/pyproject.toml @@ -0,0 +1,17 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# 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. + +[build-system] +requires = ['setuptools', 'wheel'] +build-backend = 'setuptools.build_meta' diff --git a/scripts/py_matter_yamltests/setup.cfg b/scripts/py_matter_yamltests/setup.cfg new file mode 100644 index 00000000000000..497022ce1459d9 --- /dev/null +++ b/scripts/py_matter_yamltests/setup.cfg @@ -0,0 +1,24 @@ +# Copyright (c) 2022 Project CHIP Authors +# +# 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. + +[metadata] +name = matter_yamltests +version = 0.0.1 +author = Project CHIP Authors +description = Parse matter yaml tests files + +[options] +packages = find: + +zip_safe = False diff --git a/scripts/tests/yamltests/setup.py b/scripts/py_matter_yamltests/setup.py similarity index 68% rename from scripts/tests/yamltests/setup.py rename to scripts/py_matter_yamltests/setup.py index 2bcdfbe8c61d46..2d7f786e1957f6 100644 --- a/scripts/tests/yamltests/setup.py +++ b/scripts/py_matter_yamltests/setup.py @@ -13,16 +13,8 @@ # limitations under the License. -"""The yamltest package.""" +"""The yamltests package.""" import setuptools # type: ignore -setuptools.setup( - name='yamltests', - version='0.0.1', - author='Project CHIP Authors', - description='Parse matter yaml test files', - packages=setuptools.find_packages(), - package_data={'yamltest': ['py.typed']}, - zip_safe=False, -) +setuptools.setup() # Package definition in setup.cfg diff --git a/scripts/py_matter_yamltests/test_spec_definitions.py b/scripts/py_matter_yamltests/test_spec_definitions.py new file mode 100644 index 00000000000000..35a2dcd29f911a --- /dev/null +++ b/scripts/py_matter_yamltests/test_spec_definitions.py @@ -0,0 +1,358 @@ +#!/usr/bin/env -S python3 -B +# +# Copyright (c) 2022 Project CHIP Authors +# +# 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. + +from matter_yamltests.definitions import * + +import unittest +import io + +source_cluster = ''' + + + Test + 0x1234 + + +''' + +source_command = ''' + + + Test + 0x1234 + + + + + +''' + +source_response = ''' + + + Test + 0x1234 + + + + + + + +''' + +source_attribute = ''' + + + TestGlobalAttribute + + + + Test + 0x1234 + + + TestAttribute + + + +''' + +source_event = ''' + + + Test + 0x1234 + + + + + +''' + +source_bitmap = ''' + + + + + + + + + + + + + Test + 0x1234 + + + + TestWrong + 0x4321 + + +''' + +source_enum = ''' + + + + + + + + + + + + + Test + 0x1234 + + + + TestWrong + 0x4321 + + +''' + +source_struct = ''' + + + + + + + + + + + + + + + + + + Test + 0x1234 + + + + TestWrong + 0x4321 + + +''' + + +class TestSpecDefinitions(unittest.TestCase): + def test_cluster_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_cluster), name='source_cluster')]) + self.assertIsNone(definitions.get_cluster_name(0x4321)) + self.assertEqual(definitions.get_cluster_name(0x1234), 'Test') + + def test_command_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_command), name='source_command')]) + self.assertIsNone(definitions.get_command_name(0x4321, 0x0)) + self.assertIsNone(definitions.get_command_name(0x1234, 0x1)) + self.assertEqual(definitions.get_command_name( + 0x1234, 0x0), 'TestCommand') + + def test_response_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_response), name='source_response')]) + self.assertIsNone(definitions.get_response_name(0x4321, 0x0)) + self.assertIsNone(definitions.get_response_name(0x1234, 0x1)) + self.assertEqual(definitions.get_response_name( + 0x1234, 0x0), 'TestCommandResponse') + + def test_attribute_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) + self.assertIsNone(definitions.get_attribute_name(0x4321, 0x0)) + self.assertIsNone(definitions.get_attribute_name(0x4321, 0xFFFD)) + self.assertIsNone(definitions.get_attribute_name(0x1234, 0x1)) + self.assertEqual(definitions.get_attribute_name( + 0x1234, 0x0), 'TestAttribute') + self.assertEqual(definitions.get_attribute_name( + 0x1234, 0xFFFD), 'TestGlobalAttribute') + + def test_event_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_event), name='source_event')]) + self.assertIsNone(definitions.get_event_name(0x4321, 0x0)) + self.assertIsNone(definitions.get_event_name(0x1234, 0x1)) + self.assertEqual(definitions.get_event_name(0x1234, 0x0), 'TestEvent') + + def test_get_command_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_command), name='source_command')]) + self.assertIsNone(definitions.get_command_by_name( + 'WrongName', 'TestCommand')) + self.assertIsNone(definitions.get_command_by_name( + 'Test', 'TestWrongCommand')) + self.assertIsNone( + definitions.get_response_by_name('Test', 'TestCommand')) + self.assertIsInstance(definitions.get_command_by_name( + 'Test', 'TestCommand'), Command) + self.assertIsNone( + definitions.get_command_by_name('test', 'TestCommand')) + self.assertIsInstance(definitions.get_command_by_name( + 'Test', 'testcommand'), Command) + + def test_get_response_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_response), name='source_response')]) + self.assertIsNone(definitions.get_response_by_name( + 'WrongName', 'TestCommandResponse')) + self.assertIsNone(definitions.get_response_by_name( + 'Test', 'TestWrongCommandResponse')) + self.assertIsNone(definitions.get_command_by_name( + 'Test', 'TestCommandResponse')) + self.assertIsInstance(definitions.get_response_by_name( + 'Test', 'TestCommandResponse'), Struct) + self.assertIsNone(definitions.get_response_by_name( + 'test', 'TestCommandResponse')) + self.assertIsInstance(definitions.get_response_by_name( + 'Test', 'testcommandresponse'), Struct) + + def test_get_attribute_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) + self.assertIsNone(definitions.get_attribute_by_name( + 'WrongName', 'TestAttribute')) + self.assertIsNone(definitions.get_attribute_by_name( + 'WrongName', 'TestGlobalAttribute')) + self.assertIsNone(definitions.get_attribute_by_name( + 'Test', 'TestWrongAttribute')) + self.assertIsInstance(definitions.get_attribute_by_name( + 'Test', 'TestAttribute'), Attribute) + self.assertIsInstance(definitions.get_attribute_by_name( + 'Test', 'TestGlobalAttribute'), Attribute) + self.assertIsNone(definitions.get_attribute_by_name( + 'test', 'TestAttribute')) + self.assertIsNone(definitions.get_attribute_by_name( + 'test', 'TestGlobalAttribute')) + self.assertIsInstance(definitions.get_attribute_by_name( + 'Test', 'testattribute'), Attribute) + self.assertIsInstance(definitions.get_attribute_by_name( + 'Test', 'testglobalattribute'), Attribute) + + def test_get_event_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_event), name='source_event')]) + self.assertIsNone(definitions.get_event_by_name( + 'WrongName', 'TestEvent')) + self.assertIsNone(definitions.get_event_by_name( + 'Test', 'TestWrongEvent')) + self.assertIsInstance( + definitions.get_event_by_name('Test', 'TestEvent'), Event) + self.assertIsNone(definitions.get_event_by_name('test', 'TestEvent')) + self.assertIsInstance( + definitions.get_event_by_name('Test', 'testevent'), Event) + + def test_get_bitmap_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')]) + self.assertIsNone(definitions.get_bitmap_by_name( + 'WrongName', 'TestBitmap')) + self.assertIsNone(definitions.get_bitmap_by_name( + 'Test', 'TestWrongBitmap')) + self.assertIsInstance(definitions.get_bitmap_by_name( + 'Test', 'TestBitmap'), Bitmap) + self.assertIsNone(definitions.get_bitmap_by_name('test', 'TestBitmap')) + self.assertIsInstance(definitions.get_bitmap_by_name( + 'Test', 'testbitmap'), Bitmap) + + def test_get_enum_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_enum), name='source_enum')]) + self.assertIsNone(definitions.get_enum_by_name( + 'WrongName', 'TestEnum')) + self.assertIsNone(definitions.get_enum_by_name( + 'Test', 'TestWrongEnum')) + self.assertIsInstance( + definitions.get_enum_by_name('Test', 'TestEnum'), Enum) + self.assertIsNone(definitions.get_enum_by_name('test', 'TestEnum')) + self.assertIsInstance( + definitions.get_enum_by_name('Test', 'testenum'), Enum) + + def test_get_struct_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_struct), name='source_struct')]) + self.assertIsNone(definitions.get_struct_by_name( + 'WrongName', 'TestStruct')) + self.assertIsNone(definitions.get_struct_by_name( + 'Test', 'TestWrongStruct')) + self.assertIsInstance(definitions.get_struct_by_name( + 'Test', 'TestStruct'), Struct) + self.assertIsNone(definitions.get_struct_by_name('test', 'TestStruct')) + self.assertIsInstance(definitions.get_struct_by_name( + 'Test', 'teststruct'), Struct) + + def test_get_type_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_command), name='source_command')]) + self.assertIsNone(definitions.get_type_by_name('Test', 'TestCommand')) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_response), name='source_response')]) + self.assertIsInstance(definitions.get_type_by_name( + 'Test', 'TestCommandResponse'), Struct) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) + self.assertIsNone(definitions.get_type_by_name( + 'Test', 'TestAttribute')) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_event), name='source_event')]) + self.assertIsNone(definitions.get_type_by_name('Test', 'TestEvent')) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')]) + self.assertIsInstance(definitions.get_type_by_name( + 'Test', 'TestBitmap'), Bitmap) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_enum), name='source_enum')]) + self.assertIsInstance( + definitions.get_type_by_name('Test', 'TestEnum'), Enum) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_struct), name='source_struct')]) + self.assertIsInstance(definitions.get_type_by_name( + 'Test', 'TestStruct'), Struct) + + def test_is_fabric_scoped(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_struct), name='source_struct')]) + + struct = definitions.get_struct_by_name('Test', 'TestStruct') + self.assertFalse(definitions.is_fabric_scoped(struct)) + + struct = definitions.get_struct_by_name( + 'Test', 'TestStructFabricScoped') + self.assertTrue(definitions.is_fabric_scoped(struct)) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/tests/test_yaml_parser.py b/scripts/py_matter_yamltests/test_yaml_parser.py similarity index 92% rename from scripts/tests/test_yaml_parser.py rename to scripts/py_matter_yamltests/test_yaml_parser.py index c6a73da4f8eed9..78df2c35fe64ad 100644 --- a/scripts/tests/test_yaml_parser.py +++ b/scripts/py_matter_yamltests/test_yaml_parser.py @@ -23,8 +23,8 @@ import tempfile import unittest -from yamltests.definitions import * -from yamltests.parser import TestParser +from matter_yamltests.definitions import * +from matter_yamltests.parser import TestParser simple_test_description = ''' @@ -75,7 +75,8 @@ def setUp(self): with open(self._temp_file.name, 'w') as f: f.writelines(simple_test_yaml) pics_file = None - self._yaml_parser = TestParser(self._temp_file.name, pics_file, self._definitions) + self._yaml_parser = TestParser( + self._temp_file.name, pics_file, self._definitions) def test_able_to_iterate_over_all_parsed_tests(self): # self._yaml_parser.tests implements `__next__`, which does value substitution. We are diff --git a/scripts/requirements.txt b/scripts/requirements.txt index b39ec86833bf6e..eb7b423cd90b05 100644 --- a/scripts/requirements.txt +++ b/scripts/requirements.txt @@ -69,8 +69,9 @@ tabulate # scripts/build click -# scripts/idl +# scripts/py_matter_idl/matter_idl lark +# scripts/py_matter_idl/matter_idl and scripts/py_matter_yamtests/matter_yamltests stringcase cryptography diff --git a/scripts/tests/yamltests/test_spec_definitions.py b/scripts/tests/yamltests/test_spec_definitions.py deleted file mode 100644 index 00a15da9940d0c..00000000000000 --- a/scripts/tests/yamltests/test_spec_definitions.py +++ /dev/null @@ -1,291 +0,0 @@ -#!/usr/bin/env -S python3 -B -# -# Copyright (c) 2022 Project CHIP Authors -# -# 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. - -from definitions import * - -import unittest -import io - -source_cluster = ''' - - - Test - 0x1234 - - -''' - -source_command = ''' - - - Test - 0x1234 - - - - - -''' - -source_response = ''' - - - Test - 0x1234 - - - - - - - -''' - -source_attribute = ''' - - - TestGlobalAttribute - - - - Test - 0x1234 - - - TestAttribute - - - -''' - -source_event = ''' - - - Test - 0x1234 - - - - - -''' - -source_bitmap = ''' - - - - - - - - - - - - - Test - 0x1234 - - - - TestWrong - 0x4321 - - -''' - -source_enum = ''' - - - - - - - - - - - - - Test - 0x1234 - - - - TestWrong - 0x4321 - - -''' - -source_struct = ''' - - - - - - - - - - - - - - - - - - Test - 0x1234 - - - - TestWrong - 0x4321 - - -''' - - -class TestSpecDefinitions(unittest.TestCase): - def test_cluster_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_cluster), name='source_cluster')]) - self.assertIsNone(definitions.get_cluster_name(0x4321)) - self.assertEqual(definitions.get_cluster_name(0x1234), 'Test') - - def test_command_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_command), name='source_command')]) - self.assertIsNone(definitions.get_command_name(0x4321, 0x0)) - self.assertIsNone(definitions.get_command_name(0x1234, 0x1)) - self.assertEqual(definitions.get_command_name(0x1234, 0x0), 'TestCommand') - - def test_response_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_response), name='source_response')]) - self.assertIsNone(definitions.get_response_name(0x4321, 0x0)) - self.assertIsNone(definitions.get_response_name(0x1234, 0x1)) - self.assertEqual(definitions.get_response_name(0x1234, 0x0), 'TestCommandResponse') - - def test_attribute_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) - self.assertIsNone(definitions.get_attribute_name(0x4321, 0x0)) - self.assertIsNone(definitions.get_attribute_name(0x4321, 0xFFFD)) - self.assertIsNone(definitions.get_attribute_name(0x1234, 0x1)) - self.assertEqual(definitions.get_attribute_name(0x1234, 0x0), 'TestAttribute') - self.assertEqual(definitions.get_attribute_name(0x1234, 0xFFFD), 'TestGlobalAttribute') - - def test_event_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_event), name='source_event')]) - self.assertIsNone(definitions.get_event_name(0x4321, 0x0)) - self.assertIsNone(definitions.get_event_name(0x1234, 0x1)) - self.assertEqual(definitions.get_event_name(0x1234, 0x0), 'TestEvent') - - def test_get_command_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_command), name='source_command')]) - self.assertIsNone(definitions.get_command_by_name('WrongName', 'TestCommand')) - self.assertIsNone(definitions.get_command_by_name('Test', 'TestWrongCommand')) - self.assertIsNone(definitions.get_response_by_name('Test', 'TestCommand')) - self.assertIsInstance(definitions.get_command_by_name('Test', 'TestCommand'), Command) - self.assertIsNone(definitions.get_command_by_name('test', 'TestCommand')) - self.assertIsInstance(definitions.get_command_by_name('Test', 'testcommand'), Command) - - def test_get_response_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_response), name='source_response')]) - self.assertIsNone(definitions.get_response_by_name('WrongName', 'TestCommandResponse')) - self.assertIsNone(definitions.get_response_by_name('Test', 'TestWrongCommandResponse')) - self.assertIsNone(definitions.get_command_by_name('Test', 'TestCommandResponse')) - self.assertIsInstance(definitions.get_response_by_name('Test', 'TestCommandResponse'), Struct) - self.assertIsNone(definitions.get_response_by_name('test', 'TestCommandResponse')) - self.assertIsInstance(definitions.get_response_by_name('Test', 'testcommandresponse'), Struct) - - def test_get_attribute_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) - self.assertIsNone(definitions.get_attribute_by_name('WrongName', 'TestAttribute')) - self.assertIsNone(definitions.get_attribute_by_name('WrongName', 'TestGlobalAttribute')) - self.assertIsNone(definitions.get_attribute_by_name('Test', 'TestWrongAttribute')) - self.assertIsInstance(definitions.get_attribute_by_name('Test', 'TestAttribute'), Attribute) - self.assertIsInstance(definitions.get_attribute_by_name('Test', 'TestGlobalAttribute'), Attribute) - self.assertIsNone(definitions.get_attribute_by_name('test', 'TestAttribute')) - self.assertIsNone(definitions.get_attribute_by_name('test', 'TestGlobalAttribute')) - self.assertIsInstance(definitions.get_attribute_by_name('Test', 'testattribute'), Attribute) - self.assertIsInstance(definitions.get_attribute_by_name('Test', 'testglobalattribute'), Attribute) - - def test_get_event_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_event), name='source_event')]) - self.assertIsNone(definitions.get_event_by_name('WrongName', 'TestEvent')) - self.assertIsNone(definitions.get_event_by_name('Test', 'TestWrongEvent')) - self.assertIsInstance(definitions.get_event_by_name('Test', 'TestEvent'), Event) - self.assertIsNone(definitions.get_event_by_name('test', 'TestEvent')) - self.assertIsInstance(definitions.get_event_by_name('Test', 'testevent'), Event) - - def test_get_bitmap_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')]) - self.assertIsNone(definitions.get_bitmap_by_name('WrongName', 'TestBitmap')) - self.assertIsNone(definitions.get_bitmap_by_name('Test', 'TestWrongBitmap')) - self.assertIsInstance(definitions.get_bitmap_by_name('Test', 'TestBitmap'), Bitmap) - self.assertIsNone(definitions.get_bitmap_by_name('test', 'TestBitmap')) - self.assertIsInstance(definitions.get_bitmap_by_name('Test', 'testbitmap'), Bitmap) - - def test_get_enum_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_enum), name='source_enum')]) - self.assertIsNone(definitions.get_enum_by_name('WrongName', 'TestEnum')) - self.assertIsNone(definitions.get_enum_by_name('Test', 'TestWrongEnum')) - self.assertIsInstance(definitions.get_enum_by_name('Test', 'TestEnum'), Enum) - self.assertIsNone(definitions.get_enum_by_name('test', 'TestEnum')) - self.assertIsInstance(definitions.get_enum_by_name('Test', 'testenum'), Enum) - - def test_get_struct_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_struct), name='source_struct')]) - self.assertIsNone(definitions.get_struct_by_name('WrongName', 'TestStruct')) - self.assertIsNone(definitions.get_struct_by_name('Test', 'TestWrongStruct')) - self.assertIsInstance(definitions.get_struct_by_name('Test', 'TestStruct'), Struct) - self.assertIsNone(definitions.get_struct_by_name('test', 'TestStruct')) - self.assertIsInstance(definitions.get_struct_by_name('Test', 'teststruct'), Struct) - - def test_get_type_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_command), name='source_command')]) - self.assertIsNone(definitions.get_type_by_name('Test', 'TestCommand')) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_response), name='source_response')]) - self.assertIsInstance(definitions.get_type_by_name('Test', 'TestCommandResponse'), Struct) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) - self.assertIsNone(definitions.get_type_by_name('Test', 'TestAttribute')) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_event), name='source_event')]) - self.assertIsNone(definitions.get_type_by_name('Test', 'TestEvent')) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')]) - self.assertIsInstance(definitions.get_type_by_name('Test', 'TestBitmap'), Bitmap) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_enum), name='source_enum')]) - self.assertIsInstance(definitions.get_type_by_name('Test', 'TestEnum'), Enum) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_struct), name='source_struct')]) - self.assertIsInstance(definitions.get_type_by_name('Test', 'TestStruct'), Struct) - - def test_is_fabric_scoped(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_struct), name='source_struct')]) - - struct = definitions.get_struct_by_name('Test', 'TestStruct') - self.assertFalse(definitions.is_fabric_scoped(struct)) - - struct = definitions.get_struct_by_name('Test', 'TestStructFabricScoped') - self.assertTrue(definitions.is_fabric_scoped(struct)) - - -if __name__ == '__main__': - unittest.main() From 285f4ef09fd7facdc1fcea3fed798195be44308c Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 5 Jan 2023 12:52:26 -0500 Subject: [PATCH 08/14] Cleanup after matter_idl, matter_yamltests PR merged (#24283) --- BUILD.gn | 2 +- scripts/BUILD.gn | 6 +++--- scripts/py_matter_yamltests/setup.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 23bc58926aac8d..ce3a154774d272 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -122,7 +122,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { pw_python_pip_install("pip_install_matter_packages") { packages = [ "//examples/common/pigweed/rpc_console:chip_rpc_distribution", - "//scripts:yamltests_distribution", + "//scripts:matter_yamltests_distribution", ] } diff --git a/scripts/BUILD.gn b/scripts/BUILD.gn index 878102414b89ce..e14db546195de5 100644 --- a/scripts/BUILD.gn +++ b/scripts/BUILD.gn @@ -20,9 +20,9 @@ import("$dir_pw_build/python_dist.gni") # This target creates a single Python package and wheel for yamltests. It will # merge all Python dependencies Matter. The output is located in: -# out/obj/yamltests_distribution/ <- source files here -# out/obj/yamltests_distribution._build_wheel/yamltests-0.0.1-py3-none-any.whl -pw_python_distribution("yamltests_distribution") { +# out/obj/matter_yamltests_distribution/ <- source files here +# out/obj/matter_yamltests_distribution._build_wheel/matter_yamltests-0.0.1-py3-none-any.whl +pw_python_distribution("matter_yamltests_distribution") { packages = [ "${chip_root}/scripts/py_matter_yamltests:matter_yamltests" ] generate_setup_cfg = { common_config_file = "common_setup.cfg" diff --git a/scripts/py_matter_yamltests/setup.py b/scripts/py_matter_yamltests/setup.py index 2d7f786e1957f6..8917fa45238cf5 100644 --- a/scripts/py_matter_yamltests/setup.py +++ b/scripts/py_matter_yamltests/setup.py @@ -13,7 +13,7 @@ # limitations under the License. -"""The yamltests package.""" +"""The matter_yamltests package.""" import setuptools # type: ignore From adfb786808420a1a4fde0c92d9152e556290923c Mon Sep 17 00:00:00 2001 From: Evgeny Margolis Date: Thu, 5 Jan 2023 09:57:21 -0800 Subject: [PATCH 09/14] [crypto] Added Method That Finds and Replaces Resigned Version of a Certificate (#24212) * [crypto] Added Method That Finds and Replaces Resigned Version of a Certificate. This method checks for resigned version of the reference certificate in the list and returns it. The following conditions SHOULD be satisfied for the certificate to qualify as a resigned version of a reference certificate: - SKID of the candidate and the reference certificate should match. - SubjectDN of the candidate and the reference certificate should match. There is no specific use case for this method in Matter. However, specific ecosystem implementations may find this method useful. Some of the potential use cases could be finding resigned version of a PAI or DAC certificate. Also, this method can be useful when Matter introduces attestation certificate revocation mechanism. * Updated function description. --- .../Chip-Test-PAA-NoVID-ToResignPAIs-Cert.der | Bin 0 -> 436 bytes .../Chip-Test-PAA-NoVID-ToResignPAIs-Cert.pem | 12 ++ .../Chip-Test-PAI-FFF2-8001-Resigned-Cert.der | Bin 0 -> 465 bytes .../Chip-Test-PAI-FFF2-8001-Resigned-Cert.pem | 12 ++ ...st-PAI-FFF2-8001-ResignedSKIDDiff-Cert.der | Bin 0 -> 464 bytes ...st-PAI-FFF2-8001-ResignedSKIDDiff-Cert.pem | 12 ++ ...est-PAI-FFF2-8001-ResignedSKIDDiff-Key.der | Bin 0 -> 121 bytes ...est-PAI-FFF2-8001-ResignedSKIDDiff-Key.pem | 5 + ...PAI-FFF2-8001-ResignedSubjectDiff-Cert.der | Bin 0 -> 474 bytes ...PAI-FFF2-8001-ResignedSubjectDiff-Cert.pem | 12 ++ ...Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.der | Bin 0 -> 443 bytes ...Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.pem | 12 ++ .../test/gen-test-attestation-certs.sh | 62 ++++-- .../tests/CHIPAttCert_test_vectors.cpp | 199 ++++++++++++++++++ .../tests/CHIPAttCert_test_vectors.h | 17 ++ src/crypto/CHIPCryptoPAL.h | 23 ++ src/crypto/CHIPCryptoPALOpenSSL.cpp | 60 ++++++ src/crypto/CHIPCryptoPALTinyCrypt.cpp | 77 +++++++ src/crypto/CHIPCryptoPALmbedTLS.cpp | 77 +++++++ src/crypto/tests/CHIPCryptoPALTest.cpp | 82 ++++++++ .../silabs/EFR32/CHIPCryptoPALPsaEfr32.cpp | 77 +++++++ 21 files changed, 727 insertions(+), 12 deletions(-) create mode 100644 credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.der create mode 100644 credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.pem create mode 100644 credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.der create mode 100644 credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.pem create mode 100644 credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.der create mode 100644 credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.pem create mode 100644 credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.der create mode 100644 credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.pem create mode 100644 credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.der create mode 100644 credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.pem create mode 100644 credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.der create mode 100644 credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.pem diff --git a/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.der b/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.der new file mode 100644 index 0000000000000000000000000000000000000000..93f956666154af3402ae150ef869fb5dde9d9a44 GIT binary patch literal 436 zcmXqLV%%WR#2B`KnTe5!iKCW*OI&&1eKrFwHV&;ek8`#x%uEKFhUx~YY|No7%sg_w zi6teeMG7IQ#U%;>j*bc;`3ga)#hK}OK%Qr@fr2=%k)eT^k%gg&k+F$!lmx#e5EvR6 z1Cgnvsbv%?hD90(v$2C+!Ndr44l^S=vl9c0zQh)uMTJZKup7E!b9Qab-p3%TOk6poQahgGjfe_G3 zvcimv|5-Q;*nkuhBclNyNQ@sO2J|>1n}IBd&&MLhB2p3aoOMTbzhD0G$*U4hJHN`z zXu4`350X}9kuVTzz^(u(7@0j73|yHMs*}HNy3s!UQt}4-we5SYd)oGV;GdblqWHyM w{f2}?viVGk43i%EZ2mU=V1G}muY5tszI>_G=gxe-I*;elp(375A5N430QOUn-2eap literal 0 HcmV?d00001 diff --git a/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.pem b/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.pem new file mode 100644 index 00000000000000..5c28c0a147b4a6 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBsDCCAVagAwIBAgIIfQAKFyO+3wYwCgYIKoZIzj0EAwIwKTEnMCUGA1UEAwwe +TWF0dGVyIFRlc3QgUEFBIFRvIFJlc2lnbiBQQUlzMCAXDTIxMDYyODE0MjM0M1oY +Dzk5OTkxMjMxMjM1OTU5WjApMScwJQYDVQQDDB5NYXR0ZXIgVGVzdCBQQUEgVG8g +UmVzaWduIFBBSXMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQQ7wKoGoe2gSH7 +qNMZePgHoxflCqioKERoKJFLkz3o7dSlw5yf9xpM42R/1/YmU7fSSV/LpMD0f4do +gAOeByBKo2YwZDASBgNVHRMBAf8ECDAGAQH/AgEBMA4GA1UdDwEB/wQEAwIBBjAd +BgNVHQ4EFgQUeFznBbhrj05vx5OqYMtD6mlogtUwHwYDVR0jBBgwFoAUeFznBbhr +j05vx5OqYMtD6mlogtUwCgYIKoZIzj0EAwIDSAAwRQIge2P1stiHl9JjsD+th707 +jIa88A+Zb6hz6P0vgGDCHW8CIQCS4Uyz9pfBj4yFTR9wVL5vGqvOzPPVngzSwnIM +svDIdg== +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.der b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.der new file mode 100644 index 0000000000000000000000000000000000000000..bb13cb0f7d8247bb52154313175c97aa02bb3758 GIT binary patch literal 465 zcmXqLVmxcm#8|w5nTe5!i6g1#_$n@8g}DY?Y#dr`9_MUXn3)VT4b=@)*_cCFn0e%U z6H7``ixfgqi%S#&932%x@)d$oi!;;nfIQD)0|jwjBSQl-BMUnF^FOOsD^nOiWms7acQ$LvM@F+s$pW}VR3VFGeQ$(;$g8cFfcTT zG!SNE2Ro685$aZEMs{W=1{NJQ8-?!e=j}Uh%qiHEaqrNFwVjgsO!`yZ*PbcTVr$4e zRb-mbyj`VSTCvP$lTWzdR=a=g|NI|pDHf4Fvyf#|@8UFr6re+xLuG{-8UM3z7_b2; zCPoGWK9CqcNDLS%jBEz7AU+?97>me-sM+a-3l~?-J~(&ki>M zO3X`b#gnJ@9iM&GSK^rrlS0{r=ki})1iZS-ex+Hi)a_#BwMW}-JUk}8CT!`Og&|B9 E0Ly-lJOBUy literal 0 HcmV?d00001 diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.pem b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.pem new file mode 100644 index 00000000000000..b3620594118e4a --- /dev/null +++ b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBzTCCAXOgAwIBAgIIYnLHqgoTIJ0wCgYIKoZIzj0EAwIwKTEnMCUGA1UEAwwe +TWF0dGVyIFRlc3QgUEFBIFRvIFJlc2lnbiBQQUlzMCAXDTIxMDYyODE0MjM0M1oY +Dzk5OTkxMjMxMjM1OTU5WjBGMRgwFgYDVQQDDA9NYXR0ZXIgVGVzdCBQQUkxFDAS +BgorBgEEAYKifAIBDARGRkYyMRQwEgYKKwYBBAGConwCAgwEODAwMTBZMBMGByqG +SM49AgEGCCqGSM49AwEHA0IABCwGPCCLt88/idiccLJo3sLwrYkZLwIvlUetzHIq +BoBpynI1YIO3JHcbIXZMskxXEbU+/of+T+C0cxQbzKEEso2jZjBkMBIGA1UdEwEB +/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTQWptncaGjepvB +nZXotduPQwC2OjAfBgNVHSMEGDAWgBR4XOcFuGuPTm/Hk6pgy0PqaWiC1TAKBggq +hkjOPQQDAgNIADBFAiEAnw1UN+kJn4U4ylMO6J0qs2QkXOkrIcnKvseb1U0Y5hwC +IHbQ5x/16FDq3QfUgx51RtF51uK22OHGF6xWpeyhVAI4 +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.der b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.der new file mode 100644 index 0000000000000000000000000000000000000000..89b0d9ded65a0b420c86edd3f63f0b3956b91284 GIT binary patch literal 464 zcmXqLVmxEe#8|w5nTe5!iNoLK(A|x)M@}1Xv2kd%d7QIlVP-PWG*mZGWn&IyVdjzZ zO)M!%Em8GqcU8w0GmAAo^PX59cbp?~_t)YygA|}cm_ucS85#exa2T)w zDJDh+13r)#KS&H1DvWFfvLHSmix`W@?ea^}$+;{R3n$4q1_{``dUV8^-9R2Bt;_=S zZi7fg%yZTq+5LX`$0x5!IPLr@Go$G$au_qaGZ?rqDX_{Ln1ua(&G`TClgjzOx7g-h z^hh=7x@JFV*XdIUCuB646aDJq{33c+V%Dh)xg9Je|av%@hmw~aN;8X DU9633 literal 0 HcmV?d00001 diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.pem b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.pem new file mode 100644 index 00000000000000..3eed75c53562ae --- /dev/null +++ b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBzDCCAXOgAwIBAgIITzzC3bEdxMswCgYIKoZIzj0EAwIwKTEnMCUGA1UEAwwe +TWF0dGVyIFRlc3QgUEFBIFRvIFJlc2lnbiBQQUlzMCAXDTIxMDYyODE0MjM0M1oY +Dzk5OTkxMjMxMjM1OTU5WjBGMRgwFgYDVQQDDA9NYXR0ZXIgVGVzdCBQQUkxFDAS +BgorBgEEAYKifAIBDARGRkYyMRQwEgYKKwYBBAGConwCAgwEODAwMTBZMBMGByqG +SM49AgEGCCqGSM49AwEHA0IABKH6SCo8kvOkZmOc4zVxOLakyd1EdhaOx+xcRQgr +3BvAbZuU00x53wXfxAsnEIBEC3qItDY4rEye5DnHQZwU3fqjZjBkMBIGA1UdEwEB +/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTbd9JbY20EOKGS +HEFSED7q4sQ7BzAfBgNVHSMEGDAWgBR4XOcFuGuPTm/Hk6pgy0PqaWiC1TAKBggq +hkjOPQQDAgNHADBEAiAFHzA0Vv3rAf/95Hmf+7Q9bdFIZTSK1j+SusvKYMgcKQIg +ERLDCvsqkvYALhR4OSA7Rdu4JVFhsP0M0F4MpMRwyPE= +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.der b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.der new file mode 100644 index 0000000000000000000000000000000000000000..b3791b55bb3686803eda260b38d29799f86f8265 GIT binary patch literal 121 zcmV-<0EYiCcLD(c1R&9_V*5?A1^%Oqqv=F+O&h?!`IM-1+{N{J7x=XpQ8l0n1_&yK zNX|V20SBQ(13~}|8|%E8H8vZJU(SOnKi0 b-^2?i5P(DrdWf_(IIK*bj*bc;`3ga)#hK}OK%Qr@fr2=%k)eT^k%gg&k+F$!lmx#e5EvR6 z1Cgnvsb!RbzoDXmJj5^wRKq->CZ(nriWms7acQ$LvM@F+s$pW}VR3VFGeQ$(;$g8c zFfcTTG!SNE2fLMt5$b4WMs{W=1{NJQ8-?!e=j}Uh%qiHEaqrNFwVjgsO!`yZ*PbcT zVr$4eRb-mbyj`VSTCvP$lTWzdR=a=g|NI|pDHf4Fvyf#|@8UFr6re+xLuG{-8UM3z z7_b2;CPoGWK9CqcNDLS}jBEz7AU+?97>me-sM+a-3l~?-J~(&ki>OwfwsDU_Mfv!@l)gX7q)^X0W#Y4E6Ay%*Ua-NdXhPYd2>s1FA9IQBJA5JL IrJ(*F0K|Kdj{pDw literal 0 HcmV?d00001 diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.pem b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.pem new file mode 100644 index 00000000000000..3e28439c9a470f --- /dev/null +++ b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIB1jCCAXygAwIBAgIIR+1jaCGXaTEwCgYIKoZIzj0EAwIwKTEnMCUGA1UEAwwe +TWF0dGVyIFRlc3QgUEFBIFRvIFJlc2lnbiBQQUlzMCAXDTIxMDYyODE0MjM0M1oY +Dzk5OTkxMjMxMjM1OTU5WjBPMSEwHwYDVQQDDBhNYXR0ZXIgVGVzdCBQQUkgUmVz +aWduZWQxFDASBgorBgEEAYKifAIBDARGRkYyMRQwEgYKKwYBBAGConwCAgwEODAw +MTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCwGPCCLt88/idiccLJo3sLwrYkZ +LwIvlUetzHIqBoBpynI1YIO3JHcbIXZMskxXEbU+/of+T+C0cxQbzKEEso2jZjBk +MBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTQ +WptncaGjepvBnZXotduPQwC2OjAfBgNVHSMEGDAWgBR4XOcFuGuPTm/Hk6pgy0Pq +aWiC1TAKBggqhkjOPQQDAgNIADBFAiEA6LLGEXBKVAZ5DMXIhzg4iQOcGO3yPV7i +VRUOD/R178kCIH8NlJHm5pHAVcugsEpykHaiWC+zueMKFb7D0FzpES/8 +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.der b/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.der new file mode 100644 index 0000000000000000000000000000000000000000..8c7bc50d173b665fced0e0a61cb94415e37cbfa6 GIT binary patch literal 443 zcmXqLV%%=f#2CAPnTe5!i6fRP@_@Lvb*cdu8;4e#$2nUTW+nqoLv;gHHs(+kW*#}; z#FCQKB88CD;u3`bM@NN_e1)LY;>`3sAkVYdKtY_>$k4#d$imRX$k@ayk zfymU-)H2Gzz)-?K3}P5Rs$rgnA_hWiT-t1mER0QyYM2;#Slry)j0_?TgxT1^j$vYi zx{8^Ro!N~)!u*ia{mwi&qza1xD%F`99 z*%?%(csOsml|)Y1g;O_YZg4zQuyW&R`^9MnDL^ZkLuG{-8UM3z7_b2;CPoGWK9Cqc zNDSzIMm7Uk5TB1lj722T_CmX9+=uRUj8Bfu>OXF~rl>"$output_cstyle_file".h printf "$namespaces_open\n" >>"$output_cstyle_file".cpp printf "$namespaces_open\n" >>"$output_cstyle_file".h - for cert_file_pem in credentials/test/attestation/*Cert.pem; do + for cert_file_pem in "$dest_dir"/*Cert.pem; do params_prefix="${cert_file_pem/*Chip-Test/sTestCert}" params_prefix="${params_prefix//-/_}" params_prefix="${params_prefix/_Cert.pem/}" @@ -387,24 +418,31 @@ namespace TestCerts { printf "};\n\n" printf "extern const ByteSpan ${params_prefix}_SKID = ByteSpan(${params_prefix}_SKID_Array);\n\n" - printf "// \${chip_root}/$key_file_pem\n\n" + # Print key data if present + if test -f "$key_file_pem"; then + printf "// \${chip_root}/$key_file_pem\n\n" - printf "constexpr uint8_t ${params_prefix}_PublicKey_Array[] = {\n" - openssl ec -text -noout -in "$key_file_pem" | sed '0,/pub:$/d' | sed '/ASN1 OID:/,$d' | sed 's/:/ /g' | sed 's/\/,/g' | sed "s/^[ \t]*/ /" | sed 's/ *$//' - printf "};\n\n" - printf "extern const ByteSpan ${params_prefix}_PublicKey = ByteSpan(${params_prefix}_PublicKey_Array);\n\n" + printf "constexpr uint8_t ${params_prefix}_PublicKey_Array[] = {\n" + openssl ec -text -noout -in "$key_file_pem" | sed '0,/pub:$/d' | sed '/ASN1 OID:/,$d' | sed 's/:/ /g' | sed 's/\/,/g' | sed "s/^[ \t]*/ /" | sed 's/ *$//' + printf "};\n\n" + printf "extern const ByteSpan ${params_prefix}_PublicKey = ByteSpan(${params_prefix}_PublicKey_Array);\n\n" - printf "constexpr uint8_t ${params_prefix}_PrivateKey_Array[] = {\n" - openssl ec -text -noout -in "$key_file_pem" | sed '0,/priv:$/d' | sed '/pub:/,$d' | sed 's/:/ /g' | sed 's/\/,/g' | sed "s/^[ \t]*/ /" | sed 's/ *$//' - printf "};\n\n" - printf "extern const ByteSpan ${params_prefix}_PrivateKey = ByteSpan(${params_prefix}_PrivateKey_Array);\n\n" + printf "constexpr uint8_t ${params_prefix}_PrivateKey_Array[] = {\n" + openssl ec -text -noout -in "$key_file_pem" | sed '0,/priv:$/d' | sed '/pub:/,$d' | sed 's/:/ /g' | sed 's/\/,/g' | sed "s/^[ \t]*/ /" | sed 's/ *$//' + printf "};\n\n" + printf "extern const ByteSpan ${params_prefix}_PrivateKey = ByteSpan(${params_prefix}_PrivateKey_Array);\n\n" + fi } >>"$output_cstyle_file".cpp { printf "extern const ByteSpan ${params_prefix}_Cert;\n" printf "extern const ByteSpan ${params_prefix}_SKID;\n" - printf "extern const ByteSpan ${params_prefix}_PublicKey;\n" - printf "extern const ByteSpan ${params_prefix}_PrivateKey;\n\n" + # Print key data if present + if test -f "$key_file_pem"; then + printf "extern const ByteSpan ${params_prefix}_PublicKey;\n" + printf "extern const ByteSpan ${params_prefix}_PrivateKey;\n" + fi + printf "\n" } >>"$output_cstyle_file".h done diff --git a/src/credentials/tests/CHIPAttCert_test_vectors.cpp b/src/credentials/tests/CHIPAttCert_test_vectors.cpp index 0bb32b7b72f32a..82cda1285d8980 100644 --- a/src/credentials/tests/CHIPAttCert_test_vectors.cpp +++ b/src/credentials/tests/CHIPAttCert_test_vectors.cpp @@ -2596,6 +2596,40 @@ constexpr uint8_t sTestCert_PAA_NoVID_PrivateKey_Array[] = { extern const ByteSpan sTestCert_PAA_NoVID_PrivateKey = ByteSpan(sTestCert_PAA_NoVID_PrivateKey_Array); +// ${chip_root}/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.pem + +constexpr uint8_t sTestCert_PAA_NoVID_ToResignPAIs_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xb0, 0x30, 0x82, 0x01, 0x56, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x7d, 0x00, 0x0a, 0x17, 0x23, 0xbe, + 0xdf, 0x06, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, + 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, + 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, + 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x10, 0xef, 0x02, 0xa8, 0x1a, 0x87, 0xb6, + 0x81, 0x21, 0xfb, 0xa8, 0xd3, 0x19, 0x78, 0xf8, 0x07, 0xa3, 0x17, 0xe5, 0x0a, 0xa8, 0xa8, 0x28, 0x44, 0x68, 0x28, 0x91, 0x4b, + 0x93, 0x3d, 0xe8, 0xed, 0xd4, 0xa5, 0xc3, 0x9c, 0x9f, 0xf7, 0x1a, 0x4c, 0xe3, 0x64, 0x7f, 0xd7, 0xf6, 0x26, 0x53, 0xb7, 0xd2, + 0x49, 0x5f, 0xcb, 0xa4, 0xc0, 0xf4, 0x7f, 0x87, 0x68, 0x80, 0x03, 0x9e, 0x07, 0x20, 0x4a, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, + 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01, 0x30, 0x0e, 0x06, + 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, + 0x16, 0x04, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, + 0x82, 0xd5, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, + 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, 0x82, 0xd5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, + 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x7b, 0x63, 0xf5, 0xb2, 0xd8, 0x87, 0x97, 0xd2, 0x63, + 0xb0, 0x3f, 0xad, 0x87, 0xbd, 0x3b, 0x8c, 0x86, 0xbc, 0xf0, 0x0f, 0x99, 0x6f, 0xa8, 0x73, 0xe8, 0xfd, 0x2f, 0x80, 0x60, 0xc2, + 0x1d, 0x6f, 0x02, 0x21, 0x00, 0x92, 0xe1, 0x4c, 0xb3, 0xf6, 0x97, 0xc1, 0x8f, 0x8c, 0x85, 0x4d, 0x1f, 0x70, 0x54, 0xbe, 0x6f, + 0x1a, 0xab, 0xce, 0xcc, 0xf3, 0xd5, 0x9e, 0x0c, 0xd2, 0xc2, 0x72, 0x0c, 0xb2, 0xf0, 0xc8, 0x76, +}; + +extern const ByteSpan sTestCert_PAA_NoVID_ToResignPAIs_Cert = ByteSpan(sTestCert_PAA_NoVID_ToResignPAIs_Cert_Array); + +constexpr uint8_t sTestCert_PAA_NoVID_ToResignPAIs_SKID_Array[] = { + 0x78, 0x5C, 0xE7, 0x05, 0xB8, 0x6B, 0x8F, 0x4E, 0x6F, 0xC7, 0x93, 0xAA, 0x60, 0xCB, 0x43, 0xEA, 0x69, 0x68, 0x82, 0xD5, +}; + +extern const ByteSpan sTestCert_PAA_NoVID_ToResignPAIs_SKID = ByteSpan(sTestCert_PAA_NoVID_ToResignPAIs_SKID_Array); + // ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF1-8000-Cert.pem constexpr uint8_t sTestCert_PAI_FFF1_8000_Cert_Array[] = { @@ -2703,6 +2737,136 @@ constexpr uint8_t sTestCert_PAI_FFF2_8001_PrivateKey_Array[] = { extern const ByteSpan sTestCert_PAI_FFF2_8001_PrivateKey = ByteSpan(sTestCert_PAI_FFF2_8001_PrivateKey_Array); +// ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.pem + +constexpr uint8_t sTestCert_PAI_FFF2_8001_Resigned_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xcd, 0x30, 0x82, 0x01, 0x73, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x62, 0x72, 0xc7, 0xaa, 0x0a, 0x13, + 0x20, 0x9d, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, + 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x46, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, + 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x46, 0x46, 0x46, 0x32, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x02, 0x0c, 0x04, 0x38, 0x30, 0x30, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, + 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, + 0x04, 0x2c, 0x06, 0x3c, 0x20, 0x8b, 0xb7, 0xcf, 0x3f, 0x89, 0xd8, 0x9c, 0x70, 0xb2, 0x68, 0xde, 0xc2, 0xf0, 0xad, 0x89, 0x19, + 0x2f, 0x02, 0x2f, 0x95, 0x47, 0xad, 0xcc, 0x72, 0x2a, 0x06, 0x80, 0x69, 0xca, 0x72, 0x35, 0x60, 0x83, 0xb7, 0x24, 0x77, 0x1b, + 0x21, 0x76, 0x4c, 0xb2, 0x4c, 0x57, 0x11, 0xb5, 0x3e, 0xfe, 0x87, 0xfe, 0x4f, 0xe0, 0xb4, 0x73, 0x14, 0x1b, 0xcc, 0xa1, 0x04, + 0xb2, 0x8d, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, + 0x01, 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, + 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xd0, 0x5a, 0x9b, 0x67, 0x71, 0xa1, 0xa3, 0x7a, 0x9b, 0xc1, + 0x9d, 0x95, 0xe8, 0xb5, 0xdb, 0x8f, 0x43, 0x00, 0xb6, 0x3a, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, 0x82, + 0xd5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x21, 0x00, + 0x9f, 0x0d, 0x54, 0x37, 0xe9, 0x09, 0x9f, 0x85, 0x38, 0xca, 0x53, 0x0e, 0xe8, 0x9d, 0x2a, 0xb3, 0x64, 0x24, 0x5c, 0xe9, 0x2b, + 0x21, 0xc9, 0xca, 0xbe, 0xc7, 0x9b, 0xd5, 0x4d, 0x18, 0xe6, 0x1c, 0x02, 0x20, 0x76, 0xd0, 0xe7, 0x1f, 0xf5, 0xe8, 0x50, 0xea, + 0xdd, 0x07, 0xd4, 0x83, 0x1e, 0x75, 0x46, 0xd1, 0x79, 0xd6, 0xe2, 0xb6, 0xd8, 0xe1, 0xc6, 0x17, 0xac, 0x56, 0xa5, 0xec, 0xa1, + 0x54, 0x02, 0x38, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_Resigned_Cert = ByteSpan(sTestCert_PAI_FFF2_8001_Resigned_Cert_Array); + +constexpr uint8_t sTestCert_PAI_FFF2_8001_Resigned_SKID_Array[] = { + 0xD0, 0x5A, 0x9B, 0x67, 0x71, 0xA1, 0xA3, 0x7A, 0x9B, 0xC1, 0x9D, 0x95, 0xE8, 0xB5, 0xDB, 0x8F, 0x43, 0x00, 0xB6, 0x3A, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_Resigned_SKID = ByteSpan(sTestCert_PAI_FFF2_8001_Resigned_SKID_Array); + +// ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.pem + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xcc, 0x30, 0x82, 0x01, 0x73, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x4f, 0x3c, 0xc2, 0xdd, 0xb1, 0x1d, + 0xc4, 0xcb, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, + 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x46, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, + 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x46, 0x46, 0x46, 0x32, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x02, 0x0c, 0x04, 0x38, 0x30, 0x30, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, + 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, + 0x04, 0xa1, 0xfa, 0x48, 0x2a, 0x3c, 0x92, 0xf3, 0xa4, 0x66, 0x63, 0x9c, 0xe3, 0x35, 0x71, 0x38, 0xb6, 0xa4, 0xc9, 0xdd, 0x44, + 0x76, 0x16, 0x8e, 0xc7, 0xec, 0x5c, 0x45, 0x08, 0x2b, 0xdc, 0x1b, 0xc0, 0x6d, 0x9b, 0x94, 0xd3, 0x4c, 0x79, 0xdf, 0x05, 0xdf, + 0xc4, 0x0b, 0x27, 0x10, 0x80, 0x44, 0x0b, 0x7a, 0x88, 0xb4, 0x36, 0x38, 0xac, 0x4c, 0x9e, 0xe4, 0x39, 0xc7, 0x41, 0x9c, 0x14, + 0xdd, 0xfa, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, + 0x01, 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, + 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xdb, 0x77, 0xd2, 0x5b, 0x63, 0x6d, 0x04, 0x38, 0xa1, 0x92, + 0x1c, 0x41, 0x52, 0x10, 0x3e, 0xea, 0xe2, 0xc4, 0x3b, 0x07, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, 0x82, + 0xd5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x47, 0x00, 0x30, 0x44, 0x02, 0x20, 0x05, + 0x1f, 0x30, 0x34, 0x56, 0xfd, 0xeb, 0x01, 0xff, 0xfd, 0xe4, 0x79, 0x9f, 0xfb, 0xb4, 0x3d, 0x6d, 0xd1, 0x48, 0x65, 0x34, 0x8a, + 0xd6, 0x3f, 0x92, 0xba, 0xcb, 0xca, 0x60, 0xc8, 0x1c, 0x29, 0x02, 0x20, 0x11, 0x12, 0xc3, 0x0a, 0xfb, 0x2a, 0x92, 0xf6, 0x00, + 0x2e, 0x14, 0x78, 0x39, 0x20, 0x3b, 0x45, 0xdb, 0xb8, 0x25, 0x51, 0x61, 0xb0, 0xfd, 0x0c, 0xd0, 0x5e, 0x0c, 0xa4, 0xc4, 0x70, + 0xc8, 0xf1, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert = ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert_Array); + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_SKID_Array[] = { + 0xDB, 0x77, 0xD2, 0x5B, 0x63, 0x6D, 0x04, 0x38, 0xA1, 0x92, 0x1C, 0x41, 0x52, 0x10, 0x3E, 0xEA, 0xE2, 0xC4, 0x3B, 0x07, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_SKID = ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_SKID_Array); + +// ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.pem + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PublicKey_Array[] = { + 0x04, 0xa1, 0xfa, 0x48, 0x2a, 0x3c, 0x92, 0xf3, 0xa4, 0x66, 0x63, 0x9c, 0xe3, 0x35, 0x71, 0x38, 0xb6, + 0xa4, 0xc9, 0xdd, 0x44, 0x76, 0x16, 0x8e, 0xc7, 0xec, 0x5c, 0x45, 0x08, 0x2b, 0xdc, 0x1b, 0xc0, 0x6d, + 0x9b, 0x94, 0xd3, 0x4c, 0x79, 0xdf, 0x05, 0xdf, 0xc4, 0x0b, 0x27, 0x10, 0x80, 0x44, 0x0b, 0x7a, 0x88, + 0xb4, 0x36, 0x38, 0xac, 0x4c, 0x9e, 0xe4, 0x39, 0xc7, 0x41, 0x9c, 0x14, 0xdd, 0xfa, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PublicKey = + ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PublicKey_Array); + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PrivateKey_Array[] = { + 0xd1, 0xae, 0x62, 0xfb, 0x4d, 0xb3, 0x05, 0xfe, 0xa3, 0x8c, 0xa3, 0xe9, 0x44, 0x74, 0x4d, 0x1b, + 0xc0, 0xbf, 0xf9, 0x94, 0xa8, 0x74, 0xdc, 0xc5, 0xf5, 0x7a, 0x17, 0xf8, 0xb5, 0x18, 0x51, 0x35, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PrivateKey = + ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PrivateKey_Array); + +// ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.pem + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xd6, 0x30, 0x82, 0x01, 0x7c, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x47, 0xed, 0x63, 0x68, 0x21, 0x97, + 0x69, 0x31, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, + 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x4f, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x18, 0x4d, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x49, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, + 0x65, 0x64, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x46, + 0x46, 0x46, 0x32, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x02, 0x0c, 0x04, + 0x38, 0x30, 0x30, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x2c, 0x06, 0x3c, 0x20, 0x8b, 0xb7, 0xcf, 0x3f, 0x89, 0xd8, 0x9c, + 0x70, 0xb2, 0x68, 0xde, 0xc2, 0xf0, 0xad, 0x89, 0x19, 0x2f, 0x02, 0x2f, 0x95, 0x47, 0xad, 0xcc, 0x72, 0x2a, 0x06, 0x80, 0x69, + 0xca, 0x72, 0x35, 0x60, 0x83, 0xb7, 0x24, 0x77, 0x1b, 0x21, 0x76, 0x4c, 0xb2, 0x4c, 0x57, 0x11, 0xb5, 0x3e, 0xfe, 0x87, 0xfe, + 0x4f, 0xe0, 0xb4, 0x73, 0x14, 0x1b, 0xcc, 0xa1, 0x04, 0xb2, 0x8d, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, + 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, + 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xd0, + 0x5a, 0x9b, 0x67, 0x71, 0xa1, 0xa3, 0x7a, 0x9b, 0xc1, 0x9d, 0x95, 0xe8, 0xb5, 0xdb, 0x8f, 0x43, 0x00, 0xb6, 0x3a, 0x30, 0x1f, + 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, + 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, 0x82, 0xd5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, + 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x21, 0x00, 0xe8, 0xb2, 0xc6, 0x11, 0x70, 0x4a, 0x54, 0x06, 0x79, 0x0c, 0xc5, 0xc8, + 0x87, 0x38, 0x38, 0x89, 0x03, 0x9c, 0x18, 0xed, 0xf2, 0x3d, 0x5e, 0xe2, 0x55, 0x15, 0x0e, 0x0f, 0xf4, 0x75, 0xef, 0xc9, 0x02, + 0x20, 0x7f, 0x0d, 0x94, 0x91, 0xe6, 0xe6, 0x91, 0xc0, 0x55, 0xcb, 0xa0, 0xb0, 0x4a, 0x72, 0x90, 0x76, 0xa2, 0x58, 0x2f, 0xb3, + 0xb9, 0xe3, 0x0a, 0x15, 0xbe, 0xc3, 0xd0, 0x5c, 0xe9, 0x11, 0x2f, 0xfc, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert = + ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert_Array); + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_SKID_Array[] = { + 0xD0, 0x5A, 0x9B, 0x67, 0x71, 0xA1, 0xA3, 0x7A, 0x9B, 0xC1, 0x9D, 0x95, 0xE8, 0xB5, 0xDB, 0x8F, 0x43, 0x00, 0xB6, 0x3A, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_SKID = + ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_SKID_Array); + // ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-8004-FB-Cert.pem constexpr uint8_t sTestCert_PAI_FFF2_8004_FB_Cert_Array[] = { @@ -3129,5 +3293,40 @@ constexpr uint8_t sTestCert_PAI_FFF2_NoPID_FB_PrivateKey_Array[] = { extern const ByteSpan sTestCert_PAI_FFF2_NoPID_FB_PrivateKey = ByteSpan(sTestCert_PAI_FFF2_NoPID_FB_PrivateKey_Array); +// ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.pem + +constexpr uint8_t sTestCert_PAI_FFF2_NoPID_Resigned_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xb7, 0x30, 0x82, 0x01, 0x5d, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x5d, 0x0a, 0x59, 0xc0, 0x17, 0x4b, + 0x3b, 0x65, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, + 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x30, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, + 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x46, 0x46, 0x46, 0x32, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, + 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, + 0xd8, 0xbf, 0x93, 0x47, 0x92, 0xcf, 0x8e, 0xae, 0xda, 0xc2, 0x4f, 0xfc, 0x96, 0x6c, 0x91, 0x76, 0x20, 0xfb, 0x97, 0x2f, 0xba, + 0xb9, 0x8e, 0xc6, 0xd5, 0x13, 0x14, 0xa0, 0x7a, 0xe9, 0x8e, 0x1a, 0x03, 0xfb, 0x41, 0x91, 0xd2, 0x6e, 0x2d, 0x12, 0x7c, 0xb9, + 0x52, 0x76, 0x21, 0xc3, 0x6e, 0x97, 0x3a, 0x18, 0x6c, 0x56, 0xd0, 0xca, 0xd9, 0x99, 0xb0, 0x41, 0xc2, 0x70, 0xa9, 0xb1, 0xcb, + 0x3f, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, + 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, + 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x61, 0x3d, 0xd0, 0x87, 0x35, 0x5e, 0xf0, 0x8b, 0xae, 0x01, 0xe4, + 0xc6, 0x9a, 0x8f, 0xc7, 0x3d, 0xac, 0x8c, 0x7d, 0xfd, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, + 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, 0x82, 0xd5, + 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x7e, 0x5f, + 0x9f, 0x5f, 0xff, 0x06, 0xeb, 0x39, 0xff, 0x13, 0x4f, 0x5a, 0xed, 0x7f, 0x3f, 0x96, 0x61, 0x3f, 0xe2, 0xf1, 0x7f, 0x4f, 0x7b, + 0xbf, 0x51, 0x24, 0x3e, 0x2a, 0x73, 0x53, 0x70, 0xf8, 0x02, 0x21, 0x00, 0xec, 0x54, 0x7d, 0x78, 0x73, 0xdb, 0x45, 0x80, 0xf1, + 0xe8, 0xd8, 0xe9, 0x2e, 0xca, 0xec, 0x24, 0x5d, 0x88, 0x0a, 0x88, 0x17, 0xfc, 0xd8, 0x1c, 0x67, 0xa8, 0xfa, 0xe4, 0x95, 0x8e, + 0xda, 0x82, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_NoPID_Resigned_Cert = ByteSpan(sTestCert_PAI_FFF2_NoPID_Resigned_Cert_Array); + +constexpr uint8_t sTestCert_PAI_FFF2_NoPID_Resigned_SKID_Array[] = { + 0x61, 0x3D, 0xD0, 0x87, 0x35, 0x5E, 0xF0, 0x8B, 0xAE, 0x01, 0xE4, 0xC6, 0x9A, 0x8F, 0xC7, 0x3D, 0xAC, 0x8C, 0x7D, 0xFD, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_NoPID_Resigned_SKID = ByteSpan(sTestCert_PAI_FFF2_NoPID_Resigned_SKID_Array); + } // namespace TestCerts } // namespace chip diff --git a/src/credentials/tests/CHIPAttCert_test_vectors.h b/src/credentials/tests/CHIPAttCert_test_vectors.h index a38a48e6fe81cd..2419c6bfd578c3 100644 --- a/src/credentials/tests/CHIPAttCert_test_vectors.h +++ b/src/credentials/tests/CHIPAttCert_test_vectors.h @@ -258,6 +258,9 @@ extern const ByteSpan sTestCert_PAA_NoVID_SKID; extern const ByteSpan sTestCert_PAA_NoVID_PublicKey; extern const ByteSpan sTestCert_PAA_NoVID_PrivateKey; +extern const ByteSpan sTestCert_PAA_NoVID_ToResignPAIs_Cert; +extern const ByteSpan sTestCert_PAA_NoVID_ToResignPAIs_SKID; + extern const ByteSpan sTestCert_PAI_FFF1_8000_Cert; extern const ByteSpan sTestCert_PAI_FFF1_8000_SKID; extern const ByteSpan sTestCert_PAI_FFF1_8000_PublicKey; @@ -268,6 +271,17 @@ extern const ByteSpan sTestCert_PAI_FFF2_8001_SKID; extern const ByteSpan sTestCert_PAI_FFF2_8001_PublicKey; extern const ByteSpan sTestCert_PAI_FFF2_8001_PrivateKey; +extern const ByteSpan sTestCert_PAI_FFF2_8001_Resigned_Cert; +extern const ByteSpan sTestCert_PAI_FFF2_8001_Resigned_SKID; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert; +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_SKID; +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PublicKey; +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PrivateKey; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert; +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_SKID; + extern const ByteSpan sTestCert_PAI_FFF2_8004_FB_Cert; extern const ByteSpan sTestCert_PAI_FFF2_8004_FB_SKID; extern const ByteSpan sTestCert_PAI_FFF2_8004_FB_PublicKey; @@ -308,5 +322,8 @@ extern const ByteSpan sTestCert_PAI_FFF2_NoPID_FB_SKID; extern const ByteSpan sTestCert_PAI_FFF2_NoPID_FB_PublicKey; extern const ByteSpan sTestCert_PAI_FFF2_NoPID_FB_PrivateKey; +extern const ByteSpan sTestCert_PAI_FFF2_NoPID_Resigned_Cert; +extern const ByteSpan sTestCert_PAI_FFF2_NoPID_Resigned_SKID; + } // namespace TestCerts } // namespace chip diff --git a/src/crypto/CHIPCryptoPAL.h b/src/crypto/CHIPCryptoPAL.h index e87400604d8a84..00733b7d9e7402 100644 --- a/src/crypto/CHIPCryptoPAL.h +++ b/src/crypto/CHIPCryptoPAL.h @@ -1492,6 +1492,29 @@ CHIP_ERROR ExtractSKIDFromX509Cert(const ByteSpan & certificate, MutableByteSpan **/ CHIP_ERROR ExtractAKIDFromX509Cert(const ByteSpan & certificate, MutableByteSpan & akid); +/** + * @brief Checks for resigned version of the certificate in the list and returns it. + * + * The following conditions SHOULD be satisfied for the certificate to qualify as + * a resigned version of a reference certificate: + * - SKID of the candidate and the reference certificate should match. + * - SubjectDN of the candidate and the reference certificate should match. + * + * If no resigned version is found then reference certificate itself is returned. + * + * @param referenceCertificate A DER certificate. + * @param candidateCertificates A pointer to the list of DER Certificates, which should be searched + * for the resigned version of `referenceCertificate`. + * @param candidateCertificatesCount Number of certificates in the `candidateCertificates` list. + * @param outCertificate A reference to the certificate or it's resigned version if found. + * Note that it points to either `referenceCertificate` or one of + * `candidateCertificates`, but it doesn't copy data. + * + * @returns error if there is certificate parsing/format issue or CHIP_NO_ERROR otherwise. + **/ +CHIP_ERROR ReplaceCertIfResignedCertFound(const ByteSpan & referenceCertificate, const ByteSpan * candidateCertificates, + size_t candidateCertificatesCount, ByteSpan & outCertificate); + /** * Defines DN attribute types that can include endocing of VID/PID parameters. */ diff --git a/src/crypto/CHIPCryptoPALOpenSSL.cpp b/src/crypto/CHIPCryptoPALOpenSSL.cpp index 8a24fde3c54fd4..def307997f5e04 100644 --- a/src/crypto/CHIPCryptoPALOpenSSL.cpp +++ b/src/crypto/CHIPCryptoPALOpenSSL.cpp @@ -2045,5 +2045,65 @@ CHIP_ERROR ExtractVIDPIDFromX509Cert(const ByteSpan & certificate, AttestationCe return err; } +CHIP_ERROR ReplaceCertIfResignedCertFound(const ByteSpan & referenceCertificate, const ByteSpan * candidateCertificates, + size_t candidateCertificatesCount, ByteSpan & outCertificate) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + X509 * x509ReferenceCertificate = nullptr; + X509 * x509CandidateCertificate = nullptr; + const uint8_t * pReferenceCertificate = referenceCertificate.data(); + X509_NAME * referenceSubject = nullptr; + X509_NAME * candidateSubject = nullptr; + uint8_t referenceSKIDBuf[kSubjectKeyIdentifierLength]; + uint8_t candidateSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan referenceSKID(referenceSKIDBuf); + MutableByteSpan candidateSKID(candidateSKIDBuf); + + ReturnErrorCodeIf(referenceCertificate.empty(), CHIP_ERROR_INVALID_ARGUMENT); + + outCertificate = referenceCertificate; + + ReturnErrorCodeIf(candidateCertificates == nullptr || candidateCertificatesCount == 0, CHIP_NO_ERROR); + + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(referenceCertificate, referenceSKID)); + + x509ReferenceCertificate = d2i_X509(nullptr, &pReferenceCertificate, static_cast(referenceCertificate.size())); + VerifyOrExit(x509ReferenceCertificate != nullptr, err = CHIP_ERROR_NO_MEMORY); + + referenceSubject = X509_get_subject_name(x509ReferenceCertificate); + VerifyOrExit(referenceSubject != nullptr, err = CHIP_ERROR_INTERNAL); + + for (size_t i = 0; i < candidateCertificatesCount; i++) + { + const ByteSpan candidateCertificate = candidateCertificates[i]; + const uint8_t * pCandidateCertificate = candidateCertificate.data(); + + VerifyOrExit(!candidateCertificate.empty(), err = CHIP_ERROR_INVALID_ARGUMENT); + + SuccessOrExit(err = ExtractSKIDFromX509Cert(candidateCertificate, candidateSKID)); + + x509CandidateCertificate = d2i_X509(nullptr, &pCandidateCertificate, static_cast(candidateCertificate.size())); + VerifyOrExit(x509CandidateCertificate != nullptr, err = CHIP_ERROR_NO_MEMORY); + + candidateSubject = X509_get_subject_name(x509CandidateCertificate); + VerifyOrExit(candidateSubject != nullptr, err = CHIP_ERROR_INTERNAL); + + if (referenceSKID.data_equal(candidateSKID) && X509_NAME_cmp(referenceSubject, candidateSubject) == 0) + { + outCertificate = candidateCertificate; + ExitNow(); + } + + X509_free(x509CandidateCertificate); + x509CandidateCertificate = nullptr; + } + +exit: + X509_free(x509ReferenceCertificate); + X509_free(x509CandidateCertificate); + + return err; +} + } // namespace Crypto } // namespace chip diff --git a/src/crypto/CHIPCryptoPALTinyCrypt.cpp b/src/crypto/CHIPCryptoPALTinyCrypt.cpp index b89bbcd22a76b3..dd6f875a58287b 100644 --- a/src/crypto/CHIPCryptoPALTinyCrypt.cpp +++ b/src/crypto/CHIPCryptoPALTinyCrypt.cpp @@ -1691,5 +1691,82 @@ CHIP_ERROR ExtractVIDPIDFromX509Cert(const ByteSpan & certificate, AttestationCe return error; } +namespace { +#if defined(MBEDTLS_X509_CRT_PARSE_C) +CHIP_ERROR ExtractRawSubjectFromX509Cert(const ByteSpan & certificate, MutableByteSpan & subject) +{ + CHIP_ERROR error = CHIP_NO_ERROR; + int result = 0; + uint8_t * p = nullptr; + size_t len = 0; + mbedtls_x509_crt mbedCertificate; + + ReturnErrorCodeIf(certificate.empty(), CHIP_ERROR_INVALID_ARGUMENT); + + mbedtls_x509_crt_init(&mbedCertificate); + result = mbedtls_x509_crt_parse(&mbedCertificate, Uint8::to_const_uchar(certificate.data()), certificate.size()); + VerifyOrExit(result == 0, error = CHIP_ERROR_INTERNAL); + + len = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(len); + p = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(p); + + VerifyOrExit(len <= subject.size(), error = CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(subject.data(), p, len); + subject.reduce_size(len); + +exit: + _log_mbedTLS_error(result); + mbedtls_x509_crt_free(&mbedCertificate); + + return error; +} +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} // namespace + +CHIP_ERROR ReplaceCertIfResignedCertFound(const ByteSpan & referenceCertificate, const ByteSpan * candidateCertificates, + size_t candidateCertificatesCount, ByteSpan & outCertificate) +{ +#if defined(MBEDTLS_X509_CRT_PARSE_C) + constexpr size_t kMaxCertificateSubjectLength = 150; + uint8_t referenceSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t referenceSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan referenceSubject(referenceSubjectBuf); + MutableByteSpan referenceSKID(referenceSKIDBuf); + + outCertificate = referenceCertificate; + + ReturnErrorCodeIf(candidateCertificates == nullptr || candidateCertificatesCount == 0, CHIP_NO_ERROR); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(referenceCertificate, referenceSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(referenceCertificate, referenceSKID)); + + for (size_t i = 0; i < candidateCertificatesCount; i++) + { + const ByteSpan candidateCertificate = candidateCertificates[i]; + uint8_t candidateSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t candidateSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan candidateSubject(candidateSubjectBuf); + MutableByteSpan candidateSKID(candidateSKIDBuf); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(candidateCertificate, candidateSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(candidateCertificate, candidateSKID)); + + if (referenceSKID.data_equal(candidateSKID) && referenceSubject.data_equal(candidateSubject)) + { + outCertificate = candidateCertificate; + return CHIP_NO_ERROR; + } + } + + return CHIP_NO_ERROR; +#else + (void) referenceCertificate; + (void) candidateCertificates; + (void) candidateCertificatesCount; + (void) outCertificate; + return CHIP_ERROR_NOT_IMPLEMENTED; +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} + } // namespace Crypto } // namespace chip diff --git a/src/crypto/CHIPCryptoPALmbedTLS.cpp b/src/crypto/CHIPCryptoPALmbedTLS.cpp index 2ce3bc7aba8c30..ff42f9e3df411b 100644 --- a/src/crypto/CHIPCryptoPALmbedTLS.cpp +++ b/src/crypto/CHIPCryptoPALmbedTLS.cpp @@ -1836,5 +1836,82 @@ CHIP_ERROR ExtractVIDPIDFromX509Cert(const ByteSpan & certificate, AttestationCe return error; } +namespace { +#if defined(MBEDTLS_X509_CRT_PARSE_C) +CHIP_ERROR ExtractRawSubjectFromX509Cert(const ByteSpan & certificate, MutableByteSpan & subject) +{ + CHIP_ERROR error = CHIP_NO_ERROR; + int result = 0; + uint8_t * p = nullptr; + size_t len = 0; + mbedtls_x509_crt mbedCertificate; + + ReturnErrorCodeIf(certificate.empty(), CHIP_ERROR_INVALID_ARGUMENT); + + mbedtls_x509_crt_init(&mbedCertificate); + result = mbedtls_x509_crt_parse(&mbedCertificate, Uint8::to_const_uchar(certificate.data()), certificate.size()); + VerifyOrExit(result == 0, error = CHIP_ERROR_INTERNAL); + + len = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(len); + p = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(p); + + VerifyOrExit(len <= subject.size(), error = CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(subject.data(), p, len); + subject.reduce_size(len); + +exit: + _log_mbedTLS_error(result); + mbedtls_x509_crt_free(&mbedCertificate); + + return error; +} +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} // namespace + +CHIP_ERROR ReplaceCertIfResignedCertFound(const ByteSpan & referenceCertificate, const ByteSpan * candidateCertificates, + size_t candidateCertificatesCount, ByteSpan & outCertificate) +{ +#if defined(MBEDTLS_X509_CRT_PARSE_C) + constexpr size_t kMaxCertificateSubjectLength = 150; + uint8_t referenceSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t referenceSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan referenceSubject(referenceSubjectBuf); + MutableByteSpan referenceSKID(referenceSKIDBuf); + + outCertificate = referenceCertificate; + + ReturnErrorCodeIf(candidateCertificates == nullptr || candidateCertificatesCount == 0, CHIP_NO_ERROR); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(referenceCertificate, referenceSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(referenceCertificate, referenceSKID)); + + for (size_t i = 0; i < candidateCertificatesCount; i++) + { + const ByteSpan candidateCertificate = candidateCertificates[i]; + uint8_t candidateSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t candidateSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan candidateSubject(candidateSubjectBuf); + MutableByteSpan candidateSKID(candidateSKIDBuf); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(candidateCertificate, candidateSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(candidateCertificate, candidateSKID)); + + if (referenceSKID.data_equal(candidateSKID) && referenceSubject.data_equal(candidateSubject)) + { + outCertificate = candidateCertificate; + return CHIP_NO_ERROR; + } + } + + return CHIP_NO_ERROR; +#else + (void) referenceCertificate; + (void) candidateCertificates; + (void) candidateCertificatesCount; + (void) outCertificate; + return CHIP_ERROR_NOT_IMPLEMENTED; +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} + } // namespace Crypto } // namespace chip diff --git a/src/crypto/tests/CHIPCryptoPALTest.cpp b/src/crypto/tests/CHIPCryptoPALTest.cpp index f79a967f652f74..c8b2810ddd0f40 100644 --- a/src/crypto/tests/CHIPCryptoPALTest.cpp +++ b/src/crypto/tests/CHIPCryptoPALTest.cpp @@ -2301,6 +2301,87 @@ static void TestVIDPID_x509Extraction(nlTestSuite * inSuite, void * inContext) } } +static void TestX509_ReplaceCertIfResignedCertFound(nlTestSuite * inSuite, void * inContext) +{ + using namespace TestCerts; + + HeapChecker heapChecker(inSuite); + + struct TestCase + { + ByteSpan referenceCert; + ByteSpan * candidateCertsList; + size_t candidateCertsCount; + ByteSpan expectedOutCert; + }; + + // clang-format off + ByteSpan TestCandidateCertsList1[] = { sTestCert_DAC_FFF1_8000_0004_Cert, + sTestCert_PAI_FFF2_8004_FB_Cert, + sTestCert_PAA_FFF1_Cert }; + ByteSpan TestCandidateCertsList2[] = { sTestCert_DAC_FFF1_8000_0004_Cert, + sTestCert_PAI_FFF2_NoPID_Resigned_Cert }; + ByteSpan TestCandidateCertsList3[] = { sTestCert_DAC_FFF1_8000_0004_Cert, + sTestCert_PAI_FFF2_8001_Resigned_Cert }; + ByteSpan TestCandidateCertsList4[] = { sTestCert_PAI_FFF2_8001_Resigned_Cert, + sTestCert_PAI_FFF1_8000_Cert }; + ByteSpan TestCandidateCertsList5[] = { sTestCert_PAI_FFF2_NoPID_Resigned_Cert, + sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert }; + ByteSpan TestCandidateCertsList6[] = { sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert, + sTestCert_DAC_FFF1_8000_0004_Cert }; + ByteSpan TestCandidateCertsList7[] = { sTestCert_PAA_NoVID_ToResignPAIs_Cert, + sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert, + sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert, + sTestCert_PAI_FFF2_8001_Resigned_Cert, + sTestCert_PAI_FFF2_NoPID_Resigned_Cert }; + ByteSpan TestCandidateCertsList8[] = { sTestCert_PAA_NoVID_ToResignPAIs_Cert, + sTestCert_PAI_FFF2_8001_Resigned_Cert, + ByteSpan(), + sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert, + sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert, + sTestCert_PAI_FFF2_NoPID_Resigned_Cert }; + + const TestCase kTestCases[] = { + { sTestCert_PAI_FFF2_8001_Cert, nullptr, 5, sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList3, 0, sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF1_8000_Cert, TestCandidateCertsList1, ArraySize(TestCandidateCertsList1), sTestCert_PAI_FFF1_8000_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList2, ArraySize(TestCandidateCertsList2), sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList3, ArraySize(TestCandidateCertsList3), sTestCert_PAI_FFF2_8001_Resigned_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList4, ArraySize(TestCandidateCertsList4), sTestCert_PAI_FFF2_8001_Resigned_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList5, ArraySize(TestCandidateCertsList5), sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList6, ArraySize(TestCandidateCertsList6), sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList7, ArraySize(TestCandidateCertsList7), sTestCert_PAI_FFF2_8001_Resigned_Cert }, + { sTestCert_PAI_FFF2_NoPID_Cert, TestCandidateCertsList7, ArraySize(TestCandidateCertsList7), sTestCert_PAI_FFF2_NoPID_Resigned_Cert }, + }; + // clang-format on + + for (const auto & testCase : kTestCases) + { + ByteSpan outCert; + CHIP_ERROR result = ReplaceCertIfResignedCertFound(testCase.referenceCert, testCase.candidateCertsList, + testCase.candidateCertsCount, outCert); + + NL_TEST_ASSERT(inSuite, result == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, outCert.data_equal(testCase.expectedOutCert)); + } + + // Error case: invalid input argument for referenceCertificate + { + ByteSpan outCert; + CHIP_ERROR result = + ReplaceCertIfResignedCertFound(ByteSpan(), TestCandidateCertsList7, ArraySize(TestCandidateCertsList7), outCert); + NL_TEST_ASSERT(inSuite, result == CHIP_ERROR_INVALID_ARGUMENT); + } + + // Error case: invalid input argument for one of the certificates in the candidateCertificates list + { + ByteSpan outCert; + CHIP_ERROR result = + ReplaceCertIfResignedCertFound(ByteSpan(), TestCandidateCertsList8, ArraySize(TestCandidateCertsList8), outCert); + NL_TEST_ASSERT(inSuite, result == CHIP_ERROR_INVALID_ARGUMENT); + } +} + static const uint8_t kCompressedFabricId[] = { 0x29, 0x06, 0xC9, 0x08, 0xD1, 0x15, 0xD3, 0x62 }; const uint8_t kEpochKeyBuffer1[Crypto::CHIP_CRYPTO_SYMMETRIC_KEY_LENGTH_BYTES] = { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, @@ -2462,6 +2543,7 @@ static const nlTest sTests[] = { NL_TEST_DEF("Test Authority Key Id Extraction from x509 Certificate", TestAKID_x509Extraction), NL_TEST_DEF("Test Vendor ID and Product ID Extraction from Attribute String", TestVIDPID_StringExtraction), NL_TEST_DEF("Test Vendor ID and Product ID Extraction from x509 Attestation Certificate", TestVIDPID_x509Extraction), + NL_TEST_DEF("Test Replace Resigned Certificate Version if Found", TestX509_ReplaceCertIfResignedCertFound), NL_TEST_DEF("Test Group Operation Key Derivation", TestGroup_OperationalKeyDerivation), NL_TEST_DEF("Test Group Session ID Derivation", TestGroup_SessionIdDerivation), NL_TEST_DEF("Test Group Privacy Key Derivation", TestGroup_PrivacyKeyDerivation), diff --git a/src/platform/silabs/EFR32/CHIPCryptoPALPsaEfr32.cpp b/src/platform/silabs/EFR32/CHIPCryptoPALPsaEfr32.cpp index bcf252a86754de..184da071eeddce 100644 --- a/src/platform/silabs/EFR32/CHIPCryptoPALPsaEfr32.cpp +++ b/src/platform/silabs/EFR32/CHIPCryptoPALPsaEfr32.cpp @@ -1875,5 +1875,82 @@ CHIP_ERROR ExtractVIDPIDFromX509Cert(const ByteSpan & certificate, AttestationCe return error; } +namespace { +#if defined(MBEDTLS_X509_CRT_PARSE_C) +CHIP_ERROR ExtractRawSubjectFromX509Cert(const ByteSpan & certificate, MutableByteSpan & subject) +{ + CHIP_ERROR error = CHIP_NO_ERROR; + int result = 0; + uint8_t * p = nullptr; + size_t len = 0; + mbedtls_x509_crt mbedCertificate; + + ReturnErrorCodeIf(certificate.empty(), CHIP_ERROR_INVALID_ARGUMENT); + + mbedtls_x509_crt_init(&mbedCertificate); + result = mbedtls_x509_crt_parse(&mbedCertificate, Uint8::to_const_uchar(certificate.data()), certificate.size()); + VerifyOrExit(result == 0, error = CHIP_ERROR_INTERNAL); + + len = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(len); + p = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(p); + + VerifyOrExit(len <= subject.size(), error = CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(subject.data(), p, len); + subject.reduce_size(len); + +exit: + _log_mbedTLS_error(result); + mbedtls_x509_crt_free(&mbedCertificate); + + return error; +} +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} // namespace + +CHIP_ERROR ReplaceCertIfResignedCertFound(const ByteSpan & referenceCertificate, const ByteSpan * candidateCertificates, + size_t candidateCertificatesCount, ByteSpan & outCertificate) +{ +#if defined(MBEDTLS_X509_CRT_PARSE_C) + constexpr size_t kMaxCertificateSubjectLength = 150; + uint8_t referenceSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t referenceSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan referenceSubject(referenceSubjectBuf); + MutableByteSpan referenceSKID(referenceSKIDBuf); + + outCertificate = referenceCertificate; + + ReturnErrorCodeIf(candidateCertificates == nullptr || candidateCertificatesCount == 0, CHIP_NO_ERROR); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(referenceCertificate, referenceSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(referenceCertificate, referenceSKID)); + + for (size_t i = 0; i < candidateCertificatesCount; i++) + { + const ByteSpan candidateCertificate = candidateCertificates[i]; + uint8_t candidateSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t candidateSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan candidateSubject(candidateSubjectBuf); + MutableByteSpan candidateSKID(candidateSKIDBuf); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(candidateCertificate, candidateSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(candidateCertificate, candidateSKID)); + + if (referenceSKID.data_equal(candidateSKID) && referenceSubject.data_equal(candidateSubject)) + { + outCertificate = candidateCertificate; + return CHIP_NO_ERROR; + } + } + + return CHIP_NO_ERROR; +#else + (void) referenceCertificate; + (void) candidateCertificates; + (void) candidateCertificatesCount; + (void) outCertificate; + return CHIP_ERROR_NOT_IMPLEMENTED; +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} + } // namespace Crypto } // namespace chip From 3012b1826f5dd8a689f63e39fbbb5de3d2d69a72 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 5 Jan 2023 19:27:15 +0100 Subject: [PATCH 10/14] [third_party] Add libwebsockets to third_party with a lws_config.h file that makes it server only (#24280) --- .gitmodules | 4 + third_party/libwebsockets/BUILD.gn | 109 ++++++++++++++++++ third_party/libwebsockets/lws_config.h | 65 +++++++++++ .../libwebsockets/lws_config_private.h | 19 +++ third_party/libwebsockets/repo | 1 + 5 files changed, 198 insertions(+) create mode 100644 third_party/libwebsockets/BUILD.gn create mode 100644 third_party/libwebsockets/lws_config.h create mode 100644 third_party/libwebsockets/lws_config_private.h create mode 160000 third_party/libwebsockets/repo diff --git a/.gitmodules b/.gitmodules index f211ca385789ff..9e5b4f09f0fb39 100644 --- a/.gitmodules +++ b/.gitmodules @@ -290,3 +290,7 @@ url = https://github.com/bouffalolab/bl_iot_sdk_tiny.git branch = main platforms = bouffalolab +[submodule "third_party/libwebsockets/repo"] + path = third_party/libwebsockets/repo + url = https://github.com/warmcat/libwebsockets + platforms = linux,darwin diff --git a/third_party/libwebsockets/BUILD.gn b/third_party/libwebsockets/BUILD.gn new file mode 100644 index 00000000000000..8e759cc4dc601f --- /dev/null +++ b/third_party/libwebsockets/BUILD.gn @@ -0,0 +1,109 @@ +# Copyright (c) 2023 Project CHIP Authors +# +# 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. + +config("libwebsockets_config") { + include_dirs = [ + ".", + "repo/include", + ] + + cflags = [ + "-Wno-shadow", + "-Wno-unreachable-code", + "-Wno-format-nonliteral", + ] + + defines = [] +} + +source_set("libwebsockets") { + include_dirs = [ + "repo/lib/plat/windows", + "repo/lib/plat/freertos", + "repo/lib/plat/unix", + "repo/lib/secure-streams", + "repo/lib/event-libs", + "repo/lib/roles", + "repo/lib/roles/http", + "repo/lib/roles/h1", + "repo/lib/roles/h2", + "repo/lib/roles/ws", + "repo/lib/system/metrics", + "repo/lib/system/smd", + "repo/lib/system/async-dns", + "repo/lib/core", + "repo/lib/core-net", + ] + + sources = [ + "repo/lib/core-net/adopt.c", + "repo/lib/core-net/close.c", + "repo/lib/core-net/dummy-callback.c", + "repo/lib/core-net/network.c", + "repo/lib/core-net/output.c", + "repo/lib/core-net/pollfd.c", + "repo/lib/core-net/service.c", + "repo/lib/core-net/sorted-usec-list.c", + "repo/lib/core-net/vhost.c", + "repo/lib/core-net/wsi-timeout.c", + "repo/lib/core-net/wsi.c", + "repo/lib/core/alloc.c", + "repo/lib/core/buflist.c", + "repo/lib/core/context.c", + "repo/lib/core/libwebsockets.c", + "repo/lib/core/logs.c", + "repo/lib/core/lws_dll2.c", + "repo/lib/event-libs/poll/poll.c", + "repo/lib/misc/base64-decode.c", + "repo/lib/misc/sha-1.c", + "repo/lib/roles/h1/ops-h1.c", + "repo/lib/roles/http/date.c", + "repo/lib/roles/http/header.c", + "repo/lib/roles/http/parsers.c", + "repo/lib/roles/http/server/server.c", + "repo/lib/roles/listen/ops-listen.c", + "repo/lib/roles/pipe/ops-pipe.c", + "repo/lib/roles/raw-skt/ops-raw-skt.c", + "repo/lib/roles/ws/ops-ws.c", + "repo/lib/roles/ws/server-ws.c", + "repo/lib/system/system.c", + ] + + if (current_os == "freertos") { + sources += [ + "repo/lib/plat/freertos/freertos-fds.c", + "repo/lib/plat/freertos/freertos-init.c", + "repo/lib/plat/freertos/freertos-misc.c", + "repo/lib/plat/freertos/freertos-pipe.c", + "repo/lib/plat/freertos/freertos-service.c", + "repo/lib/plat/freertos/freertos-sockets.c", + ] + + cflags = [ "-DLWS_PLAT_FREERTOS" ] + } else { + sources += [ + "repo/lib/plat/unix/unix-caps.c", + "repo/lib/plat/unix/unix-fds.c", + "repo/lib/plat/unix/unix-init.c", + "repo/lib/plat/unix/unix-misc.c", + "repo/lib/plat/unix/unix-pipe.c", + "repo/lib/plat/unix/unix-service.c", + "repo/lib/plat/unix/unix-sockets.c", + ] + + cflags = [ "-DLWS_PLAT_UNIX" ] + } + + public_configs = [ ":libwebsockets_config" ] +} diff --git a/third_party/libwebsockets/lws_config.h b/third_party/libwebsockets/lws_config.h new file mode 100644 index 00000000000000..96ddcf8a6db7d9 --- /dev/null +++ b/third_party/libwebsockets/lws_config.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 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 + +#define LWS_LIBRARY_VERSION "4.3.99" + +// +// Major individual features +// +#define LWS_WITH_NETWORK // "Compile with network-related code" - default: ON +#define LWS_ROLE_H1 // "Compile with support for http/1 (needed for ws)" - default: ON +#define LWS_ROLE_WS // "Compile with support for websockets" - default: ON +#define LWS_WITH_IPV6 // "Compile with support for ipv6" - default: OFF +#define LWS_UNIX_SOCK // "Compile with support for UNIX domain socket if OS supports it" - default: ON + +// +// Client / Server / Test Apps build control +// +#define LWS_WITHOUT_CLIENT // "Don't build the client part of the library" default - OFF + +// +// Extensions (permessage-deflate) +// +#define LWS_WITHOUT_EXTENSIONS // "Don't compile with extensions" - default: ON + +// +// Helpers + misc +// +#define LWS_WITHOUT_DAEMONIZE // "Don't build the daemonization api" - default: ON +#define LWS_LOGS_TIMESTAMP // "Timestamp at start of logs" - default: ON +#define LWS_LOG_TAG_LIFECYCLE // "Log tagged object lifecycle as NOTICE" - default: ON + +// +// Implied Options +// +#define LWS_WITH_POLL +#define LWS_MAX_SMP 1 + +#ifdef LWS_WITHOUT_DAEMONIZE +#define LWS_NO_DAEMONIZE +#endif + +#ifdef LWS_WITH_HTTP2 +#define LWS_ROLE_H2 +#endif + +#ifndef LWS_WITHOUT_SERVER +#define LWS_WITH_SERVER +#endif diff --git a/third_party/libwebsockets/lws_config_private.h b/third_party/libwebsockets/lws_config_private.h new file mode 100644 index 00000000000000..468bba9a126d4f --- /dev/null +++ b/third_party/libwebsockets/lws_config_private.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 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 diff --git a/third_party/libwebsockets/repo b/third_party/libwebsockets/repo new file mode 160000 index 00000000000000..ec6d5ac6d58d92 --- /dev/null +++ b/third_party/libwebsockets/repo @@ -0,0 +1 @@ +Subproject commit ec6d5ac6d58d92ac8c1a3d769d076cabd6aa4ac1 From e59000e042cf49c6b7fca4d34adc919a3d6b2fbd Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Fri, 6 Jan 2023 04:21:44 +0800 Subject: [PATCH 11/14] use docker image 0.6.27 (#24273) * use docker image 0.6.27 * [mbedtls] Update filepath Fix CI error for new docker image. * Move cloudbuild and chef back to 0.6.18 for compilation until NRF is compatible with latest SDK * Do not update the telink docker image yet Co-authored-by: Andrei Litvin --- .devcontainer/devcontainer.json | 2 +- .github/workflows/bloat_check.yaml | 2 +- .github/workflows/build.yaml | 6 +++--- .github/workflows/chef.yaml | 5 +++-- .github/workflows/cirque.yaml | 4 ++-- .github/workflows/doxygen.yaml | 2 +- .github/workflows/examples-ameba.yaml | 2 +- .github/workflows/examples-bouffalolab.yaml | 2 +- .github/workflows/examples-cc13x2x7_26x2x7.yaml | 2 +- .github/workflows/examples-efr32.yaml | 2 +- .github/workflows/examples-esp32.yaml | 4 ++-- .github/workflows/examples-infineon.yaml | 2 +- .github/workflows/examples-k32w.yaml | 2 +- .github/workflows/examples-linux-arm.yaml | 2 +- .github/workflows/examples-linux-imx.yaml | 2 +- .github/workflows/examples-linux-standalone.yaml | 2 +- .github/workflows/examples-mbed.yaml | 2 +- .github/workflows/examples-mw320.yaml | 2 +- .github/workflows/examples-nrfconnect.yaml | 2 +- .github/workflows/examples-openiotsdk.yaml | 2 +- .github/workflows/examples-qpg.yaml | 2 +- .github/workflows/examples-telink.yaml | 1 + .github/workflows/examples-tizen.yaml | 2 +- .github/workflows/full-android.yaml | 2 +- .github/workflows/fuzzing-build.yaml | 2 +- .github/workflows/qemu.yaml | 2 +- .github/workflows/release_artifacts.yaml | 4 ++-- .github/workflows/smoketest-android.yaml | 2 +- .github/workflows/tests.yaml | 6 +++--- .github/workflows/unit_integration_test.yaml | 2 +- .github/workflows/zap_regeneration.yaml | 2 +- .github/workflows/zap_templates.yaml | 2 +- integrations/cloudbuild/build-all.yaml | 5 +++-- integrations/cloudbuild/build-coverage.yaml | 4 ++-- integrations/cloudbuild/chef.yaml | 6 +++--- integrations/cloudbuild/smoke-test.yaml | 13 +++++++------ third_party/ameba/mbedtls.cmake | 2 +- 37 files changed, 57 insertions(+), 53 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 95625da71a1e40..5ddef22276ed10 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "BUILD_VERSION": "0.6.18" + "BUILD_VERSION": "0.6.27" } }, "remoteUser": "vscode", diff --git a/.github/workflows/bloat_check.yaml b/.github/workflows/bloat_check.yaml index b5325da5ec1ff3..ba734f22758ca9 100644 --- a/.github/workflows/bloat_check.yaml +++ b/.github/workflows/bloat_check.yaml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 443210b15c3c05..00ab192750e13f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -138,7 +138,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -308,7 +308,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 3a7a91d60663e9..eca0463b31931a 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -29,7 +29,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --user root steps: @@ -57,7 +57,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 options: --user root steps: @@ -85,6 +85,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: + # TODO: update this to connectedhomeip/chip-build-vscode:0.6.27 once we can compile with latest NRF image: connectedhomeip/chip-build-nrf-platform:0.6.18 options: --user root diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index c55e84b7a9273d..58fc8091a224df 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -29,7 +29,7 @@ jobs: timeout-minutes: 90 env: - DOCKER_RUN_VERSION: 0.6.18 + DOCKER_RUN_VERSION: 0.6.27 GITHUB_CACHE_PATH: /tmp/cirque-cache/ runs-on: ubuntu-latest @@ -38,7 +38,7 @@ jobs: # need to run with privilege, which isn't supported by job.XXX.contaner # https://github.com/actions/container-action/issues/2 # container: - # image: connectedhomeip/chip-build-cirque:0.6.18 + # image: connectedhomeip/chip-build-cirque:0.6.27 # volumes: # - "/tmp:/tmp" # - "/dev/pts:/dev/pts" diff --git a/.github/workflows/doxygen.yaml b/.github/workflows/doxygen.yaml index d5f84576ff0fc7..669efca5f6d4c7 100644 --- a/.github/workflows/doxygen.yaml +++ b/.github/workflows/doxygen.yaml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-doxygen:0.6.18 + image: connectedhomeip/chip-build-doxygen:0.6.27 if: github.actor != 'restyled-io[bot]' diff --git a/.github/workflows/examples-ameba.yaml b/.github/workflows/examples-ameba.yaml index 6986e6b6bda00b..3b568a270aa0ae 100644 --- a/.github/workflows/examples-ameba.yaml +++ b/.github/workflows/examples-ameba.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ameba:0.6.18 + image: connectedhomeip/chip-build-ameba:0.6.27 options: --user root steps: diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index a62e0dad3c74dd..04331435bc6e14 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-bouffalolab:0.6.18 + image: connectedhomeip/chip-build-bouffalolab:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index aa11433edd9fa6..99baf383bbaf3f 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.6.18 + image: connectedhomeip/chip-build-ti:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 30374f090bfe96..90e0e397c82517 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-efr32:0.6.18 + image: connectedhomeip/chip-build-efr32:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 61d9d032042c9d..13a025fe229767 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -140,7 +140,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 51d89d81c0b316..bb629fa999fcf2 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-infineon:0.6.18 + image: connectedhomeip/chip-build-infineon:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 76f8d8237f2d56..53b1aa46701771 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.6.18 + image: connectedhomeip/chip-build-k32w:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-linux-arm.yaml b/.github/workflows/examples-linux-arm.yaml index 1a5b9c07395482..159960bef927a4 100644 --- a/.github/workflows/examples-linux-arm.yaml +++ b/.github/workflows/examples-linux-arm.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-crosscompile:0.6.18 + image: connectedhomeip/chip-build-crosscompile:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-linux-imx.yaml b/.github/workflows/examples-linux-imx.yaml index b8bfdc0c086c14..42f426bfa959b0 100644 --- a/.github/workflows/examples-linux-imx.yaml +++ b/.github/workflows/examples-linux-imx.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-imx:0.6.18 + image: connectedhomeip/chip-build-imx:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index 2c09f5871e7f7f..11c913cfee488c 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index 3a9d522b1aa676..91f9f6f82a2097 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -40,7 +40,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-mbed-os:0.6.18 + image: connectedhomeip/chip-build-mbed-os:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mw320.yaml b/.github/workflows/examples-mw320.yaml index aedded0398df28..7fc6238cc81034 100755 --- a/.github/workflows/examples-mw320.yaml +++ b/.github/workflows/examples-mw320.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 7d0c274dc2d029..1fa32d751037e8 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.6.18 + image: connectedhomeip/chip-build-nrf-platform:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-openiotsdk.yaml b/.github/workflows/examples-openiotsdk.yaml index f3b49f828704ff..7e043d58d98ee5 100644 --- a/.github/workflows/examples-openiotsdk.yaml +++ b/.github/workflows/examples-openiotsdk.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-openiotsdk:0.6.18 + image: connectedhomeip/chip-build-openiotsdk:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" options: --privileged diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index c32dd590ddc930..35bc2987a4d10a 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 2099621e165ed3..9e5737c84828f9 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -35,6 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: + # TODO: update this to connectedhomeip/chip-build-vscode:0.6.27 once we can compile image: connectedhomeip/chip-build-telink:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 259733a008237c..8f892c8c712f13 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -33,7 +33,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-tizen:0.6.18 + image: connectedhomeip/chip-build-tizen:0.6.27 options: --user root volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index 1173adaf7c82d5..8f87a48a9e6043 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.18 + image: connectedhomeip/chip-build-android:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/fuzzing-build.yaml b/.github/workflows/fuzzing-build.yaml index bd96ff35792e31..bfb1eac538a138 100644 --- a/.github/workflows/fuzzing-build.yaml +++ b/.github/workflows/fuzzing-build.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 1a0c88e28d47b3..965e69ae1f3576 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32-qemu:0.6.18 + image: connectedhomeip/chip-build-esp32-qemu:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index 6b57156ba01f2d..5a6c13f85f8f14 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-efr32:0.6.18 + image: connectedhomeip/chip-build-efr32:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 name: Checkout diff --git a/.github/workflows/smoketest-android.yaml b/.github/workflows/smoketest-android.yaml index 04c4c8ecb77d2b..dc8ee425c28fca 100644 --- a/.github/workflows/smoketest-android.yaml +++ b/.github/workflows/smoketest-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.18 + image: connectedhomeip/chip-build-android:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8f96c75a1e280b..e492cba4c6b360 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" @@ -352,7 +352,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" @@ -426,7 +426,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index a0ea6842e24dc0..a6cb192b058a99 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index 19960d000c4fcb..1906613500816d 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.25 + image: connectedhomeip/chip-build:0.6.27 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index e35ad0d7495d16..b7459e76d53996 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.25 + image: connectedhomeip/chip-build:0.6.27 defaults: run: shell: sh diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml index 5a80129f54496b..863a7105c23290 100644 --- a/integrations/cloudbuild/build-all.yaml +++ b/integrations/cloudbuild/build-all.yaml @@ -6,7 +6,7 @@ steps: - "--init" - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -21,7 +21,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -76,6 +76,7 @@ steps: --target k32w-shell build --create-archives /workspace/artifacts/ + # TODO: update this to connectedhomeip/chip-build-vscode:0.6.27 once we can compile with latest NRF - name: "connectedhomeip/chip-build-vscode:0.6.18" env: - PW_ENVIRONMENT_ROOT=/pwenv diff --git a/integrations/cloudbuild/build-coverage.yaml b/integrations/cloudbuild/build-coverage.yaml index 3973c85147a623..8beb8b6d18f19c 100644 --- a/integrations/cloudbuild/build-coverage.yaml +++ b/integrations/cloudbuild/build-coverage.yaml @@ -7,7 +7,7 @@ steps: - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build:0.6.18" + - name: "connectedhomeip/chip-build:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -22,7 +22,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build:0.6.17" + - name: "connectedhomeip/chip-build:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/chef.yaml b/integrations/cloudbuild/chef.yaml index 0cfebde9cf97ea..494869a38e318e 100644 --- a/integrations/cloudbuild/chef.yaml +++ b/integrations/cloudbuild/chef.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,7 +12,7 @@ steps: path: /pwenv timeout: 2700s - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -26,7 +26,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/smoke-test.yaml b/integrations/cloudbuild/smoke-test.yaml index 47145edfc2aabc..c2f34ea5f72cdc 100644 --- a/integrations/cloudbuild/smoke-test.yaml +++ b/integrations/cloudbuild/smoke-test.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" entrypoint: "bash" args: - "-c" @@ -7,7 +7,7 @@ steps: git config --global --add safe.directory "*" git submodule update --init --recursive id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -22,7 +22,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: ESP32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -41,6 +41,7 @@ steps: - name: pwenv path: /pwenv + # TODO: update this to connectedhomeip/chip-build-vscode:0.6.27 once we can compile with latest NRF - name: "connectedhomeip/chip-build-vscode:0.6.18" id: NRFConnect env: @@ -62,7 +63,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: EFR32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -84,7 +85,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: Linux env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -142,7 +143,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: Android env: - PW_ENVIRONMENT_ROOT=/pwenv diff --git a/third_party/ameba/mbedtls.cmake b/third_party/ameba/mbedtls.cmake index 454358141d5df9..107e29a591df08 100755 --- a/third_party/ameba/mbedtls.cmake +++ b/third_party/ameba/mbedtls.cmake @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.6) project(mbedtls) -set(dir "${sdk_root}/component/common/network/ssl/mbedtls-matter") +set(dir "${sdk_root}/component/common/application/matter/mbedtls") set(dir_mbedtlschip "${ameba_matter_root}/third_party/mbedtls/repo/library") list( From fbaa1fe47894ab79435053d48c10eb7e774eef41 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 5 Jan 2023 15:31:16 -0500 Subject: [PATCH 12/14] Update ZAP to tip. (#24286) Moves list of weakly typed enums out of the ZAP helper code. --- integrations/docker/images/chip-build/Dockerfile | 2 +- integrations/docker/images/chip-build/version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/docker/images/chip-build/Dockerfile b/integrations/docker/images/chip-build/Dockerfile index 57eb0030689518..9d8b2ebdd9d8da 100644 --- a/integrations/docker/images/chip-build/Dockerfile +++ b/integrations/docker/images/chip-build/Dockerfile @@ -178,7 +178,7 @@ RUN set -x \ # Install a known ZAP release # Only keep the cli version, since `zap` is 143MB and not usable (UI) -ENV ZAP_VERSION=v2022.12.20-nightly +ENV ZAP_VERSION=v2023.01.05-nightly RUN set -x \ && mkdir -p /opt/zap-${ZAP_VERSION} \ && cd /opt/zap-${ZAP_VERSION} \ diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index bcccaaff02e138..2c5730e10a8e14 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.6.27 Version bump reason: [Telink] Update Telink Docker image (Zephyr update) +0.6.28 Version bump reason: Updating ZAP to v2023.01.05-nightly From 7f668cd586d1b4b239a7498909682d3fd8416f73 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 5 Jan 2023 19:03:01 -0500 Subject: [PATCH 13/14] Preserve acronyms in Darwin names of enum/bitmap values. (#24293) --- .github/workflows/zap_regeneration.yaml | 2 +- .github/workflows/zap_templates.yaml | 2 +- .../Framework/CHIP/templates/MTRBaseClusters.zapt | 12 ++++++------ .../Framework/CHIP/templates/availability.yaml | 9 +++++++++ .../CHIP/zap-generated/MTRBaseClusters.h | 15 ++++++++++++--- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index 1906613500816d..72cdc5fbc47808 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.28 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index b7459e76d53996..4a53d2b180a1df 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.28 defaults: run: shell: sh diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt index 99a43ecc41aadc..f7c229a0fbb14e 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt @@ -84,13 +84,13 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio {{#*inline "enumDef"}} typedef NS_ENUM({{asUnderlyingZclType name}}, {{objCEnumName clusterName enumName}}) { {{#zcl_enum_items}} - {{objCEnumName ../clusterName ../enumName}}{{objCEnumItemLabel label}} {{availability ../clusterName enum=../enumName enumValue=(objCEnumItemLabel label) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex value 2}}, + {{objCEnumName ../clusterName ../enumName}}{{asUpperCamelCase label preserveAcronyms=true}} {{availability ../clusterName enum=../enumName enumValue=(asUpperCamelCase label preserveAcronyms=true) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex value 2}}, {{#*inline "oldNameItemDecl"}} {{#if oldItemName}} - {{objCEnumName ../clusterName ../enumName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName enum=../enumName enumValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex value 2}}, + {{objCEnumName ../clusterName ../enumName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName enum=../enumName enumValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex value 2}}, {{/if}} {{/inline}} - {{> oldNameItemDecl oldItemName=(oldName ../clusterName enum=../enumName enumValue=(objCEnumItemLabel label))}} + {{> oldNameItemDecl oldItemName=(oldName ../clusterName enum=../enumName enumValue=(asUpperCamelCase label preserveAcronyms=true))}} {{/zcl_enum_items}} } {{/inline}} @@ -118,13 +118,13 @@ typedef NS_ENUM({{asUnderlyingZclType name}}, {{objCEnumName clusterName enumNam {{#*inline "bitmapDef"}} typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitmapName}}) { {{#zcl_bitmap_items}} - {{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel label}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=(objCEnumItemLabel label) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex mask}}, + {{objCEnumName ../clusterName ../bitmapName}}{{asUpperCamelCase label preserveAcronyms=true}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=(asUpperCamelCase label preserveAcronyms=true) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex mask}}, {{#*inline "oldNameItemDecl"}} {{#if oldItemName}} - {{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex mask}}, + {{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex mask}}, {{/if}} {{/inline}} - {{> oldNameItemDecl oldItemName=(oldName ../clusterName bitmap=../bitmapName bitmapValue=(objCEnumItemLabel label))}} + {{> oldNameItemDecl oldItemName=(oldName ../clusterName bitmap=../bitmapName bitmapValue=(asUpperCamelCase label preserveAcronyms=true))}} {{/zcl_bitmap_items}} } {{/inline}} diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index fb9685f8ad5539..79510e723f9877 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -5208,6 +5208,9 @@ NetworkCommissioning: WiFiSecurity: - WEP + - WPAPersonal + - WPA2Personal + - WPA3Personal deprecated: clusters: - OtaSoftwareUpdateProvider @@ -5276,6 +5279,9 @@ NetworkCommissioning: WiFiSecurity: - WepPersonal + - WpaPersonal + - Wpa2Personal + - Wpa3Personal apis: - Timed Invoke for server to client commands - Deprecated global attribute names @@ -5358,3 +5364,6 @@ NetworkCommissioning: WiFiSecurity: WEP: WepPersonal + WPAPersonal: WpaPersonal + WPA2Personal: Wpa2Personal + WPA3Personal: Wpa3Personal diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index 0387e8cc9334ac..0934f592496b57 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -17526,9 +17526,18 @@ typedef NS_OPTIONS(uint8_t, MTRNetworkCommissioningWiFiSecurity) { MTRNetworkCommissioningWiFiSecurityWepPersonal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) MTR_NEWLY_DEPRECATED("Please use MTRNetworkCommissioningWiFiSecurityWEP") = 0x2, - MTRNetworkCommissioningWiFiSecurityWpaPersonal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x4, - MTRNetworkCommissioningWiFiSecurityWpa2Personal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x8, - MTRNetworkCommissioningWiFiSecurityWpa3Personal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x10, + MTRNetworkCommissioningWiFiSecurityWPAPersonal MTR_NEWLY_AVAILABLE = 0x4, + MTRNetworkCommissioningWiFiSecurityWpaPersonal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRNetworkCommissioningWiFiSecurityWPAPersonal") + = 0x4, + MTRNetworkCommissioningWiFiSecurityWPA2Personal MTR_NEWLY_AVAILABLE = 0x8, + MTRNetworkCommissioningWiFiSecurityWpa2Personal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRNetworkCommissioningWiFiSecurityWPA2Personal") + = 0x8, + MTRNetworkCommissioningWiFiSecurityWPA3Personal MTR_NEWLY_AVAILABLE = 0x10, + MTRNetworkCommissioningWiFiSecurityWpa3Personal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRNetworkCommissioningWiFiSecurityWPA3Personal") + = 0x10, } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); typedef NS_ENUM(uint8_t, MTRDiagnosticLogsLogsIntent) { From e766102fad3d2e05d0fe0aafa888f6ccbdae804f Mon Sep 17 00:00:00 2001 From: Robert Schulze <112553298+deveritec-rosc@users.noreply.github.com> Date: Fri, 6 Jan 2023 10:35:08 +0100 Subject: [PATCH 14/14] [nrfconnect] Allow use of certifcates stored on the HDD for factory data (#24274) * [nrfconnect] Allow use of certifcates stored somewhere on the HDD for factory data Instead of just allow usage for the default certificates or certificates generated on demand also add the possibility to use certificates already located on the HDD. This makes it easier to use generated test DCL certificates. * [nrfconnect] Rename options and provide help string Signed-off-by: Robert Schulze * [nrfconnect] fix indententaion error in Kconfig Signed-off-by: Robert Schulze Signed-off-by: Robert Schulze --- config/nrfconnect/chip-module/Kconfig | 47 +++++++++++++++---- .../chip-module/generate_factory_data.cmake | 4 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/config/nrfconnect/chip-module/Kconfig b/config/nrfconnect/chip-module/Kconfig index 4b477d357287d1..b6700cbe7f3602 100644 --- a/config/nrfconnect/chip-module/Kconfig +++ b/config/nrfconnect/chip-module/Kconfig @@ -135,16 +135,45 @@ config CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE As a result, a new output file merged.hex will consist of all partitions including factory data. -# Use default certificates without generating or providing them -config CHIP_FACTORY_DATA_USE_DEFAULT_CERTS - bool "Use default certificates located in Matter repository" - default y +# Select source of the certificates +choice CHIP_FACTORY_DATA_CERT_SOURCE + prompt "Attestation certificate file source" + default CHIP_FACTORY_DATA_USE_DEFAULT_CERTS + + config CHIP_FACTORY_DATA_USE_DEFAULT_CERTS + bool "Use pre-generated development certificates" + help + Use pre-generated certificate files from the credentials/development/attestation/ + directory that match the configured Product ID. This can be used for development + purpose. + config CHIP_FACTORY_DATA_CERT_SOURCE_GENERATED + bool "Auto-generate certificates" + help + Generate new certificates instead of using pre-generated ones. + The certificates are generated on every build. + config CHIP_FACTORY_DATA_CERT_SOURCE_USER + bool "Use user-provided certificate files" + help + Use user-provided certificate files. + The user needs to specify the absolute path to all necessary files. +endchoice + +if CHIP_FACTORY_DATA_CERT_SOURCE_USER + +config CHIP_FACTORY_DATA_USER_CERTS_DAC_CERT + string "Path to the DAC certificate *.der-file" + help + Absolute path to the DAC certificate file in binary format. +config CHIP_FACTORY_DATA_USER_CERTS_DAC_KEY + string "Path to the DAC private key *.der-file" help - Pre-generated certificates can be used for development purpose. - This config includes default pre-generated certificates - which are located in credentials/development/attestation/ directory - instead of generating new ones. - If this config is set to `n` new certificates will be generated. + Absolute path to the DAC keysfile in binary format. + Note that both public and private keys must be present (will be extracted automatically). +config CHIP_FACTORY_DATA_USER_CERTS_PAI_CERT + string "Path to the PAI certificate *.der-file" + help + Absolute path pointing to the PAI certificate in binary format. +endif # Configs for SPAKE2 generation config CHIP_FACTORY_DATA_GENERATE_SPAKE2_VERIFIER diff --git a/config/nrfconnect/chip-module/generate_factory_data.cmake b/config/nrfconnect/chip-module/generate_factory_data.cmake index 2888822efcaea3..be0c4c0fac692c 100644 --- a/config/nrfconnect/chip-module/generate_factory_data.cmake +++ b/config/nrfconnect/chip-module/generate_factory_data.cmake @@ -69,6 +69,10 @@ if(CONFIG_CHIP_FACTORY_DATA_USE_DEFAULT_CERTS) string(APPEND script_args "--dac_cert \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-DAC-${raw_pid_upper}-Cert.der\"\n") string(APPEND script_args "--dac_key \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-DAC-${raw_pid_upper}-Key.der\"\n") string(APPEND script_args "--pai_cert \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-PAI-noPID-Cert.der\"\n") +elseif(CONFIG_CHIP_FACTORY_DATA_CERT_SOURCE_USER) + string(APPEND script_args "--dac_cert \"${CONFIG_CHIP_FACTORY_DATA_USER_CERTS_DAC_CERT}\"\n") + string(APPEND script_args "--dac_key \"${CONFIG_CHIP_FACTORY_DATA_USER_CERTS_DAC_KEY}\"\n") + string(APPEND script_args "--pai_cert \"${CONFIG_CHIP_FACTORY_DATA_USER_CERTS_PAI_CERT}\"\n") else() find_program(chip_cert_exe NAMES chip-cert REQUIRED) string(APPEND script_args "--gen_cd\n")