linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 1/3] client/assistant: Detect if object already contains a valid BCode
@ 2025-10-02 13:40 Luiz Augusto von Dentz
  2025-10-02 13:40 ` [PATCH BlueZ v2 2/3] shared/bass: Fix permissions not requiring encryption Luiz Augusto von Dentz
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2025-10-02 13:40 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If assistant object already contains a valid (non-zero) BCode
(e.g state=local) use it instead of always request the user to
re-enter.
---
 client/assistant.c | 55 ++++++++++++++++++++++++++++++++++------------
 1 file changed, 41 insertions(+), 14 deletions(-)

diff --git a/client/assistant.c b/client/assistant.c
index 1ff8001d7216..ed0c8cdd6c7a 100644
--- a/client/assistant.c
+++ b/client/assistant.c
@@ -293,7 +293,7 @@ fail:
 
 static bool assistant_get_qos(struct assistant_config *cfg)
 {
-	DBusMessageIter iter, dict, entry, value;
+	DBusMessageIter iter, dict;
 	const char *key;
 
 	/* Get QoS property to check if the stream is encrypted */
@@ -305,22 +305,45 @@ static bool assistant_get_qos(struct assistant_config *cfg)
 
 	dbus_message_iter_recurse(&iter, &dict);
 
-	if (dbus_message_iter_get_arg_type(&dict) != DBUS_TYPE_DICT_ENTRY)
-		return false;
+	while (dbus_message_iter_get_arg_type(&dict) != DBUS_TYPE_DICT_ENTRY) {
+		DBusMessageIter entry, value;
+		int var;
 
-	dbus_message_iter_recurse(&dict, &entry);
-	dbus_message_iter_get_basic(&entry, &key);
+		dbus_message_iter_recurse(&dict, &entry);
+		dbus_message_iter_get_basic(&entry, &key);
 
-	if (strcasecmp(key, "Encryption") != 0)
-		return false;
+		dbus_message_iter_next(&entry);
+		dbus_message_iter_recurse(&entry, &value);
 
-	dbus_message_iter_next(&entry);
-	dbus_message_iter_recurse(&entry, &value);
+		var = dbus_message_iter_get_arg_type(&value);
 
-	if (dbus_message_iter_get_arg_type(&value) != DBUS_TYPE_BYTE)
-		return false;
+		if (!strcasecmp(key, "Encryption")) {
+			if (var != DBUS_TYPE_BYTE)
+				return false;
 
-	dbus_message_iter_get_basic(&value, &cfg->qos.bcast.encryption);
+			dbus_message_iter_get_basic(&value,
+						&cfg->qos.bcast.encryption);
+		} else if (!strcasecmp(key, "BCode")) {
+			DBusMessageIter array;
+			struct iovec iov = {0};
+
+			if (var != DBUS_TYPE_ARRAY)
+				return false;
+
+			dbus_message_iter_recurse(&value, &array);
+			dbus_message_iter_get_fixed_array(&array,
+							&iov.iov_base,
+							(int *)&iov.iov_len);
+
+			if (iov.iov_len != 16) {
+				bt_shell_printf("Invalid size for BCode: "
+						"%zu != 16\n", iov.iov_len);
+				return false;
+			}
+
+			memcpy(cfg->qos.bcast.bcode, iov.iov_base, iov.iov_len);
+		}
+	}
 
 	return true;
 }
@@ -328,6 +351,7 @@ static bool assistant_get_qos(struct assistant_config *cfg)
 static void assistant_set_metadata_cfg(const char *input, void *user_data)
 {
 	struct assistant_config *cfg = user_data;
+	uint8_t no_bcode[16] = {};
 
 	if (!strcasecmp(input, "a") || !strcasecmp(input, "auto"))
 		goto done;
@@ -346,7 +370,8 @@ done:
 	if (!assistant_get_qos(cfg))
 		goto fail;
 
-	if (cfg->qos.bcast.encryption)
+	if (cfg->qos.bcast.encryption &&
+			!memcmp(cfg->qos.bcast.bcode, no_bcode, 16))
 		/* Prompt user to enter the Broadcast Code to decrypt
 		 * the stream
 		 */
@@ -373,13 +398,15 @@ fail:
 static void assistant_set_device_cfg(const char *input, void *user_data)
 {
 	struct assistant_config *cfg = user_data;
+	uint8_t no_bcode[16] = {};
 
 	cfg->device = strdup(input);
 
 	if (!assistant_get_qos(cfg))
 		goto fail;
 
-	if (cfg->qos.bcast.encryption) {
+	if (cfg->qos.bcast.encryption &&
+			!memcmp(cfg->qos.bcast.bcode, no_bcode, 16)) {
 		/* Prompt user to enter the Broadcast Code to decrypt
 		 * the stream
 		 */
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH BlueZ v2 2/3] shared/bass: Fix permissions not requiring encryption
  2025-10-02 13:40 [PATCH BlueZ v2 1/3] client/assistant: Detect if object already contains a valid BCode Luiz Augusto von Dentz
@ 2025-10-02 13:40 ` Luiz Augusto von Dentz
  2025-10-02 13:40 ` [PATCH BlueZ v2 3/3] client/player: Set QoS.Encryption if QoS.BCode is set Luiz Augusto von Dentz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2025-10-02 13:40 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Both Broadcast Audio Scan Control Point and Broadcast Receive State do
require encryption:

https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/24670-BASS-html5/out/en/index-en.html#UUID-dd95da9a-6ac0-3f45-7e34-13fa9e04d41c
---
 src/shared/bass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/shared/bass.c b/src/shared/bass.c
index 4b4fe8adf762..19cc9531d617 100644
--- a/src/shared/bass.c
+++ b/src/shared/bass.c
@@ -1223,7 +1223,7 @@ static void bcast_recv_new(struct bt_bass_db *bdb, int i)
 	bt_uuid16_create(&uuid, BCAST_RECV_STATE_UUID);
 	bcast_recv_state->attr =
 		gatt_db_service_add_characteristic(bdb->service, &uuid,
-				BT_ATT_PERM_READ,
+				BT_ATT_PERM_READ | BT_ATT_PERM_READ_ENCRYPT,
 				BT_GATT_CHRC_PROP_READ |
 				BT_GATT_CHRC_PROP_NOTIFY,
 				bass_bcast_recv_state_read, NULL,
@@ -1252,7 +1252,7 @@ static void bass_new(struct bt_bass_db *bdb)
 	bdb->bcast_audio_scan_cp =
 		gatt_db_service_add_characteristic(bdb->service,
 				&uuid,
-				BT_ATT_PERM_WRITE,
+				BT_ATT_PERM_WRITE | BT_ATT_PERM_WRITE_ENCRYPT,
 				BT_GATT_CHRC_PROP_WRITE |
 				BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP,
 				NULL, bass_bcast_audio_scan_cp_write,
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH BlueZ v2 3/3] client/player: Set QoS.Encryption if QoS.BCode is set
  2025-10-02 13:40 [PATCH BlueZ v2 1/3] client/assistant: Detect if object already contains a valid BCode Luiz Augusto von Dentz
  2025-10-02 13:40 ` [PATCH BlueZ v2 2/3] shared/bass: Fix permissions not requiring encryption Luiz Augusto von Dentz
