diff --git a/doc/connectivity/bluetooth/api/audio/shell/cap.rst b/doc/connectivity/bluetooth/api/audio/shell/cap.rst index 6f61b24880a..57dc7e19d83 100644 --- a/doc/connectivity/bluetooth/api/audio/shell/cap.rst +++ b/doc/connectivity/bluetooth/api/audio/shell/cap.rst @@ -27,9 +27,9 @@ register callbacks. [rank ] [not-lockable] [sirk ] lock :Lock the set release :Release the set [force] - set_sirk :Set the currently used SIRK + sirk :Set the currently used SIRK get_sirk :Get the currently used SIRK - set_sirk_rsp :Set the response used in SIRK requests Besides initializing the CAS and the CSIS, there are also commands to lock and release the CSIS @@ -45,8 +45,8 @@ clients. .. code-block:: console - uart:~$ cap_acceptor set_sirk 00112233445566778899aabbccddeeff - Set SIRK updated + uart:~$ cap_acceptor sirk 00112233445566778899aabbccddeeff + SIRK updated Getting the current SIRK ------------------------ @@ -56,7 +56,7 @@ This command can get the currently used SIRK. .. code-block:: console uart:~$ cap_acceptor get_sirk - Set SIRK + SIRK 36 04 9a dc 66 3a a1 a1 |6...f:.. 1d 9a 2f 41 01 73 3e 01 |../A.s>. diff --git a/doc/connectivity/bluetooth/api/audio/shell/csip.rst b/doc/connectivity/bluetooth/api/audio/shell/csip.rst index 307eade3999..84a11d75081 100644 --- a/doc/connectivity/bluetooth/api/audio/shell/csip.rst +++ b/doc/connectivity/bluetooth/api/audio/shell/csip.rst @@ -80,7 +80,7 @@ Discovering sets on a device: bt_csip_set_coordinator.discover_func: Setup complete for 1 / 1 Found 1 sets on device uart:~$ csip_set_coordinator discover_sets - bt_csip_set_coordinator.Set SIRK + bt_csip_set_coordinator.SIRK 36 04 9a dc 66 3a a1 a1 |6...f:.. 1d 9a 2f 41 01 73 3e 01 |../A.s>. bt_csip_set_coordinator.csip_set_coordinator_discover_sets_read_set_size_cb: 2 @@ -109,7 +109,7 @@ Lock set members: bt_csip_set_coordinator.csip_set_coordinator_connected: Connected to 34:02:86:03:86:c0 (public) bt_csip_set_coordinator.discover_func: Setup complete for 1 / 1 bt_csip_set_coordinator.csip_set_coordinator_lock_set_init_cb: - bt_csip_set_coordinator.Set SIRK + bt_csip_set_coordinator.SIRK 36 04 9a dc 66 3a a1 a1 |6...f:.. 1d 9a 2f 41 01 73 3e 01 |../A.s>. bt_csip_set_coordinator.csip_set_coordinator_discover_sets_read_set_size_cb: 2 @@ -149,9 +149,9 @@ Using the Set Member [rank ] [not-lockable] [sirk ] lock :Lock the set release :Release the set [force] - set_sirk :Set the currently used SIRK + sirk :Set the currently used SIRK get_sirk :Get the currently used SIRK - set_sirk_rsp :Set the response used in SIRK requests Example Usage @@ -176,8 +176,8 @@ clients. .. code-block:: console - uart:~$ csip_set_member set_sirk 00112233445566778899aabbccddeeff - Set SIRK updated + uart:~$ csip_set_member sirk 00112233445566778899aabbccddeeff + SIRK updated Getting the current SIRK ------------------------ @@ -187,6 +187,6 @@ This command can get the currently used SIRK. .. code-block:: console uart:~$ csip_set_member get_sirk - Set SIRK + SIRK 36 04 9a dc 66 3a a1 a1 |6...f:.. 1d 9a 2f 41 01 73 3e 01 |../A.s>. diff --git a/doc/releases/migration-guide-3.7.rst b/doc/releases/migration-guide-3.7.rst index 2ef092224bf..1c5a8fd79f7 100644 --- a/doc/releases/migration-guide-3.7.rst +++ b/doc/releases/migration-guide-3.7.rst @@ -446,6 +446,9 @@ Bluetooth Audio This needs to be added to all instances of CAP discovery callback functions defined. (:github:`72797`) +* All occurrences of ``set_sirk`` have been changed to just ``sirk`` as the ``s`` in ``sirk`` stands + for set. (:github:`73413`) + Bluetooth Classic ================= diff --git a/include/zephyr/bluetooth/audio/csip.h b/include/zephyr/bluetooth/audio/csip.h index 1981a23458f..d89f9450cf9 100644 --- a/include/zephyr/bluetooth/audio/csip.h +++ b/include/zephyr/bluetooth/audio/csip.h @@ -44,7 +44,7 @@ extern "C" { #define BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY 0x03 /** Size of the Set Identification Resolving Key (SIRK) */ -#define BT_CSIP_SET_SIRK_SIZE 16 +#define BT_CSIP_SIRK_SIZE 16 /** Size of the Resolvable Set Identifier (RSI) */ #define BT_CSIP_RSI_SIZE 6 @@ -123,7 +123,7 @@ struct bt_csip_set_member_register_param { * This shall be unique between different sets, and shall be the same * for each set member for each set. */ - uint8_t set_sirk[BT_CSIP_SET_SIRK_SIZE]; + uint8_t sirk[BT_CSIP_SIRK_SIZE]; /** * @brief Boolean to set whether the set is lockable by clients @@ -204,8 +204,8 @@ int bt_csip_set_member_unregister(struct bt_csip_set_member_svc_inst *svc_inst); * @param svc_inst Pointer to the registered Coordinated Set Identification Service. * @param sirk The new SIRK. */ -int bt_csip_set_member_set_sirk(struct bt_csip_set_member_svc_inst *svc_inst, - const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE]); +int bt_csip_set_member_sirk(struct bt_csip_set_member_svc_inst *svc_inst, + const uint8_t sirk[BT_CSIP_SIRK_SIZE]); /** * @brief Get the SIRK of a service instance @@ -214,7 +214,7 @@ int bt_csip_set_member_set_sirk(struct bt_csip_set_member_svc_inst *svc_inst, * @param[out] sirk Array to store the SIRK in. */ int bt_csip_set_member_get_sirk(struct bt_csip_set_member_svc_inst *svc_inst, - uint8_t sirk[BT_CSIP_SET_SIRK_SIZE]); + uint8_t sirk[BT_CSIP_SIRK_SIZE]); /** * @brief Generate the Resolvable Set Identifier (RSI) value. @@ -248,10 +248,10 @@ struct bt_csip_set_coordinator_set_info { /** * @brief The 16 octet set Set Identity Resolving Key (SIRK) * - * The Set SIRK may not be exposed by the server over Bluetooth, and + * The SIRK may not be exposed by the server over Bluetooth, and * may require an out-of-band solution. */ - uint8_t set_sirk[BT_CSIP_SET_SIRK_SIZE]; + uint8_t sirk[BT_CSIP_SIRK_SIZE]; /** * @brief The size of the set @@ -382,12 +382,12 @@ struct bt_csip_set_coordinator_cb { /** * @brief Check if advertising data indicates a set member * - * @param set_sirk The SIRK of the set to check against - * @param data The advertising data + * @param sirk The SIRK of the set to check against + * @param data The advertising data * * @return true if the advertising data indicates a set member, false otherwise */ -bool bt_csip_set_coordinator_is_set_member(const uint8_t set_sirk[BT_CSIP_SET_SIRK_SIZE], +bool bt_csip_set_coordinator_is_set_member(const uint8_t sirk[BT_CSIP_SIRK_SIZE], struct bt_data *data); /** diff --git a/include/zephyr/bluetooth/uuid.h b/include/zephyr/bluetooth/uuid.h index f430fc7edf5..8568ebb254d 100644 --- a/include/zephyr/bluetooth/uuid.h +++ b/include/zephyr/bluetooth/uuid.h @@ -4120,12 +4120,11 @@ struct bt_uuid_128 { /** * @brief Set Identity Resolving Key value */ -#define BT_UUID_CSIS_SET_SIRK_VAL 0x2b84 +#define BT_UUID_CSIS_SIRK_VAL 0x2b84 /** * @brief Set Identity Resolving Key */ -#define BT_UUID_CSIS_SET_SIRK \ - BT_UUID_DECLARE_16(BT_UUID_CSIS_SET_SIRK_VAL) +#define BT_UUID_CSIS_SIRK BT_UUID_DECLARE_16(BT_UUID_CSIS_SIRK_VAL) /** * @brief Set size value */ diff --git a/samples/bluetooth/hap_ha/src/csip_set_member.c b/samples/bluetooth/hap_ha/src/csip_set_member.c index 9d76a335571..962ac3579da 100644 --- a/samples/bluetooth/hap_ha/src/csip_set_member.c +++ b/samples/bluetooth/hap_ha/src/csip_set_member.c @@ -41,7 +41,7 @@ int csip_set_member_init(void) .set_size = 2, .rank = CONFIG_HAP_HA_SET_RANK, .lockable = false, - .set_sirk = CSIP_SIRK_DEBUG, + .sirk = CSIP_SIRK_DEBUG, .cb = &csip_cb, }; diff --git a/subsys/bluetooth/audio/csip_crypto.c b/subsys/bluetooth/audio/csip_crypto.c index 3240e6d053e..0efe1fec5a2 100644 --- a/subsys/bluetooth/audio/csip_crypto.c +++ b/subsys/bluetooth/audio/csip_crypto.c @@ -26,7 +26,7 @@ LOG_MODULE_REGISTER(bt_csip_crypto, CONFIG_BT_CSIP_SET_MEMBER_CRYPTO_LOG_LEVEL); #define BT_CSIP_PADDED_RAND_SIZE (BT_CSIP_CRYPTO_PADDING_SIZE + BT_CSIP_CRYPTO_PRAND_SIZE) #define BT_CSIP_R_MASK BIT_MASK(24) /* r is 24 bit / 3 octet */ -int bt_csip_sih(const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE], uint8_t r[BT_CSIP_CRYPTO_PRAND_SIZE], +int bt_csip_sih(const uint8_t sirk[BT_CSIP_SIRK_SIZE], uint8_t r[BT_CSIP_CRYPTO_PRAND_SIZE], uint8_t out[BT_CSIP_CRYPTO_HASH_SIZE]) { uint8_t res[BT_CSIP_PADDED_RAND_SIZE]; /* need to store 128 bit */ @@ -37,7 +37,7 @@ int bt_csip_sih(const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE], uint8_t r[BT_CSIP_CRY LOG_DBG("Invalid r %s", bt_hex(r, BT_CSIP_CRYPTO_PRAND_SIZE)); } - LOG_DBG("SIRK %s", bt_hex(sirk, BT_CSIP_SET_SIRK_SIZE)); + LOG_DBG("SIRK %s", bt_hex(sirk, BT_CSIP_SIRK_SIZE)); LOG_DBG("r %s", bt_hex(r, BT_CSIP_CRYPTO_PRAND_SIZE)); /* r' = padding || r */ @@ -148,9 +148,8 @@ static int s1(const uint8_t *m, size_t m_size, return err; } -int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], - const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE], - uint8_t out_sirk[BT_CSIP_SET_SIRK_SIZE]) +int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], const uint8_t sirk[BT_CSIP_SIRK_SIZE], + uint8_t out_sirk[BT_CSIP_SIRK_SIZE]) { const uint8_t m[] = {'S', 'I', 'R', 'K', 'e', 'n', 'c'}; const uint8_t p[] = {'c', 's', 'i', 's'}; @@ -163,7 +162,7 @@ int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], * sef(K, SIRK) = k1(K, s1("SIRKenc"), "csis") ^ SIRK */ - LOG_DBG("SIRK %s", bt_hex(sirk, BT_CSIP_SET_SIRK_SIZE)); + LOG_DBG("SIRK %s", bt_hex(sirk, BT_CSIP_SIRK_SIZE)); if (IS_ENABLED(CONFIG_LITTLE_ENDIAN)) { /* Swap because aes_cmac is big endian @@ -195,14 +194,13 @@ int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], } mem_xor_128(out_sirk, k1_out, sirk); - LOG_DBG("out %s", bt_hex(out_sirk, BT_CSIP_SET_SIRK_SIZE)); + LOG_DBG("out %s", bt_hex(out_sirk, BT_CSIP_SIRK_SIZE)); return 0; } -int bt_csip_sdf(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], - const uint8_t enc_sirk[BT_CSIP_SET_SIRK_SIZE], - uint8_t out_sirk[BT_CSIP_SET_SIRK_SIZE]) +int bt_csip_sdf(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], const uint8_t enc_sirk[BT_CSIP_SIRK_SIZE], + uint8_t out_sirk[BT_CSIP_SIRK_SIZE]) { /* SIRK encryption is currently symmetric, which means that we can * simply apply the sef function to decrypt it. diff --git a/subsys/bluetooth/audio/csip_crypto.h b/subsys/bluetooth/audio/csip_crypto.h index f644335701e..1a41bf32d54 100644 --- a/subsys/bluetooth/audio/csip_crypto.h +++ b/subsys/bluetooth/audio/csip_crypto.h @@ -27,8 +27,7 @@ * @param out 3 byte LS byte first output buffer * @return int 0 on success, any other value indicates a failure. */ -int bt_csip_sih(const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE], - uint8_t r[BT_CSIP_CRYPTO_PRAND_SIZE], +int bt_csip_sih(const uint8_t sirk[BT_CSIP_SIRK_SIZE], uint8_t r[BT_CSIP_CRYPTO_PRAND_SIZE], uint8_t out[BT_CSIP_CRYPTO_HASH_SIZE]); /** @@ -54,9 +53,8 @@ int bt_csip_sih(const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE], * @param out_sirk The encrypted SIRK. * @return int 0 on success, any other value indicates a failure. */ -int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], - const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE], - uint8_t out_sirk[BT_CSIP_SET_SIRK_SIZE]); +int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], const uint8_t sirk[BT_CSIP_SIRK_SIZE], + uint8_t out_sirk[BT_CSIP_SIRK_SIZE]); /** * @brief SIRK decryption function sdf @@ -81,6 +79,5 @@ int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], * @param out_sirk The decrypted SIRK. * @return int 0 on success, any other value indicates a failure. */ -int bt_csip_sdf(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], - const uint8_t enc_sirk[BT_CSIP_SET_SIRK_SIZE], - uint8_t out_sirk[BT_CSIP_SET_SIRK_SIZE]); +int bt_csip_sdf(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE], const uint8_t enc_sirk[BT_CSIP_SIRK_SIZE], + uint8_t out_sirk[BT_CSIP_SIRK_SIZE]); diff --git a/subsys/bluetooth/audio/csip_internal.h b/subsys/bluetooth/audio/csip_internal.h index 86dcdcc0161..c501ea321e7 100644 --- a/subsys/bluetooth/audio/csip_internal.h +++ b/subsys/bluetooth/audio/csip_internal.h @@ -16,9 +16,9 @@ #define BT_CSIP_RELEASE_VALUE 0x01 #define BT_CSIP_LOCK_VALUE 0x02 -struct bt_csip_set_sirk { +struct bt_csip_sirk { uint8_t type; - uint8_t value[BT_CSIP_SET_SIRK_SIZE]; + uint8_t value[BT_CSIP_SIRK_SIZE]; } __packed; struct bt_csip_set_coordinator_svc_inst *bt_csip_set_coordinator_lookup_instance_by_index( @@ -29,7 +29,7 @@ struct bt_csip_set_coordinator_svc_inst { uint16_t start_handle; uint16_t end_handle; - uint16_t set_sirk_handle; + uint16_t sirk_handle; uint16_t set_size_handle; uint16_t set_lock_handle; uint16_t rank_handle; diff --git a/subsys/bluetooth/audio/csip_set_coordinator.c b/subsys/bluetooth/audio/csip_set_coordinator.c index fb68aa2ee9e..339157981c3 100644 --- a/subsys/bluetooth/audio/csip_set_coordinator.c +++ b/subsys/bluetooth/audio/csip_set_coordinator.c @@ -73,15 +73,15 @@ static struct bt_uuid_16 uuid = BT_UUID_INIT_16(0); static sys_slist_t csip_set_coordinator_cbs = SYS_SLIST_STATIC_INIT(&csip_set_coordinator_cbs); static struct bt_csip_set_coordinator_inst client_insts[CONFIG_BT_MAX_CONN]; -static int read_set_sirk(struct bt_csip_set_coordinator_svc_inst *svc_inst); +static int read_sirk(struct bt_csip_set_coordinator_svc_inst *svc_inst); static int csip_set_coordinator_read_set_size(struct bt_conn *conn, uint8_t inst_idx, bt_gatt_read_func_t cb); static int csip_set_coordinator_read_set_lock(struct bt_csip_set_coordinator_svc_inst *svc_inst); -static uint8_t csip_set_coordinator_discover_insts_read_set_sirk_cb( - struct bt_conn *conn, uint8_t err, struct bt_gatt_read_params *params, - const void *data, uint16_t length); +static uint8_t csip_set_coordinator_discover_insts_read_sirk_cb(struct bt_conn *conn, uint8_t err, + struct bt_gatt_read_params *params, + const void *data, uint16_t length); static void discover_insts_resume(struct bt_conn *conn, uint16_t sirk_handle, uint16_t size_handle, uint16_t rank_handle); @@ -140,9 +140,7 @@ static struct bt_csip_set_coordinator_svc_inst *lookup_instance_by_set_info( member_set_info = &member->insts[i].info; if (member_set_info->set_size == set_info->set_size && - memcmp(&member_set_info->set_sirk, - &set_info->set_sirk, - sizeof(set_info->set_sirk)) == 0) { + memcmp(&member_set_info->sirk, &set_info->sirk, sizeof(set_info->sirk)) == 0) { return bt_csip_set_coordinator_lookup_instance_by_index(inst->conn, i); } } @@ -375,18 +373,17 @@ static uint8_t sirk_notify_func(struct bt_conn *conn, if (svc_inst != NULL) { LOG_DBG("Instance %u", svc_inst->idx); - if (length == sizeof(struct bt_csip_set_sirk)) { - struct bt_csip_set_sirk *sirk = - (struct bt_csip_set_sirk *)data; + if (length == sizeof(struct bt_csip_sirk)) { + struct bt_csip_sirk *sirk = (struct bt_csip_sirk *)data; struct bt_csip_set_coordinator_inst *client; struct bt_csip_set_coordinator_csis_inst *inst; uint8_t *dst_sirk; client = &client_insts[bt_conn_index(conn)]; inst = &client->set_member.insts[svc_inst->idx]; - dst_sirk = inst->info.set_sirk; + dst_sirk = inst->info.sirk; - LOG_DBG("Set SIRK %sencrypted", + LOG_DBG("SIRK %sencrypted", sirk->type == BT_CSIP_SIRK_TYPE_PLAIN ? "not " : ""); /* Assuming not connected to other set devices */ @@ -395,7 +392,7 @@ static uint8_t sirk_notify_func(struct bt_conn *conn, int err; LOG_HEXDUMP_DBG(sirk->value, sizeof(*sirk), - "Encrypted Set SIRK"); + "Encrypted SIRK"); err = sirk_decrypt(conn, sirk->value, dst_sirk); if (err != 0) { @@ -411,8 +408,7 @@ static uint8_t sirk_notify_func(struct bt_conn *conn, (void)memcpy(dst_sirk, sirk->value, sizeof(sirk->value)); } - LOG_HEXDUMP_DBG(dst_sirk, BT_CSIP_SET_SIRK_SIZE, - "Set SIRK"); + LOG_HEXDUMP_DBG(dst_sirk, BT_CSIP_SIRK_SIZE, "SIRK"); sirk_changed(inst); } else { @@ -548,7 +544,7 @@ static int csip_set_coordinator_write_set_lock(struct bt_csip_set_coordinator_sv return bt_gatt_write(inst->conn, &client->write_params); } -static int read_set_sirk(struct bt_csip_set_coordinator_svc_inst *svc_inst) +static int read_sirk(struct bt_csip_set_coordinator_svc_inst *svc_inst) { struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(svc_inst->conn)]; @@ -560,14 +556,14 @@ static int read_set_sirk(struct bt_csip_set_coordinator_svc_inst *svc_inst) client->cur_inst = svc_inst; } - if (svc_inst->set_sirk_handle == 0) { + if (svc_inst->sirk_handle == 0) { LOG_DBG("Handle not set"); return -EINVAL; } - client->read_params.func = csip_set_coordinator_discover_insts_read_set_sirk_cb; + client->read_params.func = csip_set_coordinator_discover_insts_read_sirk_cb; client->read_params.handle_count = 1; - client->read_params.single.handle = svc_inst->set_sirk_handle; + client->read_params.single.handle = svc_inst->sirk_handle; client->read_params.single.offset = 0U; return bt_gatt_read(svc_inst->conn, &client->read_params); @@ -649,7 +645,7 @@ static int csip_set_coordinator_discover_sets(struct bt_csip_set_coordinator_ins int err; /* Start reading values and call CB when done */ - err = read_set_sirk((struct bt_csip_set_coordinator_svc_inst *)member->insts[0].svc_inst); + err = read_sirk((struct bt_csip_set_coordinator_svc_inst *)member->insts[0].svc_inst); if (err == 0) { client->busy = true; } @@ -707,9 +703,9 @@ static uint8_t discover_func(struct bt_conn *conn, if (params->type == BT_GATT_DISCOVER_CHARACTERISTIC && client->inst_count != 0) { chrc = (struct bt_gatt_chrc *)attr->user_data; - if (bt_uuid_cmp(chrc->uuid, BT_UUID_CSIS_SET_SIRK) == 0) { - LOG_DBG("Set SIRK"); - client->cur_inst->set_sirk_handle = chrc->value_handle; + if (bt_uuid_cmp(chrc->uuid, BT_UUID_CSIS_SIRK) == 0) { + LOG_DBG("SIRK"); + client->cur_inst->sirk_handle = chrc->value_handle; sub_params = &client->cur_inst->sirk_sub_params; sub_params->disc_params = &client->cur_inst->sirk_sub_disc_params; notify_handler = sirk_notify_func; @@ -819,8 +815,8 @@ static uint8_t primary_discover_func(struct bt_conn *conn, return BT_GATT_ITER_CONTINUE; } -bool bt_csip_set_coordinator_is_set_member(const uint8_t set_sirk[BT_CSIP_SET_SIRK_SIZE], - struct bt_data *data) +bool bt_csip_set_coordinator_is_set_member(const uint8_t sirk[BT_CSIP_SIRK_SIZE], + struct bt_data *data) { if (data->type == BT_DATA_CSIS_RSI && data->data_len == BT_CSIP_RSI_SIZE) { @@ -834,7 +830,7 @@ bool bt_csip_set_coordinator_is_set_member(const uint8_t set_sirk[BT_CSIP_SET_SI LOG_DBG("hash: %s", bt_hex(hash, BT_CSIP_CRYPTO_HASH_SIZE)); LOG_DBG("prand %s", bt_hex(prand, BT_CSIP_CRYPTO_PRAND_SIZE)); - err = bt_csip_sih(set_sirk, prand, calculated_hash); + err = bt_csip_sih(sirk, prand, calculated_hash); if (err != 0) { return false; } @@ -921,25 +917,23 @@ static uint8_t csip_set_coordinator_discover_insts_read_set_size_cb( static int parse_sirk(struct bt_csip_set_coordinator_inst *client, const void *data, uint16_t length) { - uint8_t *set_sirk; + uint8_t *sirk; - set_sirk = client->set_member.insts[client->cur_inst->idx].info.set_sirk; + sirk = client->set_member.insts[client->cur_inst->idx].info.sirk; - if (length == sizeof(struct bt_csip_set_sirk)) { - struct bt_csip_set_sirk *sirk = - (struct bt_csip_set_sirk *)data; + if (length == sizeof(struct bt_csip_sirk)) { + struct bt_csip_sirk *recvd_sirk = (struct bt_csip_sirk *)data; - LOG_DBG("Set SIRK %sencrypted", - sirk->type == BT_CSIP_SIRK_TYPE_PLAIN ? "not " : ""); + LOG_DBG("SIRK %sencrypted", + recvd_sirk->type == BT_CSIP_SIRK_TYPE_PLAIN ? "not " : ""); /* Assuming not connected to other set devices */ - if (sirk->type == BT_CSIP_SIRK_TYPE_ENCRYPTED) { + if (recvd_sirk->type == BT_CSIP_SIRK_TYPE_ENCRYPTED) { if (IS_ENABLED(CONFIG_BT_CSIP_SET_COORDINATOR_ENC_SIRK_SUPPORT)) { int err; - LOG_HEXDUMP_DBG(sirk->value, sizeof(sirk->value), - "Encrypted Set SIRK"); - err = sirk_decrypt(client->conn, sirk->value, - set_sirk); + LOG_HEXDUMP_DBG(recvd_sirk->value, sizeof(recvd_sirk->value), + "Encrypted SIRK"); + err = sirk_decrypt(client->conn, recvd_sirk->value, sirk); if (err != 0) { LOG_ERR("Could not decrypt " "SIRK %d", @@ -948,16 +942,15 @@ static int parse_sirk(struct bt_csip_set_coordinator_inst *client, } } else { LOG_WRN("Encrypted SIRK not supported"); - set_sirk = NULL; + sirk = NULL; return BT_ATT_ERR_INSUFFICIENT_ENCRYPTION; } } else { - (void)memcpy(set_sirk, sirk->value, sizeof(sirk->value)); + (void)memcpy(sirk, recvd_sirk->value, sizeof(recvd_sirk->value)); } - if (set_sirk != NULL) { - LOG_HEXDUMP_DBG(set_sirk, BT_CSIP_SET_SIRK_SIZE, - "Set SIRK"); + if (sirk != NULL) { + LOG_HEXDUMP_DBG(sirk, BT_CSIP_SIRK_SIZE, "SIRK"); } } else { LOG_DBG("Invalid length"); @@ -967,9 +960,9 @@ static int parse_sirk(struct bt_csip_set_coordinator_inst *client, return 0; } -static uint8_t csip_set_coordinator_discover_insts_read_set_sirk_cb( - struct bt_conn *conn, uint8_t err, struct bt_gatt_read_params *params, - const void *data, uint16_t length) +static uint8_t csip_set_coordinator_discover_insts_read_sirk_cb(struct bt_conn *conn, uint8_t err, + struct bt_gatt_read_params *params, + const void *data, uint16_t length) { struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; int cb_err = err; @@ -1036,7 +1029,7 @@ static void discover_insts_resume(struct bt_conn *conn, uint16_t sirk_handle, bt_csip_set_coordinator_lookup_instance_by_index(conn, next_idx); /* Read next */ - cb_err = read_set_sirk(client->cur_inst); + cb_err = read_sirk(client->cur_inst); } else { discover_complete(client, 0); @@ -1351,7 +1344,7 @@ static void csip_set_coordinator_reset(struct bt_csip_set_coordinator_inst *inst svc_inst->set_lock = 0; svc_inst->start_handle = 0; svc_inst->end_handle = 0; - svc_inst->set_sirk_handle = 0; + svc_inst->sirk_handle = 0; svc_inst->set_size_handle = 0; svc_inst->set_lock_handle = 0; svc_inst->rank_handle = 0; diff --git a/subsys/bluetooth/audio/csip_set_member.c b/subsys/bluetooth/audio/csip_set_member.c index 20019137103..d038020f9c8 100644 --- a/subsys/bluetooth/audio/csip_set_member.c +++ b/subsys/bluetooth/audio/csip_set_member.c @@ -54,7 +54,7 @@ struct csip_client { }; struct bt_csip_set_member_svc_inst { - struct bt_csip_set_sirk set_sirk; + struct bt_csip_sirk sirk; uint8_t set_size; uint8_t set_lock; uint8_t rank; @@ -127,9 +127,8 @@ static void notify_clients(struct bt_csip_set_member_svc_inst *svc_inst, } } -static int sirk_encrypt(struct bt_conn *conn, - const struct bt_csip_set_sirk *sirk, - struct bt_csip_set_sirk *enc_sirk) +static int sirk_encrypt(struct bt_conn *conn, const struct bt_csip_sirk *sirk, + struct bt_csip_sirk *enc_sirk) { int err; uint8_t *k; @@ -214,7 +213,7 @@ int bt_csip_set_member_generate_rsi(const struct bt_csip_set_member_svc_inst *sv } } - res = bt_csip_sih(svc_inst->set_sirk.value, prand, hash); + res = bt_csip_sih(svc_inst->sirk.value, prand, hash); if (res != 0) { LOG_WRN("Could not generate new RSI"); return res; @@ -226,12 +225,11 @@ int bt_csip_set_member_generate_rsi(const struct bt_csip_set_member_svc_inst *sv return res; } -static ssize_t read_set_sirk(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - void *buf, uint16_t len, uint16_t offset) +static ssize_t read_sirk(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) { - struct bt_csip_set_sirk enc_sirk; - struct bt_csip_set_sirk *sirk; + struct bt_csip_sirk enc_sirk; + struct bt_csip_sirk *sirk; struct bt_csip_set_member_svc_inst *svc_inst = BT_AUDIO_CHRC_USER_DATA(attr); if (svc_inst->cb != NULL && svc_inst->cb->sirk_read_req != NULL) { @@ -242,22 +240,20 @@ static ssize_t read_set_sirk(struct bt_conn *conn, cb_rsp = svc_inst->cb->sirk_read_req(conn, &svc_insts[0]); if (cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT) { - sirk = &svc_inst->set_sirk; + sirk = &svc_inst->sirk; } else if (IS_ENABLED(CONFIG_BT_CSIP_SET_MEMBER_ENC_SIRK_SUPPORT) && cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC) { int err; - err = sirk_encrypt(conn, &svc_inst->set_sirk, - &enc_sirk); + err = sirk_encrypt(conn, &svc_inst->sirk, &enc_sirk); if (err != 0) { LOG_ERR("Could not encrypt SIRK: %d", err); gatt_err = BT_GATT_ERR(BT_ATT_ERR_UNLIKELY); } else { sirk = &enc_sirk; - LOG_HEXDUMP_DBG(enc_sirk.value, - sizeof(enc_sirk.value), - "Encrypted Set SIRK"); + LOG_HEXDUMP_DBG(enc_sirk.value, sizeof(enc_sirk.value), + "Encrypted SIRK"); } } else if (cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_REJECT) { gatt_err = BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); @@ -272,21 +268,17 @@ static ssize_t read_set_sirk(struct bt_conn *conn, return gatt_err; } } else { - sirk = &svc_inst->set_sirk; + sirk = &svc_inst->sirk; } - - LOG_DBG("Set sirk %sencrypted", - sirk->type == BT_CSIP_SIRK_TYPE_PLAIN ? "not " : ""); - LOG_HEXDUMP_DBG(svc_inst->set_sirk.value, - sizeof(svc_inst->set_sirk.value), "Set SIRK"); + LOG_DBG("SIRK %sencrypted", sirk->type == BT_CSIP_SIRK_TYPE_PLAIN ? "not " : ""); + LOG_HEXDUMP_DBG(svc_inst->sirk.value, sizeof(svc_inst->sirk.value), "SIRK"); return bt_gatt_attr_read(conn, attr, buf, len, offset, sirk, sizeof(*sirk)); } #if defined(CONFIG_BT_CSIP_SET_MEMBER_NOTIFIABLE) -static void set_sirk_cfg_changed(const struct bt_gatt_attr *attr, - uint16_t value) +static void sirk_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) { LOG_DBG("value 0x%04x", value); } @@ -616,13 +608,13 @@ static struct bt_conn_auth_info_cb auth_callbacks = { #if defined(CONFIG_BT_CSIP_SET_MEMBER_NOTIFIABLE) #define BT_CSIS_CHR_SIRK(_csip) \ - BT_AUDIO_CHRC(BT_UUID_CSIS_SET_SIRK, BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, \ - BT_GATT_PERM_READ_ENCRYPT, read_set_sirk, NULL, &_csip), \ - BT_AUDIO_CCC(set_sirk_cfg_changed) + BT_AUDIO_CHRC(BT_UUID_CSIS_SIRK, BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, \ + BT_GATT_PERM_READ_ENCRYPT, read_sirk, NULL, &_csip), \ + BT_AUDIO_CCC(sirk_cfg_changed) #else #define BT_CSIS_CHR_SIRK(_csip) \ - BT_AUDIO_CHRC(BT_UUID_CSIS_SET_SIRK, BT_GATT_CHRC_READ, BT_GATT_PERM_READ_ENCRYPT, \ - read_set_sirk, NULL, &_csip) + BT_AUDIO_CHRC(BT_UUID_CSIS_SIRK, BT_GATT_CHRC_READ, BT_GATT_PERM_READ_ENCRYPT, read_sirk, \ + NULL, &_csip) #endif /* CONFIG_BT_CSIP_SET_MEMBER_NOTIFIABLE */ #define BT_CSIP_SERVICE_DEFINITION(_csip) {\ @@ -771,8 +763,8 @@ static void notify_cb(struct bt_conn *conn, void *data) if (IS_ENABLED(CONFIG_BT_CSIP_SET_MEMBER_NOTIFIABLE) && atomic_test_and_clear_bit(client->flags, FLAG_NOTIFY_SIRK)) { - notify(svc_inst, conn, BT_UUID_CSIS_SET_SIRK, &svc_inst->set_sirk, - sizeof(svc_inst->set_sirk)); + notify(svc_inst, conn, BT_UUID_CSIS_SIRK, &svc_inst->sirk, + sizeof(svc_inst->sirk)); } } } @@ -869,7 +861,7 @@ int bt_csip_set_member_register(const struct bt_csip_set_member_register_param * inst->rank = param->rank; inst->set_size = param->set_size; inst->set_lock = BT_CSIP_RELEASE_VALUE; - inst->set_sirk.type = BT_CSIP_SIRK_TYPE_PLAIN; + inst->sirk.type = BT_CSIP_SIRK_TYPE_PLAIN; inst->cb = param->cb; if (IS_ENABLED(CONFIG_BT_CSIP_SET_MEMBER_TEST_SAMPLE_DATA)) { @@ -878,12 +870,10 @@ int bt_csip_set_member_register(const struct bt_csip_set_member_register_param * 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45, }; - (void)memcpy(inst->set_sirk.value, test_sirk, - sizeof(test_sirk)); + (void)memcpy(inst->sirk.value, test_sirk, sizeof(test_sirk)); LOG_DBG("CSIP SIRK was overwritten by sample data SIRK"); } else { - (void)memcpy(inst->set_sirk.value, param->set_sirk, - sizeof(inst->set_sirk.value)); + (void)memcpy(inst->sirk.value, param->sirk, sizeof(inst->sirk.value)); } *svc_inst = inst; @@ -911,8 +901,8 @@ int bt_csip_set_member_unregister(struct bt_csip_set_member_svc_inst *svc_inst) return 0; } -int bt_csip_set_member_set_sirk(struct bt_csip_set_member_svc_inst *svc_inst, - const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE]) +int bt_csip_set_member_sirk(struct bt_csip_set_member_svc_inst *svc_inst, + const uint8_t sirk[BT_CSIP_SIRK_SIZE]) { CHECKIF(svc_inst == NULL) { LOG_DBG("NULL svc_inst"); @@ -924,7 +914,7 @@ int bt_csip_set_member_set_sirk(struct bt_csip_set_member_svc_inst *svc_inst, return -EINVAL; } - memcpy(svc_inst->set_sirk.value, sirk, BT_CSIP_SET_SIRK_SIZE); + memcpy(svc_inst->sirk.value, sirk, BT_CSIP_SIRK_SIZE); notify_clients(svc_inst, NULL, FLAG_NOTIFY_SIRK); @@ -932,7 +922,7 @@ int bt_csip_set_member_set_sirk(struct bt_csip_set_member_svc_inst *svc_inst, } int bt_csip_set_member_get_sirk(struct bt_csip_set_member_svc_inst *svc_inst, - uint8_t sirk[BT_CSIP_SET_SIRK_SIZE]) + uint8_t sirk[BT_CSIP_SIRK_SIZE]) { CHECKIF(svc_inst == NULL) { LOG_DBG("NULL svc_inst"); @@ -944,7 +934,7 @@ int bt_csip_set_member_get_sirk(struct bt_csip_set_member_svc_inst *svc_inst, return -EINVAL; } - memcpy(sirk, svc_inst->set_sirk.value, BT_CSIP_SET_SIRK_SIZE); + memcpy(sirk, svc_inst->sirk.value, BT_CSIP_SIRK_SIZE); return 0; } diff --git a/subsys/bluetooth/audio/shell/cap_acceptor.c b/subsys/bluetooth/audio/shell/cap_acceptor.c index 0558511905f..fc399221e8d 100644 --- a/subsys/bluetooth/audio/shell/cap_acceptor.c +++ b/subsys/bluetooth/audio/shell/cap_acceptor.c @@ -81,9 +81,9 @@ static int cmd_cap_acceptor_init(const struct shell *sh, size_t argc, .rank = 1, .lockable = true, /* Using the CSIS test sample SIRK */ - .set_sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, - 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 }, - .cb = &csip_set_member_cbs + .sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, + 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 }, + .cb = &csip_set_member_cbs, }; int err = 0; @@ -150,8 +150,8 @@ static int cmd_cap_acceptor_init(const struct shell *sh, size_t argc, return SHELL_CMD_HELP_PRINTED; } - len = hex2bin(argv[argn], strlen(argv[argn]), - param.set_sirk, sizeof(param.set_sirk)); + len = hex2bin(argv[argn], strlen(argv[argn]), param.sirk, + sizeof(param.sirk)); if (len == 0) { shell_error(sh, "Could not parse SIRK"); @@ -220,9 +220,9 @@ static int cmd_cap_acceptor_release(const struct shell *sh, size_t argc, return 0; } -static int cmd_cap_acceptor_set_sirk(const struct shell *sh, size_t argc, char *argv[]) +static int cmd_cap_acceptor_sirk(const struct shell *sh, size_t argc, char *argv[]) { - uint8_t sirk[BT_CSIP_SET_SIRK_SIZE]; + uint8_t sirk[BT_CSIP_SIRK_SIZE]; size_t len; int err; @@ -239,7 +239,7 @@ static int cmd_cap_acceptor_set_sirk(const struct shell *sh, size_t argc, char * return -ENOEXEC; } - err = bt_csip_set_member_set_sirk(cap_csip_svc_inst, sirk); + err = bt_csip_set_member_sirk(cap_csip_svc_inst, sirk); if (err != 0) { shell_error(sh, "Failed to set SIRK: %d", err); return -ENOEXEC; @@ -252,7 +252,7 @@ static int cmd_cap_acceptor_set_sirk(const struct shell *sh, size_t argc, char * static int cmd_cap_acceptor_get_sirk(const struct shell *sh, size_t argc, char *argv[]) { - uint8_t sirk[BT_CSIP_SET_SIRK_SIZE]; + uint8_t sirk[BT_CSIP_SIRK_SIZE]; int err; if (cap_csip_svc_inst == NULL) { @@ -267,14 +267,13 @@ static int cmd_cap_acceptor_get_sirk(const struct shell *sh, size_t argc, char * return -ENOEXEC; } - shell_print(sh, "Set SIRK"); + shell_print(sh, "SIRK"); shell_hexdump(sh, sirk, sizeof(sirk)); return 0; } -static int cmd_cap_acceptor_set_sirk_rsp(const struct shell *sh, size_t argc, - char *argv[]) +static int cmd_cap_acceptor_sirk_rsp(const struct shell *sh, size_t argc, char *argv[]) { if (strcmp(argv[1], "accept") == 0) { sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT; @@ -299,26 +298,23 @@ static int cmd_cap_acceptor(const struct shell *sh, size_t argc, char **argv) return -ENOEXEC; } -SHELL_STATIC_SUBCMD_SET_CREATE(cap_acceptor_cmds, +SHELL_STATIC_SUBCMD_SET_CREATE( + cap_acceptor_cmds, SHELL_CMD_ARG(init, NULL, "Initialize the service and register callbacks " "[size ] [rank ] [not-lockable] [sirk ]", cmd_cap_acceptor_init, 1, 4), - SHELL_CMD_ARG(lock, NULL, - "Lock the set", - cmd_cap_acceptor_lock, 1, 0), - SHELL_CMD_ARG(release, NULL, - "Release the set [force]", - cmd_cap_acceptor_release, 1, 1), - SHELL_CMD_ARG(set_sirk, NULL, "Set the currently used SIRK ", - cmd_cap_acceptor_set_sirk, 2, 0), - SHELL_CMD_ARG(get_sirk, NULL, "Get the currently used SIRK", cmd_cap_acceptor_get_sirk, - 1, 0), - SHELL_CMD_ARG(set_sirk_rsp, NULL, + SHELL_CMD_ARG(lock, NULL, "Lock the set", cmd_cap_acceptor_lock, 1, 0), + SHELL_CMD_ARG(release, NULL, "Release the set [force]", cmd_cap_acceptor_release, 1, 1), + SHELL_CMD_ARG(sirk, NULL, "Set the currently used SIRK ", cmd_cap_acceptor_sirk, 2, + 0), + SHELL_CMD_ARG(get_sirk, NULL, "Get the currently used SIRK", cmd_cap_acceptor_get_sirk, 1, + 0), + SHELL_CMD_ARG(sirk_rsp, NULL, "Set the response used in SIRK requests " "", - cmd_cap_acceptor_set_sirk_rsp, 2, 0), - SHELL_SUBCMD_SET_END + cmd_cap_acceptor_sirk_rsp, 2, 0), + SHELL_SUBCMD_SET_END ); SHELL_CMD_ARG_REGISTER(cap_acceptor, &cap_acceptor_cmds, "Bluetooth CAP acceptor shell commands", diff --git a/subsys/bluetooth/audio/shell/csip_set_coordinator.c b/subsys/bluetooth/audio/shell/csip_set_coordinator.c index 755807dbb02..f89145edf42 100644 --- a/subsys/bluetooth/audio/shell/csip_set_coordinator.c +++ b/subsys/bluetooth/audio/shell/csip_set_coordinator.c @@ -181,7 +181,7 @@ static struct bt_le_scan_cb csip_set_coordinator_scan_callbacks = { static bool csip_found(struct bt_data *data, void *user_data) { - if (bt_csip_set_coordinator_is_set_member(cur_inst->info.set_sirk, data)) { + if (bt_csip_set_coordinator_is_set_member(cur_inst->info.sirk, data)) { bt_addr_le_t *addr = user_data; char addr_str[BT_ADDR_LE_STR_LEN]; @@ -325,8 +325,7 @@ static int cmd_csip_set_coordinator_discover_members(const struct shell *sh, const struct bt_csip_set_coordinator_csis_inst *inst = &set_members[i]->insts[j]; - if (memcmp(inst->info.set_sirk, cur_inst->info.set_sirk, - BT_CSIP_SET_SIRK_SIZE) == 0) { + if (memcmp(inst->info.sirk, cur_inst->info.sirk, BT_CSIP_SIRK_SIZE) == 0) { bt_addr_le_copy(&addr_found[members_found++], bt_conn_get_dst(conns[i])); break; diff --git a/subsys/bluetooth/audio/shell/csip_set_member.c b/subsys/bluetooth/audio/shell/csip_set_member.c index ed7364ffb24..65257506626 100644 --- a/subsys/bluetooth/audio/shell/csip_set_member.c +++ b/subsys/bluetooth/audio/shell/csip_set_member.c @@ -69,9 +69,9 @@ static int cmd_csip_set_member_register(const struct shell *sh, size_t argc, cha .rank = 1, .lockable = true, /* Using the CSIS test sample SIRK */ - .set_sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, - 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 }, - .cb = &csip_set_member_cbs + .sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, + 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 }, + .cb = &csip_set_member_cbs, }; for (size_t argn = 1; argn < argc; argn++) { @@ -136,8 +136,8 @@ static int cmd_csip_set_member_register(const struct shell *sh, size_t argc, cha return SHELL_CMD_HELP_PRINTED; } - len = hex2bin(argv[argn], strlen(argv[argn]), - param.set_sirk, sizeof(param.set_sirk)); + len = hex2bin(argv[argn], strlen(argv[argn]), param.sirk, + sizeof(param.sirk)); if (len == 0) { shell_error(sh, "Could not parse SIRK"); return -ENOEXEC; @@ -157,9 +157,9 @@ static int cmd_csip_set_member_register(const struct shell *sh, size_t argc, cha return 0; } -static int cmd_csip_set_member_set_sirk(const struct shell *sh, size_t argc, char *argv[]) +static int cmd_csip_set_member_sirk(const struct shell *sh, size_t argc, char *argv[]) { - uint8_t sirk[BT_CSIP_SET_SIRK_SIZE]; + uint8_t sirk[BT_CSIP_SIRK_SIZE]; size_t len; int err; @@ -176,7 +176,7 @@ static int cmd_csip_set_member_set_sirk(const struct shell *sh, size_t argc, cha return -ENOEXEC; } - err = bt_csip_set_member_set_sirk(svc_inst, sirk); + err = bt_csip_set_member_sirk(svc_inst, sirk); if (err != 0) { shell_error(sh, "Failed to set SIRK: %d", err); return -ENOEXEC; @@ -189,7 +189,7 @@ static int cmd_csip_set_member_set_sirk(const struct shell *sh, size_t argc, cha static int cmd_csip_set_member_get_sirk(const struct shell *sh, size_t argc, char *argv[]) { - uint8_t sirk[BT_CSIP_SET_SIRK_SIZE]; + uint8_t sirk[BT_CSIP_SIRK_SIZE]; int err; if (svc_inst == NULL) { @@ -204,7 +204,7 @@ static int cmd_csip_set_member_get_sirk(const struct shell *sh, size_t argc, cha return -ENOEXEC; } - shell_print(sh, "Set SIRK"); + shell_print(sh, "SIRK"); shell_hexdump(sh, sirk, sizeof(sirk)); return 0; @@ -252,8 +252,7 @@ static int cmd_csip_set_member_release(const struct shell *sh, size_t argc, return 0; } -static int cmd_csip_set_member_set_sirk_rsp(const struct shell *sh, size_t argc, - char *argv[]) +static int cmd_csip_set_member_sirk_rsp(const struct shell *sh, size_t argc, char *argv[]) { if (strcmp(argv[1], "accept") == 0) { sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT; @@ -286,14 +285,14 @@ SHELL_STATIC_SUBCMD_SET_CREATE( cmd_csip_set_member_register, 1, 4), SHELL_CMD_ARG(lock, NULL, "Lock the set", cmd_csip_set_member_lock, 1, 0), SHELL_CMD_ARG(release, NULL, "Release the set [force]", cmd_csip_set_member_release, 1, 1), - SHELL_CMD_ARG(set_sirk, NULL, "Set the currently used SIRK ", - cmd_csip_set_member_set_sirk, 2, 0), + SHELL_CMD_ARG(sirk, NULL, "Set the currently used SIRK ", cmd_csip_set_member_sirk, 2, + 0), SHELL_CMD_ARG(get_sirk, NULL, "Get the currently used SIRK", cmd_csip_set_member_get_sirk, 1, 0), - SHELL_CMD_ARG(set_sirk_rsp, NULL, + SHELL_CMD_ARG(sirk_rsp, NULL, "Set the response used in SIRK requests " "", - cmd_csip_set_member_set_sirk_rsp, 2, 0), + cmd_csip_set_member_sirk_rsp, 2, 0), SHELL_SUBCMD_SET_END ); diff --git a/tests/bluetooth/tester/src/btp/btp_csip.h b/tests/bluetooth/tester/src/btp/btp_csip.h index 362f1bafd75..a3c76fe56f8 100644 --- a/tests/bluetooth/tester/src/btp/btp_csip.h +++ b/tests/bluetooth/tester/src/btp/btp_csip.h @@ -49,7 +49,7 @@ struct btp_csip_discovered_ev { #define BTP_CSIP_SIRK_EV 0x81 struct btp_csip_sirk_ev { bt_addr_le_t address; - uint8_t sirk[BT_CSIP_SET_SIRK_SIZE]; + uint8_t sirk[BT_CSIP_SIRK_SIZE]; } __packed; #define BTP_CSIP_LOCK_EV 0x82 diff --git a/tests/bluetooth/tester/src/btp/btp_csis.h b/tests/bluetooth/tester/src/btp/btp_csis.h index 1a9d34221a3..53857f64f0b 100644 --- a/tests/bluetooth/tester/src/btp/btp_csis.h +++ b/tests/bluetooth/tester/src/btp/btp_csis.h @@ -30,6 +30,6 @@ struct btp_csis_get_member_rsi_rp { } __packed; #define BTP_CSIS_ENC_SIRK_TYPE 0x04 -struct btp_csis_set_sirk_type_cmd { +struct btp_csis_sirk_type_cmd { uint8_t encrypted; } __packed; diff --git a/tests/bluetooth/tester/src/btp_cas.c b/tests/bluetooth/tester/src/btp_cas.c index feb64ea3323..78e3a8f2878 100644 --- a/tests/bluetooth/tester/src/btp_cas.c +++ b/tests/bluetooth/tester/src/btp_cas.c @@ -86,11 +86,11 @@ uint8_t tester_init_cas(void) #if defined(CONFIG_BT_CAP_ACCEPTOR) && defined(CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER) struct bt_csip_set_member_register_param register_params = { .set_size = 2, - .set_sirk = { 0xB8, 0x03, 0xEA, 0xC6, 0xAF, 0xBB, 0x65, 0xA2, - 0x5A, 0x41, 0xF1, 0x53, 0x05, 0x68, 0x8E, 0x83 }, + .sirk = { 0xB8, 0x03, 0xEA, 0xC6, 0xAF, 0xBB, 0x65, 0xA2, + 0x5A, 0x41, 0xF1, 0x53, 0x05, 0x68, 0x8E, 0x83 }, .lockable = true, .rank = 1, - .cb = NULL + .cb = NULL, }; int err = bt_cap_acceptor_register(®ister_params, &csis_svc_inst); #else diff --git a/tests/bluetooth/tester/src/btp_csip.c b/tests/bluetooth/tester/src/btp_csip.c index 62df2c71717..f7068e13b21 100644 --- a/tests/bluetooth/tester/src/btp_csip.c +++ b/tests/bluetooth/tester/src/btp_csip.c @@ -92,7 +92,7 @@ static void csip_discover_cb(struct bt_conn *conn, { LOG_DBG(""); - uint8_t sirk[BT_CSIP_SET_SIRK_SIZE]; + uint8_t sirk[BT_CSIP_SIRK_SIZE]; size_t sirk_size = ARRAY_SIZE(sirk); uint8_t conn_index; @@ -112,7 +112,7 @@ static void csip_discover_cb(struct bt_conn *conn, cur_csis_inst = &member->insts[0]; - memcpy(sirk, cur_csis_inst->info.set_sirk, sizeof(cur_csis_inst->info.set_sirk)); + memcpy(sirk, cur_csis_inst->info.sirk, sizeof(cur_csis_inst->info.sirk)); btp_send_csip_sirk_ev(conn, sirk, sirk_size); @@ -126,7 +126,7 @@ static void csip_discover_cb(struct bt_conn *conn, btp_csip_set_members[conn_index] = member; csip_inst = bt_csip_set_coordinator_lookup_instance_by_index(conn, conn_index); - btp_send_csip_discovered_ev(conn, csip_inst->set_sirk_handle, csip_inst->set_size_handle, + btp_send_csip_discovered_ev(conn, csip_inst->sirk_handle, csip_inst->set_size_handle, csip_inst->set_lock_handle, csip_inst->rank_handle, err); } diff --git a/tests/bluetooth/tester/src/btp_csis.c b/tests/bluetooth/tester/src/btp_csis.c index f0d14f114f5..8c8d09eaea7 100644 --- a/tests/bluetooth/tester/src/btp_csis.c +++ b/tests/bluetooth/tester/src/btp_csis.c @@ -63,14 +63,13 @@ static uint8_t csis_get_member_rsi(const void *cmd, uint16_t cmd_len, return BTP_STATUS_VAL(err); } -static uint8_t csis_set_sirk_type(const void *cmd, uint16_t cmd_len, void *rsp, - uint16_t *rsp_len) +static uint8_t csis_sirk_type(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len) { - const struct btp_csis_set_sirk_type_cmd *cp = cmd; + const struct btp_csis_sirk_type_cmd *cp = cmd; enc_sirk = cp->encrypted != 0U; - LOG_DBG("Set SIRK type: %s", enc_sirk ? "encrypted" : "plain text"); + LOG_DBG("SIRK type: %s", enc_sirk ? "encrypted" : "plain text"); return BTP_STATUS_SUCCESS; } @@ -80,22 +79,22 @@ static const struct btp_handler csis_handlers[] = { .opcode = BTP_CSIS_READ_SUPPORTED_COMMANDS, .index = BTP_INDEX_NONE, .expect_len = 0, - .func = csis_supported_commands + .func = csis_supported_commands, }, { .opcode = BTP_CSIS_SET_MEMBER_LOCK, .expect_len = sizeof(struct btp_csis_set_member_lock_cmd), - .func = csis_set_member_lock + .func = csis_set_member_lock, }, { .opcode = BTP_CSIS_GET_MEMBER_RSI, .expect_len = sizeof(struct btp_csis_get_member_rsi_cmd), - .func = csis_get_member_rsi + .func = csis_get_member_rsi, }, { .opcode = BTP_CSIS_ENC_SIRK_TYPE, - .expect_len = sizeof(struct btp_csis_set_sirk_type_cmd), - .func = csis_set_sirk_type, + .expect_len = sizeof(struct btp_csis_sirk_type_cmd), + .func = csis_sirk_type, }, }; @@ -123,8 +122,8 @@ uint8_t tester_init_csis(void) { const struct bt_csip_set_member_register_param register_params = { .set_size = 1, - .set_sirk = { 0xB8, 0x03, 0xEA, 0xC6, 0xAF, 0xBB, 0x65, 0xA2, - 0x5A, 0x41, 0xF1, 0x53, 0x05, 0x68, 0x8E, 0x83 }, + .sirk = { 0xB8, 0x03, 0xEA, 0xC6, 0xAF, 0xBB, 0x65, 0xA2, + 0x5A, 0x41, 0xF1, 0x53, 0x05, 0x68, 0x8E, 0x83 }, .lockable = true, .rank = 1, .cb = &csis_cb, diff --git a/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c b/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c index a2655bb830a..85d77d36cf7 100644 --- a/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c +++ b/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c @@ -562,8 +562,8 @@ static void init(void) .rank = 1, .lockable = true, /* Using the CSIP_SET_MEMBER test sample SIRK */ - .set_sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, - 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 }, + .sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, + 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 }, }; int err; diff --git a/tests/bsim/bluetooth/audio/src/csip_set_coordinator_test.c b/tests/bsim/bluetooth/audio/src/csip_set_coordinator_test.c index 45fcd8a4a6a..f5132bb3d83 100644 --- a/tests/bsim/bluetooth/audio/src/csip_set_coordinator_test.c +++ b/tests/bsim/bluetooth/audio/src/csip_set_coordinator_test.c @@ -169,7 +169,7 @@ static bool is_discovered(const bt_addr_le_t *addr) static bool csip_found(struct bt_data *data, void *user_data) { - if (bt_csip_set_coordinator_is_set_member(primary_inst->info.set_sirk, data)) { + if (bt_csip_set_coordinator_is_set_member(primary_inst->info.sirk, data)) { const bt_addr_le_t *addr = user_data; char addr_str[BT_ADDR_LE_STR_LEN]; diff --git a/tests/bsim/bluetooth/audio/src/csip_set_member_test.c b/tests/bsim/bluetooth/audio/src/csip_set_member_test.c index 99181a376b1..d926067680d 100644 --- a/tests/bsim/bluetooth/audio/src/csip_set_member_test.c +++ b/tests/bsim/bluetooth/audio/src/csip_set_member_test.c @@ -18,8 +18,8 @@ struct bt_csip_set_member_register_param param = { .rank = 1, .lockable = true, /* Using the CSIS test sample SIRK */ - .set_sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, - 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 }, + .sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, + 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 }, }; static void csip_lock_changed_cb(struct bt_conn *conn, @@ -76,15 +76,15 @@ static void bt_ready(int err) } } -static void test_set_sirk(void) +static void test_sirk(void) { - const uint8_t new_set_sirk[] = {0xff, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, - 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45}; - uint8_t tmp_sirk[BT_CSIP_SET_SIRK_SIZE]; + const uint8_t new_sirk[] = {0xff, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, + 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45}; + uint8_t tmp_sirk[BT_CSIP_SIRK_SIZE]; int err; printk("Setting new SIRK\n"); - err = bt_csip_set_member_set_sirk(svc_inst, new_set_sirk); + err = bt_csip_set_member_sirk(svc_inst, new_sirk); if (err != 0) { FAIL("Failed to set SIRK: %d\n", err); return; @@ -97,7 +97,7 @@ static void test_set_sirk(void) return; } - if (memcmp(new_set_sirk, tmp_sirk, BT_CSIP_SET_SIRK_SIZE) != 0) { + if (memcmp(new_sirk, tmp_sirk, BT_CSIP_SIRK_SIZE) != 0) { FAIL("The SIRK set and the SIRK set were different\n"); return; } @@ -193,7 +193,7 @@ static void test_new_sirk(void) backchannel_sync_send_all(); backchannel_sync_wait_all(); - test_set_sirk(); + test_sirk(); WAIT_FOR_UNSET_FLAG(flag_connected); @@ -223,8 +223,8 @@ static void test_args(int argc, char *argv[]) argn++; - len = hex2bin(argv[argn], strlen(argv[argn]), - param.set_sirk, sizeof(param.set_sirk)); + len = hex2bin(argv[argn], strlen(argv[argn]), param.sirk, + sizeof(param.sirk)); if (len == 0) { FAIL("Could not parse SIRK"); return; diff --git a/tests/bsim/bluetooth/audio/src/gmap_ugt_test.c b/tests/bsim/bluetooth/audio/src/gmap_ugt_test.c index f4e92886a86..fc354172efe 100644 --- a/tests/bsim/bluetooth/audio/src/gmap_ugt_test.c +++ b/tests/bsim/bluetooth/audio/src/gmap_ugt_test.c @@ -362,8 +362,8 @@ static void test_main(void) .rank = csis_rank, .lockable = true, /* Using the CSIP_SET_MEMBER test sample SIRK */ - .set_sirk = {0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, 0x22, 0xfd, - 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45}, + .sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, + 0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 }, }; err = bt_cap_acceptor_register(&csip_set_member_param, &csip_set_member);