Skip to content

Commit 6df8129

Browse files
robertfarnumapahl-clrestyled-commitsbzbarsky-appleCopilot
authored
Joint Fabric Mutual VID Verification Implementation (project-chip#40868)
* Checkpoint * Building successfully; TestJCMCommissioner crashes * Fixing tests * No crash; 2 tests fail * Latest update with JF test certs * Fix unit test crash, and missing CurrentContext() * Fix TestJCMCommissioner Error unit test. * Still need to fix unit test; bad verification signature? * JCM example app vendor id verification works, but test case does not? * Refactor deviceProxy out of TrustVerification * Add JCMCommissionee * Implement HandleAnnounceJointFabricAdministrator control flow * Implement HandleAnnounceJointFabricAdministrator state machine * TestJCMCommissioner unit test fixed * Fix launch.json * Fix unit test issues and code review comments * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Complete HandleAnnounceJointFabricAdministrator implementation * Fixes * Revert submodule accidental change * Fix GetUseJCM/SetUseJCM as being conditionally compiled * Update src/controller/CommissioningDelegate.h Co-authored-by: Boris Zbarsky <[email protected]> * Relocate TrustVerification and JCMCommissionee * Merge w/ Austin and breakout VendorIdVerificationClient[h,cpp] * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Remove header 'using namespace' * Restyled by clang-format * lint: fix use of <string> * Fix cross platform compile issue. * Restyled by clang-format * Add TestVendorIdVerificationClient.cpp * Restyled by whitespace * Restyled by clang-format * Fix jfc-app compile issues * Optionally enable JF Test fabrics in MessagingContext * Restyled by clang-format * Fix override clang compile issue * Remove trailing comma that broke the test * Fix Darwin build issue with JCMCommissee.cpp * Fix JCM Commissionee Trust Verification setup * Clean up JCMCommissionee::ParseCommissionerAdminInfo * Clean up AnnounceJointFabricAdministrator logging * checkpoint * checkpoint launch.json * checkpoint (needs work) * Restyled by autopep8 * Clean up JCMCommissionee * Implement initial TestJCMCommissionee * Abstract out ReadAttribute in JCMCommissionee * Mock ReadAttribute in TestJCMCommissionee (needs work) * Implement tests for JCMCommissionee StoreEndpointId and ReadAdminFabricIndex * Clean up JCMCommissionee::ParseCommissionerAdminInfo * Clean up AnnounceJointFabricAdministrator logging * checkpoint (needs work) * Clean up JCMCommissionee * Implement initial TestJCMCommissionee * Fix shadowing problems * Update JCMCommissionee tests * Update JCMCommissionee build config * Remove unneeded nogncheck * Add credentials/jcm:jcm public dep * Fix -Wunused-lambda-capture in JCMCommissionee * Fix format specifiers in JCMCommissionee * Simplify error logging in JCMCommissionee * Remove logging that causes CI to fail * Add constant for JFA Endpoint ID * Catch edge cases on Admin Fabrics and Admin NOCs * Merge gemini code review comments * sync submodules with master * fix * fix * resync other submodules * Update src/messaging/tests/MessagingContext.cpp Co-authored-by: Copilot <[email protected]> * Address copilot review comments * Restyled by clang-format * Update src/app/clusters/joint-fabric-administrator-server/JCMCommissionee.cpp Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Austin Pahl <[email protected]> Co-authored-by: Restyled.io <[email protected]> Co-authored-by: Boris Zbarsky <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent eb2b62a commit 6df8129

File tree

69 files changed

+3930
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3930
-341
lines changed

.vscode/launch.json

Lines changed: 194 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
{
8-
"name": "Python Debugger: Current File with Arguments",
9-
"type": "debugpy",
10-
"request": "launch",
11-
"program": "${file}",
12-
"console": "integratedTerminal",
13-
"args": []
14-
},
157
{
168
"name": "Python: Mock Server Tests",
179
"type": "debugpy",
@@ -55,17 +47,94 @@
5547
"name": "Run application (Darwin x64)",
5648
"type": "lldb",
5749
"request": "launch",
58-
"program": "${workspaceFolder}/out/${input:outAppDarwin}",
59-
"args": [],
50+
"program": "${workspaceFolder}/examples/chip-tool/out/debug/chip-tool",
51+
"args": [
52+
"--storage-directory",
53+
"./storage",
54+
"interactive",
55+
"start"
56+
],
57+
"cwd": "${workspaceFolder}/examples/chip-tool/out/debug"
58+
},
59+
{
60+
"name": "Run mdns-advertiser product-id 1 (Linux x64)",
61+
"type": "lldb",
62+
"request": "launch",
63+
"program": "${workspaceFolder}/examples/minimal-mdns/out/debug/mdns-advertiser",
64+
"args": [
65+
"-4",
66+
"-m",
67+
"commissionable-node",
68+
"--vendor-id",
69+
"4381",
70+
"--product-id",
71+
"1",
72+
"--device-type",
73+
"144",
74+
"--commissioning-mode",
75+
"0"
76+
],
6077
"cwd": "${workspaceFolder}"
6178
},
6279
{
63-
"name": "Run application Energy-Gtw-Sample (Darwin arm64)",
80+
"name": "Run TestFabricTable",
81+
"type": "lldb",
82+
"request": "launch",
83+
"program": "${workspaceFolder}/src/credentials/tests/out/test/tests/TestFabricTable",
84+
"cwd": "${workspaceFolder}/src/credentials/tests/out/test/tests"
85+
},
86+
{
87+
"name": "Run TestJCMCommissioner",
6488
"type": "lldb",
6589
"request": "launch",
66-
"program": "${workspaceFolder}/out/darwin-arm64-energy-gateway/chip-energy-gateway-app",
67-
"args": ["--enable-key", "00112233445566778899aabbccddeeff"],
68-
"cwd": "${workspaceFolder}/examples/energy-gateway-app"
90+
"program": "${workspaceFolder}/src/controller/tests/jcm/out/test/tests/TestJCMCommissioner",
91+
"cwd": "${workspaceFolder}/src/controller/tests/jcm/out/test/tests"
92+
},
93+
{
94+
"name": "Run TestTrustVerification",
95+
"type": "lldb",
96+
"request": "launch",
97+
"program": "${workspaceFolder}/src/credentials/tests/jcm/out/test/tests/TestTrustVerification",
98+
"cwd": "${workspaceFolder}/src/credentials/tests/jcm/out/test/tests"
99+
},
100+
{
101+
"name": "Run TestVendorIdVerificationClient",
102+
"type": "lldb",
103+
"request": "launch",
104+
"program": "${workspaceFolder}/src/credentials/tests/jcm/out/test/tests/TestVendorIdVerificationClient",
105+
"cwd": "${workspaceFolder}/src/credentials/tests/jcm/out/test/tests"
106+
},
107+
{
108+
"name": "Run TestCommissioningWindowManager",
109+
"type": "lldb",
110+
"request": "launch",
111+
"program": "${workspaceFolder}/src/app/tests/out/test/tests/TestCommissioningWindowManager",
112+
"cwd": "${workspaceFolder}/src/app/tests/out/test/tests"
113+
},
114+
{
115+
"name": "Run TestCommands",
116+
"type": "lldb",
117+
"request": "launch",
118+
"program": "${workspaceFolder}/src/controller/tests/out/test/tests/TestCommands",
119+
"cwd": "${workspaceFolder}/src/controller/tests/out/test/tests"
120+
},
121+
{
122+
"name": "Run application (valgrind jfc-app)",
123+
"type": "lldb",
124+
"request": "launch",
125+
"program": "valgrind",
126+
"args": [
127+
"${workspaceFolder}/examples/jf-control-app/out/debug/jfc-app",
128+
"--rpc-server-ip",
129+
"192.168.1.64",
130+
"--rpc-server-port",
131+
"33055",
132+
"--storage-directory",
133+
"./jfc_b_storage_directory",
134+
"--commissioner-vendor-id",
135+
"0xFFF2"
136+
],
137+
"cwd": "${workspaceFolder}/examples/jf-control-app/out/debug"
69138
},
70139
{
71140
"name": "Run application (Linux x64)",
@@ -221,6 +290,82 @@
221290
"program": "${workspaceFolder}/out/debug/standalone/fabric-sync",
222291
"cwd": "${workspaceFolder}"
223292
},
293+
{
294+
"name": "Joint Fabric (JFA-A)",
295+
"type": "lldb",
296+
"request": "launch",
297+
"program": "${workspaceFolder}/examples/jf-admin-app/linux/out/debug/jfa-app",
298+
"args": [
299+
"--capabilities",
300+
"0x4",
301+
"--passcode",
302+
"11022033",
303+
"--discriminator",
304+
"3840",
305+
"--secured-device-port",
306+
"5533",
307+
"--rpc-server-port",
308+
"33033",
309+
"--KVS",
310+
"jfa_a_kvs"
311+
],
312+
"cwd": "${workspaceFolder}/examples/jf-admin-app/linux/out/debug"
313+
},
314+
{
315+
"name": "Joint Fabric (JFC-A)",
316+
"type": "lldb",
317+
"request": "launch",
318+
"program": "${workspaceFolder}/examples/jf-control-app/out/debug/jfc-app",
319+
"args": [
320+
"--rpc-server-ip",
321+
"127.0.0.1",
322+
"--rpc-server-port",
323+
"33033",
324+
"--storage-directory",
325+
"./jfc_a_storage_directory",
326+
"--commissioner-vendor-id",
327+
"0xFFF1"
328+
],
329+
"cwd": "${workspaceFolder}/examples/jf-control-app/out/debug"
330+
},
331+
{
332+
"name": "Joint Fabric (JFA-B)",
333+
"type": "lldb",
334+
"request": "launch",
335+
"program": "${workspaceFolder}/examples/jf-admin-app/linux/out/debug/jfa-app",
336+
"args": [
337+
"--capabilities",
338+
"0x4",
339+
"--passcode",
340+
"11022055",
341+
"--discriminator",
342+
"3841",
343+
"--secured-device-port",
344+
"5555",
345+
"--rpc-server-port",
346+
"33055",
347+
"--KVS",
348+
"jfa_b_kvs"
349+
],
350+
"cwd": "${workspaceFolder}/examples/jf-admin-app/linux/out/debug"
351+
},
352+
{
353+
"name": "Joint Fabric (JFC-B)",
354+
"type": "lldb",
355+
"request": "launch",
356+
"program": "${workspaceFolder}/examples/jf-control-app/out/debug/jfc-app",
357+
"args": [
358+
"--rpc-server-ip",
359+
"127.0.0.1",
360+
"--rpc-server-port",
361+
"33055",
362+
"--storage-directory",
363+
"./jfc_b_storage_directory",
364+
"--commissioner-vendor-id",
365+
"0xFFF2"
366+
],
367+
"cwd": "${workspaceFolder}/examples/jf-control-app/out/debug"
368+
},
224369
{
225370
"name": "OTA Requestor App (Linux)",
226371
"type": "lldb",
@@ -269,6 +414,41 @@
269414
"ignoreFailures": true
270415
}
271416
]
417+
},
418+
{
419+
"name": "Run TestFabricTable",
420+
"type": "lldb",
421+
"request": "launch",
422+
"program": "${workspaceFolder}/src/credentials/tests/out/test/tests/TestFabricTable",
423+
"cwd": "${workspaceFolder}/src/credentials/tests/out/test/tests"
424+
},
425+
{
426+
"name": "Run TestJCMCommissioner",
427+
"type": "lldb",
428+
"request": "launch",
429+
"program": "${workspaceFolder}/src/controller/tests/jcm/out/test/tests/TestJCMCommissioner",
430+
"cwd": "${workspaceFolder}/src/controller/tests/jcm/out/test/tests"
431+
},
432+
{
433+
"name": "Run TestTrustVerification",
434+
"type": "lldb",
435+
"request": "launch",
436+
"program": "${workspaceFolder}/src/credentials/tests/jcm/out/test/tests/TestTrustVerification",
437+
"cwd": "${workspaceFolder}/src/credentials/tests/jcm/out/test/tests"
438+
},
439+
{
440+
"name": "Run TestVendorIdVerificationClient",
441+
"type": "lldb",
442+
"request": "launch",
443+
"program": "${workspaceFolder}/src/credentials/tests/jcm/out/test/tests/TestVendorIdVerificationClient",
444+
"cwd": "${workspaceFolder}/src/credentials/tests/jcm/out/test/tests"
445+
},
446+
{
447+
"name": "Run TestCommands",
448+
"type": "lldb",
449+
"request": "launch",
450+
"program": "${workspaceFolder}/src/controller/tests/out/test/tests/TestCommands",
451+
"cwd": "${workspaceFolder}/src/controller/tests/out/test/tests"
272452
}
273453
],
274454
"inputs": [

docs/guides/joint_fabric_guide.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Initialize Ecosystem A (Vendor ID = 0xFFF1)](#initialize-ecosystem-a-vendor-id--0xfff1)
88
- [Initialize Ecosystem B (Vendor ID = 0xFFF2)](#initialize-ecosystem-b-vendor-id--0xfff2)
99
- [Manually Testing JCM (Joint Commissioning Method)](#manually-testing-jcm-joint-commissioning-method)
10+
- [Unit Testing Joint Fabric](#unit-testing-joint-fabric)
1011

1112
## Joint Fabric Example Applications
1213

@@ -63,7 +64,7 @@ $ rm -rf /tmp/chip_*
6364
```
6465
$ cd ~/connectedhomeip/examples/jf-admin-app/linux/out/debug
6566
$ rm -rf jfa_a_kvs && touch jfa_a_kvs
66-
$ ./jfa-app --capabilities 0x4 --passcode 110220033 --discriminator 3840 --secured-device-port 5533 --rpc-server-port 33033 --KVS jfa_a_kvs
67+
$ ./jfa-app --capabilities 0x4 --passcode 11022033 --discriminator 3840 --secured-device-port 5533 --rpc-server-port 33033 --KVS jfa_a_kvs
6768
```
6869

6970
- Start jf-control-app
@@ -77,7 +78,7 @@ $ ./jfc-app --rpc-server-port 33033 --storage-directory jfc_a_storage_directory
7778
- Commission jf-admin-app
7879

7980
```
80-
>>> pairing onnetwork-long 1 110220033 3840 --anchor true
81+
>>> pairing onnetwork-long 1 11022033 3840 --anchor true
8182
```
8283

8384
Check for the following logs on the jf-control-app side:
@@ -129,13 +130,13 @@ Subject: 1.3.6.1.4.1.37244.1.3 = 0000000000000003, OU = jf-anchor-icac
129130
```
130131
$ cd ~/connectedhomeip/examples/lighting-app/linux/out/debug
131132
$ rm -rf light_a_kvs && touch light_a_kvs
132-
$ ./chip-lighting-app --capabilities 0x4 --passcode 110220044 --KVS light_a_kvs
133+
$ ./chip-lighting-app --capabilities 0x4 --passcode 11022044 --KVS light_a_kvs
133134
```
134135

135136
- Commission lighting-app
136137

137138
```
138-
>>> pairing onnetwork 2 110220044
139+
>>> pairing onnetwork 2 11022044
139140
```
140141

141142
Check that a Fabric having `AdminVendorID` set to 0xFFF1 has been installed:
@@ -161,7 +162,7 @@ should be found.
161162
```
162163
$ cd ~/connectedhomeip/examples/jf-admin-app/linux/out/debug
163164
$ rm -rf jfa_b_kvs && touch jfa_b_kvs
164-
$ ./jfa-app --capabilities 0x4 --passcode 110220055 --discriminator 3841 --secured-device-port 5555 --rpc-server-port 33055 --KVS jfa_b_kvs
165+
$ ./jfa-app --capabilities 0x4 --passcode 11022055 --discriminator 3841 --secured-device-port 5555 --rpc-server-port 33055 --KVS jfa_b_kvs
165166
```
166167

167168
- Start jf-control-app
@@ -175,7 +176,7 @@ $ ./jfc-app --rpc-server-port 33055 --storage-directory jfc_b_storage_directory
175176
- Commission jf-admin-app
176177

177178
```
178-
>>> pairing onnetwork-long 11 110220055 3841 --anchor true
179+
>>> pairing onnetwork-long 11 11022055 3841 --anchor true
179180
```
180181

181182
Check for the following logs on the jf-control-app side:
@@ -228,13 +229,13 @@ Subject: 1.3.6.1.4.1.37244.1.3 = 0000000000000003, OU = jf-anchor-icac
228229
```
229230
$ cd ~/connectedhomeip/examples/lighting-app/linux/out/debug
230231
$ rm -rf light_b_kvs && touch light_b_kvs
231-
$ ./chip-lighting-app --capabilities 0x4 --passcode 110220066 --KVS light_b_kvs
232+
$ ./chip-lighting-app --capabilities 0x4 --passcode 11022066 --KVS light_b_kvs
232233
```
233234

234235
- Commission lighting-app
235236

236237
```
237-
>>> pairing onnetwork 22 110220066
238+
>>> pairing onnetwork 22 11022066
238239
```
239240

240241
Check that a Fabric having `AdminVendorID` set to 0xFFF2 has been installed:
@@ -278,3 +279,9 @@ On the Ecosystem A Joint Fabric Controller application
278279
```
279280
pairing code 10 [manual pairing code] --jcm true
280281
```
282+
283+
## Unit Testing Joint Fabric
284+
285+
To enable Joint Fabric related unit tests please use the following command:
286+
287+
`gn gen out/test --args="chip_device_config_enable_joint_fabric=true"`

examples/jf-admin-app/linux/JFAManager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ constexpr uint8_t kJFAdminShift = 1;
3838
constexpr uint8_t kJFAnchorShift = 2;
3939
constexpr uint8_t kJFDatastoreShift = 3;
4040

41+
constexpr chip::EndpointId kJointFabricAdminEndpointId = 1;
42+
4143
JFAManager JFAManager::sJFA;
4244

4345
CHIP_ERROR JFAManager::Init(Server & server)
@@ -97,7 +99,8 @@ void JFAManager::HandleCommissioningCompleteEvent()
9799
/* When JFA is commissioned, it has to be issued a NOC with Anchor CAT and Administrator CAT */
98100
if (cats.ContainsIdentifier(kAdminCATIdentifier) && cats.ContainsIdentifier(kAnchorCATIdentifier))
99101
{
100-
(void) app::Clusters::JointFabricAdministrator::Attributes::AdministratorFabricIndex::Set(1, fabricIndex);
102+
(void) app::Clusters::JointFabricAdministrator::Attributes::AdministratorFabricIndex::Set(
103+
kJointFabricAdminEndpointId, fabricIndex);
101104

102105
jfFabricIndex = fabricIndex;
103106
}
@@ -225,6 +228,8 @@ CHIP_ERROR JFAManager::AnnounceJointFabricAdministrator()
225228
}
226229

227230
ChipLogProgress(JointFabric, "AnnounceJointFabricAdministrator: invoke cluster command.");
231+
request.endpointID = kJointFabricAdminEndpointId;
232+
228233
Controller::ClusterBase cluster(*mExchangeMgr, mSessionHolder.Get().Value(), peerAdminJFAdminClusterEndpointId);
229234
return cluster.InvokeCommand(request, this, OnAnnounceJointFabricAdministratorResponse,
230235
OnAnnounceJointFabricAdministratorFailure);

examples/jf-admin-app/linux/args.gni

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ matter_enable_tracing_support = true
3333
chip_enable_additional_data_advertising = true
3434
chip_enable_rotating_device_id = true
3535

36-
chip_enable_read_client = false
36+
chip_enable_read_client = true
3737

3838
chip_device_config_enable_joint_fabric = true

examples/jf-admin-app/linux/rpc/RpcServer.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ ::pw::Status JointFabric::TransferOwnership(const ::OwnershipContext & request,
3232
ChipLogError(JointFabric, "Invalid Peer Admin Endpoint ID for the JF Administrator Cluster");
3333
}
3434

35-
for (size_t i = 0; i < Crypto::kP256_PublicKey_Length; ++i)
36-
{
37-
ChipLogProgress(JointFabric, "trustedIcacPublicKeyB[%li] = %02X", i, request.trustedIcacPublicKeyB.bytes[i]);
38-
}
39-
4035
OwnershipTransferContext * data = Platform::New<OwnershipTransferContext>(
4136
request.node_id, request.jcm, ByteSpan(request.trustedIcacPublicKeyB.bytes, request.trustedIcacPublicKeyB.size),
4237
request.peerAdminJFAdminClusterEndpointId);

examples/jf-control-app/BUILD.gn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static_library("jfc-utils") {
101101

102102
deps = [
103103
"${chip_root}/src/app:events",
104-
"${chip_root}/src/controller:jcm",
104+
"${chip_root}/src/controller/jcm:jcm",
105105
]
106106

107107
if (config_use_interactive_mode) {
@@ -170,7 +170,7 @@ executable("jfc-app") {
170170

171171
deps = [
172172
":jfc-utils",
173-
"${chip_root}/src/controller:jcm",
173+
"${chip_root}/src/controller/jcm:jcm",
174174
"${chip_root}/src/platform/logging:stdio",
175175
]
176176

0 commit comments

Comments
 (0)