@ 2025-10-02 13:40 ` Luiz Augusto von Dentz
  2025-10-02 13:46 ` [BlueZ,v2,1/3] client/assistant: Detect if object already contains a valid BCode bluez.test.bot
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2025-10-02 13:40 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

QoS.Encryption must be set in order for the daemon to interpret the
QoS.BCode as valid.
---
 client/player.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/client/player.c b/client/player.c
index 598ad7f6dfd7..bb193dafeba0 100644
--- a/client/player.c
+++ b/client/player.c
@@ -1870,6 +1870,10 @@ static void append_bcast_qos(DBusMessageIter *iter, struct endpoint_config *cfg)
 
 	if (cfg->ep->bcode->iov_len != 0) {
 		const char *key = "BCode";
+		uint8_t encryption = 0x01;
+
+		g_dbus_dict_append_entry(iter, "Encryption", DBUS_TYPE_BYTE,
+						&encryption);
 
 		bt_shell_printf("BCode:\n");
 		bt_shell_hexdump(cfg->ep->bcode->iov_base,
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [BlueZ,v2,1/3] client/assistant: Detect if object already contains a valid BCode
  2025-10-02 13:40 [PATCH BlueZ v2 1/3] client/assistant: Detect if object already contains a valid BCode Luiz Augusto von Dentz
  2025-10-02 13:40 ` [PATCH BlueZ v2 2/3] shared/bass: Fix permissions not requiring encryption Luiz Augusto von Dentz
  2025-10-02 13:40 ` [PATCH BlueZ v2 3/3] client/player: Set QoS.Encryption if QoS.BCode is set Luiz Augusto von Dentz
@ 2025-10-02 13:46 ` bluez.test.bot
  2025-10-02 16:30 ` [PATCH BlueZ v2 1/3] " patchwork-bot+bluetooth
  2025-10-27 13:50 ` patchwork-bot+bluetooth
  4 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2025-10-02 13:46 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 538 bytes --]

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----

error: patch failed: client/assistant.c:293
error: client/assistant.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch

Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH BlueZ v2 1/3] client/assistant: Detect if object already contains a valid BCode
  2025-10-02 13:40 [PATCH BlueZ v2 1/3] client/assistant: Detect if object already contains a valid BCode Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2025-10-02 13:46 ` [BlueZ,v2,1/3] client/assistant: Detect if object already contains a valid BCode bluez.test.bot
@ 2025-10-02 16:30 ` patchwork-bot+bluetooth
  2025-10-27 13:50 ` patchwork-bot+bluetooth
  4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2025-10-02 16:30 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu,  2 Oct 2025 09:40:41 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> If assistant object already contains a valid (non-zero) BCode
> (e.g state=local) use it instead of always request the user to
> re-enter.
> ---
>  client/assistant.c | 55 ++++++++++++++++++++++++++++++++++------------
>  1 file changed, 41 insertions(+), 14 deletions(-)

Here is the summary with links:
  - [BlueZ,v2,1/3] client/assistant: Detect if object already contains a valid BCode
    (no matching commit)
  - [BlueZ,v2,2/3] shared/bass: Fix permissions not requiring encryption
    (no matching commit)
  - [BlueZ,v2,3/3] client/player: Set QoS.Encryption if QoS.BCode is set
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=3e55476bf6c8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH BlueZ v2 1/3] client/assistant: Detect if object already contains a valid BCode
  2025-10-02 13:40 [PATCH BlueZ v2 1/3] client/assistant: Detect if object already contains a valid BCode Luiz Augusto von Dentz
                   ` (3 preceding siblings ...)
  2025-10-02 16:30 ` [PATCH BlueZ v2 1/3] " patchwork-bot+bluetooth
@ 2025-10-27 13:50 ` patchwork-bot+bluetooth
  4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2025-10-27 13:50 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu,  2 Oct 2025 09:40:41 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> If assistant object already contains a valid (non-zero) BCode
> (e.g state=local) use it instead of always request the user to
> re-enter.
> ---
>  client/assistant.c | 55 ++++++++++++++++++++++++++++++++++------------
>  1 file changed, 41 insertions(+), 14 deletions(-)

Here is the summary with links:
  - [BlueZ,v2,1/3] client/assistant: Detect if object already contains a valid BCode
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fdf49338d97d
  - [BlueZ,v2,2/3] shared/bass: Fix permissions not requiring encryption
    (no matching commit)
  - [BlueZ,v2,3/3] client/player: Set QoS.Encryption if QoS.BCode is set
    (no matching commit)

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-10-27 13:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-02 13:40 [PATCH BlueZ v2 1/3] client/assistant: Detect if object already contains a valid BCode Luiz Augusto von Dentz
2025-10-02 13:40 ` [PATCH BlueZ v2 2/3] shared/bass: Fix permissions not requiring encryption Luiz Augusto von Dentz
2025-10-02 13:40 ` [PATCH BlueZ v2 3/3] client/player: Set QoS.Encryption if QoS.BCode is set Luiz Augusto von Dentz
2025-10-02 13:46 ` [BlueZ,v2,1/3] client/assistant: Detect if object already contains a valid BCode bluez.test.bot
2025-10-02 16:30 ` [PATCH BlueZ v2 1/3] " patchwork-bot+bluetooth
2025-10-27 13:50 ` patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).