Bluetooth: BR/EDR: Handle User Passkey Entry event
Enables handle request from remote to enter passkey by the user to continue SSP authentication process. It happens when local device supports 'keyboard only' functionality. Otherwise the response is negative. > HCI Event: IO Capability Response (0x32) plen 9 Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd) IO capability: DisplayOnly (0x00) OOB data: Authentication data not present (0x00) Authentication: Dedicated Bonding - MITM required (0x03) > 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: KeyboardOnly (0x02) OOB data: Authentication data not present (0x00) Authentication: Dedicated Bonding - MITM required (0x03) > 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 Request (0x34) plen 6 Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd) < HCI Command: User Passkey Request Reply (0x01|0x002e) plen 10 Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd) Passkey: 599207 > HCI Event: Command Complete (0x0e) plen 10 User Passkey Request Reply (0x01|0x002e) ncmd 1 Status: Success (0x00) Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd) > 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: 560e9c31d700ae5576af83d1e079e911 Key type: Authenticated Combination key from P-192 (0x05) Change-Id: Ia15517519b326eede29bc8e71edb7ec6ca77e010 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
143a826b1e
commit
6f30525278
3 changed files with 87 additions and 0 deletions
|
@ -292,6 +292,17 @@ struct bt_hci_rp_user_confirm_reply {
|
|||
bt_addr_t bdaddr;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_USER_PASSKEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002e)
|
||||
struct bt_hci_cp_user_passkey_reply {
|
||||
bt_addr_t bdaddr;
|
||||
uint32_t passkey;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_USER_PASSKEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002f)
|
||||
struct bt_hci_cp_user_passkey_neg_reply {
|
||||
bt_addr_t bdaddr;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_IO_CAPABILITY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x0034)
|
||||
struct bt_hci_cp_io_capability_neg_reply {
|
||||
bt_addr_t bdaddr;
|
||||
|
@ -706,6 +717,11 @@ struct bt_hci_evt_user_confirm_req {
|
|||
uint32_t passkey;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_EVT_USER_PASSKEY_REQ 0x34
|
||||
struct bt_hci_evt_user_passkey_req {
|
||||
bt_addr_t bdaddr;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_EVT_SSP_COMPLETE 0x36
|
||||
struct bt_hci_evt_ssp_complete {
|
||||
uint8_t status;
|
||||
|
|
|
@ -880,11 +880,52 @@ void bt_conn_ssp_auth(struct bt_conn *conn, uint32_t passkey)
|
|||
case PASSKEY_DISPLAY:
|
||||
bt_auth->passkey_display(conn, passkey);
|
||||
break;
|
||||
case PASSKEY_INPUT:
|
||||
bt_auth->passkey_entry(conn);
|
||||
break;
|
||||
default:
|
||||
ssp_confirm_reply(conn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int ssp_passkey_reply(struct bt_conn *conn, unsigned int passkey)
|
||||
{
|
||||
struct bt_hci_cp_user_passkey_reply *cp;
|
||||
struct net_buf *buf;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_USER_PASSKEY_REPLY, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
bt_addr_copy(&cp->bdaddr, &conn->br.dst);
|
||||
cp->passkey = sys_cpu_to_le32(passkey);
|
||||
|
||||
return bt_hci_cmd_send_sync(BT_HCI_OP_USER_PASSKEY_REPLY, buf, NULL);
|
||||
}
|
||||
|
||||
static int ssp_passkey_neg_reply(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_hci_cp_user_passkey_neg_reply *cp;
|
||||
struct net_buf *buf;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_USER_PASSKEY_NEG_REPLY, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
bt_addr_copy(&cp->bdaddr, &conn->br.dst);
|
||||
|
||||
return bt_hci_cmd_send_sync(BT_HCI_OP_USER_PASSKEY_NEG_REPLY, buf,
|
||||
NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void timeout_fiber(int arg1, int arg2)
|
||||
|
@ -1399,6 +1440,13 @@ int bt_conn_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)
|
|||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_SMP */
|
||||
#if defined(CONFIG_BLUETOOTH_BREDR)
|
||||
if (conn->type == BT_CONN_TYPE_BR) {
|
||||
if (conn->br.ssp_method == PASSKEY_INPUT) {
|
||||
return ssp_passkey_reply(conn, passkey);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_BREDR */
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -1448,6 +1496,10 @@ int bt_conn_auth_cancel(struct bt_conn *conn)
|
|||
return ssp_confirm_neg_reply(conn);
|
||||
}
|
||||
|
||||
if (conn->br.ssp_method == PASSKEY_INPUT) {
|
||||
return ssp_passkey_neg_reply(conn);
|
||||
}
|
||||
|
||||
return pin_code_neg_reply(&conn->br.dst);
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_BREDR */
|
||||
|
|
|
@ -1262,6 +1262,21 @@ static void user_passkey_notify(struct net_buf *buf)
|
|||
bt_conn_ssp_auth(conn, sys_le32_to_cpu(evt->passkey));
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
|
||||
static void user_passkey_req(struct net_buf *buf)
|
||||
{
|
||||
struct bt_hci_evt_user_passkey_req *evt = (void *)buf->data;
|
||||
struct bt_conn *conn;
|
||||
|
||||
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, 0);
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
|
||||
|
@ -1949,6 +1964,9 @@ static void hci_event(struct net_buf *buf)
|
|||
case BT_HCI_EVT_USER_PASSKEY_NOTIFY:
|
||||
user_passkey_notify(buf);
|
||||
break;
|
||||
case BT_HCI_EVT_USER_PASSKEY_REQ:
|
||||
user_passkey_req(buf);
|
||||
break;
|
||||
#endif
|
||||
#if defined(CONFIG_BLUETOOTH_CONN)
|
||||
case BT_HCI_EVT_DISCONN_COMPLETE:
|
||||
|
@ -2413,6 +2431,7 @@ static int set_event_mask(void)
|
|||
ev->events[6] |= 0x01; /* IO Capability Request */
|
||||
ev->events[6] |= 0x02; /* IO Capability Response */
|
||||
ev->events[6] |= 0x04; /* User Confirmation Request */
|
||||
ev->events[6] |= 0x08; /* User Passkey Request */
|
||||
ev->events[6] |= 0x20; /* Simple Pairing Complete */
|
||||
ev->events[7] |= 0x04; /* User Passkey Notification */
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue