Lines Matching refs:hcon
672 struct hci_conn *hcon = conn->hcon; in build_pairing_cmd() local
673 struct hci_dev *hdev = hcon->hdev; in build_pairing_cmd()
700 if (hcon->dst_type == ADDR_LE_DEV_PUBLIC) in build_pairing_cmd()
705 oob_data = hci_find_remote_oob_data(hdev, &hcon->dst, in build_pairing_cmd()
721 req->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
732 rsp->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
745 struct hci_dev *hdev = conn->hcon->hdev; in check_enc_key_size()
761 struct hci_conn *hcon = conn->hcon; in smp_chan_destroy() local
769 mgmt_smp_complete(hcon, complete); in smp_chan_destroy()
783 !hci_dev_test_flag(hcon->hdev, HCI_KEEP_DEBUG_KEYS)) { in smp_chan_destroy()
809 hci_conn_drop(hcon); in smp_chan_destroy()
814 struct hci_conn *hcon = conn->hcon; in smp_failure() local
821 mgmt_auth_failed(hcon, HCI_ERROR_AUTH_FAILURE); in smp_failure()
869 struct hci_conn *hcon = conn->hcon; in tk_request() local
899 hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in tk_request()
917 if (hcon->pending_sec_level < BT_SECURITY_HIGH) in tk_request()
918 hcon->pending_sec_level = BT_SECURITY_HIGH; in tk_request()
925 if (hcon->role == HCI_ROLE_MASTER) in tk_request()
942 ret = mgmt_user_passkey_request(hcon->hdev, &hcon->dst, in tk_request()
943 hcon->type, hcon->dst_type); in tk_request()
945 ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, in tk_request()
946 hcon->type, hcon->dst_type, in tk_request()
949 ret = mgmt_user_passkey_notify(hcon->hdev, &hcon->dst, in tk_request()
950 hcon->type, hcon->dst_type, in tk_request()
965 conn->hcon->init_addr_type, &conn->hcon->init_addr, in smp_confirm()
966 conn->hcon->resp_addr_type, &conn->hcon->resp_addr, in smp_confirm()
975 if (conn->hcon->out) in smp_confirm()
986 struct hci_conn *hcon = conn->hcon; in smp_random() local
993 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_random()
996 hcon->init_addr_type, &hcon->init_addr, in smp_random()
997 hcon->resp_addr_type, &hcon->resp_addr, confirm); in smp_random()
1002 bt_dev_err(hcon->hdev, "pairing failed " in smp_random()
1007 if (hcon->out) { in smp_random()
1014 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) in smp_random()
1017 hci_le_start_enc(hcon, ediv, rand, stk, smp->enc_key_size); in smp_random()
1018 hcon->enc_key_size = smp->enc_key_size; in smp_random()
1019 set_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); in smp_random()
1030 if (hcon->pending_sec_level == BT_SECURITY_HIGH) in smp_random()
1039 hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in smp_random()
1050 struct hci_conn *hcon = conn->hcon; in smp_notify_keys() local
1051 struct hci_dev *hdev = hcon->hdev; in smp_notify_keys()
1056 if (hcon->type == ACL_LINK) { in smp_notify_keys()
1057 if (hcon->key_type == HCI_LK_DEBUG_COMBINATION) in smp_notify_keys()
1061 &hcon->flags); in smp_notify_keys()
1078 if (hcon->type == LE_LINK) { in smp_notify_keys()
1079 bacpy(&hcon->dst, &smp->remote_irk->bdaddr); in smp_notify_keys()
1080 hcon->dst_type = smp->remote_irk->addr_type; in smp_notify_keys()
1086 smp->csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1087 bacpy(&smp->csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1092 smp->slave_csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1093 bacpy(&smp->slave_csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1098 smp->ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1099 bacpy(&smp->ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1104 smp->slave_ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1105 bacpy(&smp->slave_ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1115 else if (hcon->sec_level == BT_SECURITY_FIPS) in smp_notify_keys()
1120 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst, in smp_notify_keys()
1139 struct hci_conn *hcon = smp->conn->hcon; in sc_add_ltk() local
1147 if (hcon->pending_sec_level == BT_SECURITY_FIPS) in sc_add_ltk()
1152 smp->ltk = hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in sc_add_ltk()
1211 struct hci_conn *hcon = smp->conn->hcon; in sc_generate_ltk() local
1212 struct hci_dev *hdev = hcon->hdev; in sc_generate_ltk()
1215 key = hci_find_link_key(hdev, &hcon->dst); in sc_generate_ltk()
1248 struct hci_conn *hcon = conn->hcon; in smp_distribute_keys() local
1249 struct hci_dev *hdev = hcon->hdev; in smp_distribute_keys()
1257 if (hcon->out && (smp->remote_key_dist & KEY_DIST_MASK)) { in smp_distribute_keys()
1264 if (hcon->out) { in smp_distribute_keys()
1273 if (hcon->type == LE_LINK && (*keydist & SMP_DIST_LINK_KEY)) in smp_distribute_keys()
1275 if (hcon->type == ACL_LINK && (*keydist & SMP_DIST_ENC_KEY)) in smp_distribute_keys()
1305 authenticated = hcon->sec_level == BT_SECURITY_HIGH; in smp_distribute_keys()
1306 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, in smp_distribute_keys()
1333 bacpy(&addrinfo.bdaddr, &hcon->src); in smp_distribute_keys()
1334 addrinfo.addr_type = hcon->src_type; in smp_distribute_keys()
1351 if (hcon->sec_level > BT_SECURITY_MEDIUM) in smp_distribute_keys()
1384 hci_disconnect(conn->hcon, HCI_ERROR_REMOTE_USER_TERM); in smp_timeout()
1421 hci_conn_hold(conn->hcon); in smp_chan_create()
1436 struct hci_conn *hcon = smp->conn->hcon; in sc_mackey_and_ltk() local
1439 if (hcon->out) { in sc_mackey_and_ltk()
1447 memcpy(a, &hcon->init_addr, 6); in sc_mackey_and_ltk()
1448 memcpy(b, &hcon->resp_addr, 6); in sc_mackey_and_ltk()
1449 a[6] = hcon->init_addr_type; in sc_mackey_and_ltk()
1450 b[6] = hcon->resp_addr_type; in sc_mackey_and_ltk()
1457 struct hci_conn *hcon = smp->conn->hcon; in sc_dhkey_check() local
1462 memcpy(a, &hcon->init_addr, 6); in sc_dhkey_check()
1463 memcpy(b, &hcon->resp_addr, 6); in sc_dhkey_check()
1464 a[6] = hcon->init_addr_type; in sc_dhkey_check()
1465 b[6] = hcon->resp_addr_type; in sc_dhkey_check()
1467 if (hcon->out) { in sc_dhkey_check()
1480 put_unaligned_le32(hcon->passkey_notify, r); in sc_dhkey_check()
1494 struct hci_conn *hcon = conn->hcon; in sc_passkey_send_confirm() local
1498 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_send_confirm()
1515 struct hci_conn *hcon = conn->hcon; in sc_passkey_round() local
1516 struct hci_dev *hdev = hcon->hdev; in sc_passkey_round()
1525 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_round()
1546 if (!hcon->out) { in sc_passkey_round()
1574 if (hcon->out) { in sc_passkey_round()
1585 if (!hcon->out) in sc_passkey_round()
1602 struct hci_conn *hcon = conn->hcon; in sc_user_reply() local
1615 hcon->passkey_notify = le32_to_cpu(passkey); in sc_user_reply()
1630 if (hcon->out) { in sc_user_reply()
1641 int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey) in smp_user_confirm_reply() argument
1643 struct l2cap_conn *conn = hcon->l2cap_data; in smp_user_confirm_reply()
1711 struct hci_dev *hdev = conn->hcon->hdev; in build_bredr_pairing_cmd()
1731 req->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1741 rsp->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1752 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_req()
1762 if (conn->hcon->role != HCI_ROLE_SLAVE) in smp_cmd_pairing_req()
1795 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_req()
1797 if (!test_bit(HCI_CONN_AES_CCM, &conn->hcon->flags) && in smp_cmd_pairing_req()
1832 if (conn->hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_pairing_req()
1837 if (sec_level > conn->hcon->pending_sec_level) in smp_cmd_pairing_req()
1838 conn->hcon->pending_sec_level = sec_level; in smp_cmd_pairing_req()
1841 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_req()
1844 method = get_auth_method(smp, conn->hcon->io_capability, in smp_cmd_pairing_req()
1888 struct hci_dev *hdev = smp->conn->hcon->hdev; in sc_send_public_key()
1944 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_rsp()
1953 if (conn->hcon->role != HCI_ROLE_MASTER) in smp_cmd_pairing_rsp()
1988 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_rsp()
1997 else if (conn->hcon->pending_sec_level > BT_SECURITY_HIGH) in smp_cmd_pairing_rsp()
1998 conn->hcon->pending_sec_level = BT_SECURITY_HIGH; in smp_cmd_pairing_rsp()
2001 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_rsp()
2048 if (conn->hcon->out) { in sc_check_confirm()
2064 struct hci_conn *hcon = conn->hcon; in fixup_sc_false_positive() local
2065 struct hci_dev *hdev = hcon->hdev; in fixup_sc_false_positive()
2070 if (hcon->out) in fixup_sc_false_positive()
2103 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_cmd_pairing_confirm()
2125 if (conn->hcon->out) { in smp_cmd_pairing_confirm()
2144 struct hci_conn *hcon = conn->hcon; in smp_cmd_pairing_random() local
2160 if (hcon->out) { in smp_cmd_pairing_random()
2173 if (!hcon->out) in smp_cmd_pairing_random()
2184 if (hcon->out) { in smp_cmd_pairing_random()
2207 if (hcon->out) { in smp_cmd_pairing_random()
2218 err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type, in smp_cmd_pairing_random()
2219 hcon->dst_type, passkey, 0); in smp_cmd_pairing_random()
2231 struct hci_conn *hcon = conn->hcon; in smp_ltk_encrypt() local
2233 key = hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role); in smp_ltk_encrypt()
2240 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) in smp_ltk_encrypt()
2243 hci_le_start_enc(hcon, key->ediv, key->rand, key->val, key->enc_size); in smp_ltk_encrypt()
2244 hcon->enc_key_size = key->enc_size; in smp_ltk_encrypt()
2247 clear_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); in smp_ltk_encrypt()
2252 bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level, in smp_sufficient_security() argument
2265 test_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags) && in smp_sufficient_security()
2266 hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role)) in smp_sufficient_security()
2269 if (hcon->sec_level >= sec_level) in smp_sufficient_security()
2279 struct hci_conn *hcon = conn->hcon; in smp_cmd_security_req() local
2280 struct hci_dev *hdev = hcon->hdev; in smp_cmd_security_req()
2289 if (hcon->role != HCI_ROLE_MASTER) in smp_cmd_security_req()
2297 if (hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_security_req()
2302 if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) { in smp_cmd_security_req()
2307 smp_ltk_encrypt(conn, hcon->sec_level); in smp_cmd_security_req()
2311 if (sec_level > hcon->pending_sec_level) in smp_cmd_security_req()
2312 hcon->pending_sec_level = sec_level; in smp_cmd_security_req()
2314 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_cmd_security_req()
2339 int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) in smp_conn_security() argument
2341 struct l2cap_conn *conn = hcon->l2cap_data; in smp_conn_security()
2347 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); in smp_conn_security()
2353 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) in smp_conn_security()
2356 if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) in smp_conn_security()
2359 if (sec_level > hcon->pending_sec_level) in smp_conn_security()
2360 hcon->pending_sec_level = sec_level; in smp_conn_security()
2362 if (hcon->role == HCI_ROLE_MASTER) in smp_conn_security()
2363 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_conn_security()
2368 bt_dev_err(hcon->hdev, "security requested but not available"); in smp_conn_security()
2388 if (hci_dev_test_flag(hcon->hdev, HCI_SC_ENABLED)) { in smp_conn_security()
2390 if (hci_dev_test_flag(hcon->hdev, HCI_SSP_ENABLED)) in smp_conn_security()
2397 if (hcon->io_capability != HCI_IO_NO_INPUT_OUTPUT || in smp_conn_security()
2398 hcon->pending_sec_level > BT_SECURITY_MEDIUM) in smp_conn_security()
2401 if (hcon->role == HCI_ROLE_MASTER) { in smp_conn_security()
2428 struct hci_conn *hcon; in smp_cancel_and_remove_pairing() local
2437 hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type); in smp_cancel_and_remove_pairing()
2438 if (!hcon) in smp_cancel_and_remove_pairing()
2441 conn = hcon->l2cap_data; in smp_cancel_and_remove_pairing()
2497 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_master_ident()
2498 struct hci_conn *hcon = conn->hcon; in smp_cmd_master_ident() local
2517 authenticated = (hcon->sec_level == BT_SECURITY_HIGH); in smp_cmd_master_ident()
2518 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, SMP_LTK, in smp_cmd_master_ident()
2554 struct hci_conn *hcon = conn->hcon; in smp_cmd_ident_addr_info() local
2582 bt_dev_err(hcon->hdev, "ignoring IRK with no identity address"); in smp_cmd_ident_addr_info()
2589 if (hci_bdaddr_is_rpa(&hcon->dst, hcon->dst_type)) in smp_cmd_ident_addr_info()
2590 bacpy(&rpa, &hcon->dst); in smp_cmd_ident_addr_info()
2594 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, in smp_cmd_ident_addr_info()
2623 if (conn->hcon->sec_level > BT_SECURITY_MEDIUM) in smp_cmd_sign_info()
2638 struct hci_conn *hcon = conn->hcon; in sc_select_method() local
2651 if (hcon->out) { in sc_select_method()
2683 struct hci_conn *hcon = conn->hcon; in smp_cmd_public_key() local
2686 struct hci_dev *hdev = hcon->hdev; in smp_cmd_public_key()
2711 if (!hcon->out) { in smp_cmd_public_key()
2750 hcon->pending_sec_level = BT_SECURITY_MEDIUM; in smp_cmd_public_key()
2752 hcon->pending_sec_level = BT_SECURITY_FIPS; in smp_cmd_public_key()
2758 get_random_bytes(&hcon->passkey_notify, in smp_cmd_public_key()
2759 sizeof(hcon->passkey_notify)); in smp_cmd_public_key()
2760 hcon->passkey_notify %= 1000000; in smp_cmd_public_key()
2761 hcon->passkey_entered = 0; in smp_cmd_public_key()
2763 if (mgmt_user_passkey_notify(hdev, &hcon->dst, hcon->type, in smp_cmd_public_key()
2764 hcon->dst_type, in smp_cmd_public_key()
2765 hcon->passkey_notify, in smp_cmd_public_key()
2766 hcon->passkey_entered)) in smp_cmd_public_key()
2773 if (hcon->out) in smp_cmd_public_key()
2782 if (hcon->out) in smp_cmd_public_key()
2786 if (mgmt_user_passkey_request(hdev, &hcon->dst, hcon->type, in smp_cmd_public_key()
2787 hcon->dst_type)) in smp_cmd_public_key()
2797 if (conn->hcon->out) in smp_cmd_public_key()
2815 struct hci_conn *hcon = conn->hcon; in smp_cmd_dhkey_check() local
2826 memcpy(a, &hcon->init_addr, 6); in smp_cmd_dhkey_check()
2827 memcpy(b, &hcon->resp_addr, 6); in smp_cmd_dhkey_check()
2828 a[6] = hcon->init_addr_type; in smp_cmd_dhkey_check()
2829 b[6] = hcon->resp_addr_type; in smp_cmd_dhkey_check()
2831 if (hcon->out) { in smp_cmd_dhkey_check()
2844 put_unaligned_le32(hcon->passkey_notify, r); in smp_cmd_dhkey_check()
2856 if (!hcon->out) { in smp_cmd_dhkey_check()
2868 if (hcon->out) { in smp_cmd_dhkey_check()
2869 hci_le_start_enc(hcon, 0, 0, smp->tk, smp->enc_key_size); in smp_cmd_dhkey_check()
2870 hcon->enc_key_size = smp->enc_key_size; in smp_cmd_dhkey_check()
2889 struct hci_conn *hcon = conn->hcon; in smp_sig_channel() local
2897 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) { in smp_sig_channel()
2993 bt_dev_err(hcon->hdev, "unexpected SMP command 0x%02x from %pMR", in smp_sig_channel()
2994 code, &hcon->dst); in smp_sig_channel()
3015 struct hci_conn *hcon = conn->hcon; in bredr_pairing() local
3016 struct hci_dev *hdev = hcon->hdev; in bredr_pairing()
3023 if (!test_bit(HCI_CONN_NEW_LINK_KEY, &hcon->flags)) in bredr_pairing()
3027 if (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in bredr_pairing()
3031 if (hcon->role != HCI_ROLE_MASTER) in bredr_pairing()
3039 if (!test_bit(HCI_CONN_AES_CCM, &hcon->flags) && in bredr_pairing()
3048 if (!lmp_host_le_capable(hcon)) in bredr_pairing()
3083 struct hci_conn *hcon = conn->hcon; in smp_resume_cb() local
3087 if (hcon->type == ACL_LINK) { in smp_resume_cb()
3095 if (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in smp_resume_cb()
3106 struct hci_conn *hcon = conn->hcon; in smp_ready_cb() local
3118 if (hcon->type == ACL_LINK && test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in smp_ready_cb()
3135 hci_disconnect(chan->conn->hcon, HCI_ERROR_AUTH_FAILURE); in smp_recv_cb()