@@ -171,29 +171,25 @@ def gen_test_certs(chip_cert_exe: str,
171
171
new_certificates ["PAI_CERT" ] + ".der" )
172
172
173
173
174
- def gen_spake2p_params ( spake2p_path : str , passcode : int , it : int , salt : bytes ) -> dict :
175
- """ Generate Spake2+ params using external spake2p tool
174
+ def gen_spake2p_verifier ( passcode : int , it : int , salt : bytes ) -> str :
175
+ """ Generate Spake2+ verifier using SPAKE2+ Python Tool
176
176
177
177
Args:
178
- spake2p_path (str): path to spake2p executable
179
178
passcode (int): Pairing passcode using in Spake2+
180
179
it (int): Iteration counter for Spake2+ verifier generation
181
180
salt (str): Salt used to generate Spake2+ verifier
182
181
183
182
Returns:
184
- dict: dictionary containing passcode, it, salt, and generated Verifier
183
+ verifier encoded in Base64
185
184
"""
186
185
187
186
cmd = [
188
- spake2p_path , 'gen-verifier' ,
187
+ os .path .join (MATTER_ROOT , 'scripts/tools/spake2p/spake2p.py' ), 'gen-verifier' ,
188
+ '--passcode' , str (passcode ),
189
+ '--salt' , base64 .b64encode (salt ).decode ('ascii' ),
189
190
'--iteration-count' , str (it ),
190
- '--salt' , base64 .b64encode (salt ),
191
- '--pin-code' , str (passcode ),
192
- '--out' , '-' ,
193
191
]
194
- output = subprocess .check_output (cmd )
195
- output = output .decode ('utf-8' ).splitlines ()
196
- return dict (zip (output [0 ].split (',' ), output [1 ].split (',' )))
192
+ return subprocess .check_output (cmd )
197
193
198
194
199
195
class FactoryDataGenerator :
@@ -223,8 +219,8 @@ def _validate_args(self):
223
219
self ._user_data = json .loads (self ._args .user )
224
220
except json .decoder .JSONDecodeError as e :
225
221
raise AssertionError ("Provided wrong user data, this is not a JSON format! {}" .format (e ))
226
- assert ( self ._args .spake2_verifier or ( self ._args .passcode and self . _args . spake2p_path )) , \
227
- "Cannot find Spake2+ verifier, to generate a new one please provide passcode (--passcode) and path to spake2p tool (--spake2p_path) "
222
+ assert self ._args .spake2_verifier or self ._args .passcode , \
223
+ "Cannot find Spake2+ verifier, to generate a new one please provide passcode (--passcode)"
228
224
assert (self ._args .chip_cert_path or (self ._args .dac_cert and self ._args .pai_cert and self ._args .dac_key )), \
229
225
"Cannot find paths to DAC or PAI certificates .der files. To generate a new ones please provide a path to chip-cert executable (--chip_cert_path)"
230
226
assert self ._args .output .endswith (".json" ), \
@@ -301,6 +297,9 @@ def generate_json(self):
301
297
self ._add_entry ("product_id" , self ._args .product_id )
302
298
self ._add_entry ("vendor_name" , self ._args .vendor_name )
303
299
self ._add_entry ("product_name" , self ._args .product_name )
300
+ self ._add_entry ("product_label" , self ._args .product_label )
301
+ self ._add_entry ("product_url" , self ._args .product_url )
302
+ self ._add_entry ("part_number" , self ._args .part_number )
304
303
self ._add_entry ("date" , self ._args .date )
305
304
self ._add_entry ("hw_ver" , self ._args .hw_ver )
306
305
self ._add_entry ("hw_ver_str" , self ._args .hw_ver_str )
@@ -345,9 +344,7 @@ def _add_entry(self, name: str, value: any):
345
344
346
345
def _generate_spake2_verifier (self ):
347
346
""" If verifier has not been provided in arguments list it should be generated via external script """
348
- spake2_params = gen_spake2p_params (self ._args .spake2p_path , self ._args .passcode ,
349
- self ._args .spake2_it , self ._args .spake2_salt )
350
- return base64 .b64decode (spake2_params ["Verifier" ])
347
+ return base64 .b64decode (gen_spake2p_verifier (self ._args .passcode , self ._args .spake2_it , self ._args .spake2_salt ))
351
348
352
349
def _generate_rotating_device_uid (self ):
353
350
""" If rotating device unique ID has not been provided it should be generated """
@@ -438,9 +435,15 @@ def base64_str(s): return base64.b64decode(s)
438
435
the setup code. Discriminator is used during a discovery process." )
439
436
440
437
# optional keys
438
+ optional_arguments .add_argument ("--product_url" , type = str ,
439
+ help = "[string] provide link to product-specific web page" )
440
+ optional_arguments .add_argument ("--product_label" , type = str ,
441
+ help = "[string] provide human-readable product label" )
442
+ optional_arguments .add_argument ("--part_number" , type = str ,
443
+ help = "[string] provide human-readable product number" )
441
444
optional_arguments .add_argument ("--chip_cert_path" , type = str ,
442
445
help = "Generate DAC and PAI certificates instead giving a path to .der files. This option requires a path to chip-cert executable."
443
- "By default You can find spake2p in connectedhomeip/src/tools/chip-cert directory and build it there." )
446
+ "By default you can find chip-cert in connectedhomeip/src/tools/chip-cert directory and build it there." )
444
447
optional_arguments .add_argument ("--dac_cert" , type = str ,
445
448
help = "[.der] Provide the path to .der file containing DAC certificate." )
446
449
optional_arguments .add_argument ("--dac_key" , type = str ,
@@ -455,8 +458,6 @@ def base64_str(s): return base64.b64decode(s)
455
458
help = "[hex string] [128-bit hex-encoded] Provide the rotating device unique ID. If this argument is not provided a new rotating device id unique id will be generated." )
456
459
optional_arguments .add_argument ("--passcode" , type = allow_any_int ,
457
460
help = "[int | hex] Default PASE session passcode. (This is mandatory to generate Spake2+ verifier)." )
458
- optional_arguments .add_argument ("--spake2p_path" , type = str ,
459
- help = "[string] Provide a path to spake2p. By default You can find spake2p in connectedhomeip/src/tools/spake2p directory and build it there." )
460
461
optional_arguments .add_argument ("--spake2_verifier" , type = base64_str ,
461
462
help = "[base64 string] Provide Spake2+ verifier without generating it." )
462
463
optional_arguments .add_argument ("--enable_key" , type = str ,
0 commit comments