@@ -38,6 +38,8 @@ static uint32_t iv_index;
38
38
static uint16_t addr ;
39
39
static uint8_t dev_key [16 ];
40
40
static uint8_t input_size ;
41
+ static uint8_t pub_key [64 ];
42
+ static uint8_t priv_key [32 ];
41
43
42
44
/* Configured provisioning data */
43
45
static uint8_t dev_uuid [16 ];
@@ -51,6 +53,11 @@ static uint16_t vnd_app_key_idx = 0x000f;
51
53
/* Model send data */
52
54
#define MODEL_BOUNDS_MAX 2
53
55
56
+ /* Model Authentication Method */
57
+ #define AUTH_METHOD_STATIC 0x01
58
+ #define AUTH_METHOD_OUTPUT 0x02
59
+ #define AUTH_METHOD_INPUT 0x03
60
+
54
61
static struct model_data {
55
62
struct bt_mesh_model * model ;
56
63
uint16_t addr ;
@@ -436,6 +443,7 @@ static struct bt_mesh_prov prov = {
436
443
static void config_prov (uint8_t * data , uint16_t len )
437
444
{
438
445
const struct mesh_config_provisioning_cmd * cmd = (void * ) data ;
446
+ int err = 0 ;
439
447
440
448
LOG_DBG ("" );
441
449
@@ -447,8 +455,27 @@ static void config_prov(uint8_t *data, uint16_t len)
447
455
prov .input_size = cmd -> in_size ;
448
456
prov .input_actions = sys_le16_to_cpu (cmd -> in_actions );
449
457
450
- tester_rsp (BTP_SERVICE_ID_MESH , MESH_CONFIG_PROVISIONING ,
451
- CONTROLLER_INDEX , BTP_STATUS_SUCCESS );
458
+ if (cmd -> auth_method == AUTH_METHOD_OUTPUT ) {
459
+ err = bt_mesh_auth_method_set_output (prov .output_actions , prov .output_size );
460
+ } else if (cmd -> auth_method == AUTH_METHOD_INPUT ) {
461
+ err = bt_mesh_auth_method_set_input (prov .input_actions , prov .input_size );
462
+ } else if (cmd -> auth_method == AUTH_METHOD_STATIC ) {
463
+ err = bt_mesh_auth_method_set_static (static_auth , sizeof (static_auth ));
464
+ }
465
+
466
+ if (len > sizeof (* cmd )) {
467
+ memcpy (pub_key , cmd -> set_keys -> pub_key , sizeof (cmd -> set_keys -> pub_key ));
468
+ memcpy (priv_key , cmd -> set_keys -> priv_key , sizeof (cmd -> set_keys -> priv_key ));
469
+ prov .public_key_be = pub_key ;
470
+ prov .private_key_be = priv_key ;
471
+ }
472
+
473
+ if (err ) {
474
+ LOG_ERR ("err %d" , err );
475
+ }
476
+
477
+ tester_rsp (BTP_SERVICE_ID_MESH , MESH_CONFIG_PROVISIONING , CONTROLLER_INDEX ,
478
+ err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS );
452
479
}
453
480
454
481
static void provision_node (uint8_t * data , uint16_t len )
@@ -465,6 +492,16 @@ static void provision_node(uint8_t *data, uint16_t len)
465
492
flags = cmd -> flags ;
466
493
iv_index = sys_le32_to_cpu (cmd -> iv_index );
467
494
net_key_idx = sys_le16_to_cpu (cmd -> net_key_idx );
495
+
496
+ if (len > sizeof (* cmd )) {
497
+ memcpy (pub_key , cmd -> pub_key , sizeof (pub_key ));
498
+
499
+ err = bt_mesh_prov_remote_pub_key_set (pub_key );
500
+ if (err ) {
501
+ LOG_ERR ("err %d" , err );
502
+ goto fail ;
503
+ }
504
+ }
468
505
#if defined(CONFIG_BT_MESH_PROVISIONER )
469
506
err = bt_mesh_cdb_create (net_key );
470
507
if (err ) {
0 commit comments