From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 2/5] emulator/btdev: Add btdev_set_link_key_type
Date: Fri, 20 Nov 2026 10:47:47 -0500 [thread overview]
Message-ID: <20261120154750.1745643-3-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20261120154750.1745643-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add btdev_set_link_key_type() to set the key type reported in Link Key
Notification no matter the type of the key pairing results in, so
testers can emulate pairing completing with a key that doesn't meet
the security level required.
Assisted-by: OpenCode:claude-fable-5.2
---
emulator/btdev.c | 13 ++++++++++++-
emulator/btdev.h | 5 +++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/emulator/btdev.c b/emulator/btdev.c
index 1140acd90e7d..7c630718013d 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -214,6 +214,8 @@ struct btdev {
uint8_t pin_len;
uint8_t io_cap;
uint8_t auth_req;
+ bool link_key_type_set;
+ uint8_t link_key_type;
bool ssp_auth_complete;
uint8_t ssp_status;
@@ -1906,7 +1908,10 @@ static void link_key_notify(struct btdev *btdev, const uint8_t *bdaddr,
memcpy(ev.bdaddr, bdaddr, 6);
memcpy(ev.link_key, key, 16);
- ev.key_type = get_link_key_type(btdev, bdaddr);
+ if (btdev->link_key_type_set)
+ ev.key_type = btdev->link_key_type;
+ else
+ ev.key_type = get_link_key_type(btdev, bdaddr);
send_event(btdev, BT_HCI_EVT_LINK_KEY_NOTIFY, &ev, sizeof(ev));
}
@@ -9458,6 +9463,12 @@ void btdev_get_mtu(struct btdev *btdev, uint16_t *acl, uint16_t *sco,
*iso = btdev->iso_mtu;
}
+void btdev_set_link_key_type(struct btdev *btdev, uint8_t type)
+{
+ btdev->link_key_type_set = true;
+ btdev->link_key_type = type;
+}
+
void btdev_set_le_states(struct btdev *btdev, const uint8_t *le_states)
{
memcpy(btdev->le_states, le_states, sizeof(btdev->le_states));
diff --git a/emulator/btdev.h b/emulator/btdev.h
index 097021c01cc5..517c65a19cf0 100644
--- a/emulator/btdev.h
+++ b/emulator/btdev.h
@@ -90,6 +90,11 @@ const uint8_t *btdev_get_adv_addr(struct btdev *btdev, uint8_t handle);
void btdev_get_mtu(struct btdev *btdev, uint16_t *acl, uint16_t *sco,
uint16_t *iso);
+/* Report the given type in Link Key Notification, whichever is the type of
+ * the key that pairing results in.
+ */
+void btdev_set_link_key_type(struct btdev *btdev, uint8_t type);
+
void btdev_set_le_states(struct btdev *btdev, const uint8_t *le_states);
void btdev_set_al_len(struct btdev *btdev, uint8_t len);
--
2.56.0
next prev parent reply other threads:[~2026-11-20 15:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 15:47 [PATCH BlueZ v2 0/5] Add tests for security of deferred setup Luiz Augusto von Dentz
2026-11-20 15:47 ` [PATCH BlueZ v2 1/5] emulator/bthost: Add helpers to test " Luiz Augusto von Dentz
2026-11-20 15:47 ` Luiz Augusto von Dentz [this message]
2026-11-20 15:47 ` [PATCH BlueZ v2 3/5] l2cap-tester: Add tests for " Luiz Augusto von Dentz
2026-11-20 15:47 ` [PATCH BlueZ v2 4/5] rfcomm-tester: Add tests for " Luiz Augusto von Dentz
2026-11-20 15:47 ` [PATCH BlueZ v2 5/5] l2cap-tester: Set IO capability in Client SSP - Success 2 Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120154750.1745643-3-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox