Bluetooth: BR/EDR: Handle User Passkey Notify event

To allow remote, typically a keyboard, input on its side common
passkey during SSP authentication, enable generated passkey value by
local controller to be notified to user interface if available.

> HCI Event: IO Capability Response (0x32) plen 9
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	IO capability: KeyboardOnly (0x02)
	OOB data: Authentication data not present (0x00)
	Authentication: No Bonding - MITM required (0x01)
> HCI Event: IO Capability Request (0x31) plen 6
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	IO capability: DisplayYesNo (0x01)
	OOB data: Authentication data not present (0x00)
	Authentication: No Bonding - MITM required (0x01)
> HCI Event: Command Complete (0x0e) plen 10
	IO Capability Request Reply (0x01|0x002b) ncmd 1
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: User Passkey Notification (0x3b) plen 10
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Passkey: 831705
> HCI Event: Simple Pairing Complete (0x36) plen 7
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Link Key Notification (0x18) plen 23
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Link key: 1a8d1c80409c4466b3423ca2bb761cf4
	Key type: Authenticated Combination key from P-192 (0x05)
> HCI Event: Encryption Change (0x08) plen 4
	Status: Success (0x00)
	Handle: 11
	Encryption: Enabled with E0 (0x01)

Change-Id: I1e8ad5d75181ceb9c93576b9e9b93975d9cdf35b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
Arkadiusz Lichwa 2016-02-24 14:47:01 +01:00 committed by Johan Hedberg
commit 143a826b1e
3 changed files with 30 additions and 0 deletions

View file

@ -712,6 +712,12 @@ struct bt_hci_evt_ssp_complete {
bt_addr_t bdaddr; bt_addr_t bdaddr;
} __packed; } __packed;
#define BT_HCI_EVT_USER_PASSKEY_NOTIFY 0x3b
struct bt_hci_evt_user_passkey_notify {
bt_addr_t bdaddr;
uint32_t passkey;
} __packed;
#define BT_HCI_EVT_LE_META_EVENT 0x3e #define BT_HCI_EVT_LE_META_EVENT 0x3e
struct bt_hci_evt_le_meta_event { struct bt_hci_evt_le_meta_event {
uint8_t subevent; uint8_t subevent;

View file

@ -877,6 +877,9 @@ void bt_conn_ssp_auth(struct bt_conn *conn, uint32_t passkey)
atomic_set_bit(conn->flags, BT_CONN_USER); atomic_set_bit(conn->flags, BT_CONN_USER);
bt_auth->passkey_confirm(conn, passkey); bt_auth->passkey_confirm(conn, passkey);
break; break;
case PASSKEY_DISPLAY:
bt_auth->passkey_display(conn, passkey);
break;
default: default:
ssp_confirm_reply(conn); ssp_confirm_reply(conn);
break; break;

View file

@ -1245,6 +1245,23 @@ static void user_confirm_req(struct net_buf *buf)
bt_conn_ssp_auth(conn, sys_le32_to_cpu(evt->passkey)); bt_conn_ssp_auth(conn, sys_le32_to_cpu(evt->passkey));
bt_conn_unref(conn); bt_conn_unref(conn);
} }
static void user_passkey_notify(struct net_buf *buf)
{
struct bt_hci_evt_user_passkey_notify *evt = (void *)buf->data;
struct bt_conn *conn;
BT_DBG("");
conn = bt_conn_lookup_addr_br(&evt->bdaddr);
if (!conn) {
BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr));
return;
}
bt_conn_ssp_auth(conn, sys_le32_to_cpu(evt->passkey));
bt_conn_unref(conn);
}
#endif #endif
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
@ -1929,6 +1946,9 @@ static void hci_event(struct net_buf *buf)
case BT_HCI_EVT_USER_CONFIRM_REQ: case BT_HCI_EVT_USER_CONFIRM_REQ:
user_confirm_req(buf); user_confirm_req(buf);
break; break;
case BT_HCI_EVT_USER_PASSKEY_NOTIFY:
user_passkey_notify(buf);
break;
#endif #endif
#if defined(CONFIG_BLUETOOTH_CONN) #if defined(CONFIG_BLUETOOTH_CONN)
case BT_HCI_EVT_DISCONN_COMPLETE: case BT_HCI_EVT_DISCONN_COMPLETE:
@ -2394,6 +2414,7 @@ static int set_event_mask(void)
ev->events[6] |= 0x02; /* IO Capability Response */ ev->events[6] |= 0x02; /* IO Capability Response */
ev->events[6] |= 0x04; /* User Confirmation Request */ ev->events[6] |= 0x04; /* User Confirmation Request */
ev->events[6] |= 0x20; /* Simple Pairing Complete */ ev->events[6] |= 0x20; /* Simple Pairing Complete */
ev->events[7] |= 0x04; /* User Passkey Notification */
#endif #endif
ev->events[1] |= 0x20; /* Command Complete */ ev->events[1] |= 0x20; /* Command Complete */
ev->events[1] |= 0x40; /* Command Status */ ev->events[1] |= 0x40; /* Command Status */