Lines Matching refs:hcon
648 struct hci_conn *hcon = conn->hcon; in build_pairing_cmd() local
649 struct hci_dev *hdev = hcon->hdev; in build_pairing_cmd()
676 if (hcon->dst_type == ADDR_LE_DEV_PUBLIC) in build_pairing_cmd()
681 oob_data = hci_find_remote_oob_data(hdev, &hcon->dst, in build_pairing_cmd()
697 req->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
708 rsp->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
736 struct hci_conn *hcon = conn->hcon; in smp_chan_destroy() local
744 mgmt_smp_complete(hcon, complete); in smp_chan_destroy()
757 !hci_dev_test_flag(hcon->hdev, HCI_KEEP_DEBUG_KEYS)) { in smp_chan_destroy()
783 hci_conn_drop(hcon); in smp_chan_destroy()
788 struct hci_conn *hcon = conn->hcon; in smp_failure() local
795 clear_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags); in smp_failure()
796 mgmt_auth_failed(hcon, HCI_ERROR_AUTH_FAILURE); in smp_failure()
844 struct hci_conn *hcon = conn->hcon; in tk_request() local
874 hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in tk_request()
892 if (hcon->pending_sec_level < BT_SECURITY_HIGH) in tk_request()
893 hcon->pending_sec_level = BT_SECURITY_HIGH; in tk_request()
900 if (hcon->role == HCI_ROLE_MASTER) in tk_request()
917 ret = mgmt_user_passkey_request(hcon->hdev, &hcon->dst, in tk_request()
918 hcon->type, hcon->dst_type); in tk_request()
920 ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, in tk_request()
921 hcon->type, hcon->dst_type, in tk_request()
924 ret = mgmt_user_passkey_notify(hcon->hdev, &hcon->dst, in tk_request()
925 hcon->type, hcon->dst_type, in tk_request()
940 conn->hcon->init_addr_type, &conn->hcon->init_addr, in smp_confirm()
941 conn->hcon->resp_addr_type, &conn->hcon->resp_addr, in smp_confirm()
950 if (conn->hcon->out) in smp_confirm()
961 struct hci_conn *hcon = conn->hcon; in smp_random() local
968 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_random()
971 hcon->init_addr_type, &hcon->init_addr, in smp_random()
972 hcon->resp_addr_type, &hcon->resp_addr, confirm); in smp_random()
981 if (hcon->out) { in smp_random()
991 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) in smp_random()
994 hci_le_start_enc(hcon, ediv, rand, stk); in smp_random()
995 hcon->enc_key_size = smp->enc_key_size; in smp_random()
996 set_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); in smp_random()
1010 if (hcon->pending_sec_level == BT_SECURITY_HIGH) in smp_random()
1019 hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in smp_random()
1030 struct hci_conn *hcon = conn->hcon; in smp_notify_keys() local
1031 struct hci_dev *hdev = hcon->hdev; in smp_notify_keys()
1042 if (hcon->type == LE_LINK) { in smp_notify_keys()
1043 bacpy(&hcon->dst, &smp->remote_irk->bdaddr); in smp_notify_keys()
1044 hcon->dst_type = smp->remote_irk->addr_type; in smp_notify_keys()
1065 if (hcon->type == ACL_LINK) { in smp_notify_keys()
1066 if (hcon->key_type == HCI_LK_DEBUG_COMBINATION) in smp_notify_keys()
1070 &hcon->flags); in smp_notify_keys()
1081 smp->csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1082 bacpy(&smp->csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1087 smp->slave_csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1088 bacpy(&smp->slave_csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1093 smp->ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1094 bacpy(&smp->ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1099 smp->slave_ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1100 bacpy(&smp->slave_ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1110 else if (hcon->sec_level == BT_SECURITY_FIPS) in smp_notify_keys()
1115 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst, in smp_notify_keys()
1134 struct hci_conn *hcon = smp->conn->hcon; in sc_add_ltk() local
1142 if (hcon->pending_sec_level == BT_SECURITY_FIPS) in sc_add_ltk()
1150 smp->ltk = hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in sc_add_ltk()
1201 struct hci_conn *hcon = smp->conn->hcon; in sc_generate_ltk() local
1202 struct hci_dev *hdev = hcon->hdev; in sc_generate_ltk()
1205 key = hci_find_link_key(hdev, &hcon->dst); in sc_generate_ltk()
1227 struct hci_conn *hcon = conn->hcon; in smp_distribute_keys() local
1228 struct hci_dev *hdev = hcon->hdev; in smp_distribute_keys()
1236 if (hcon->out && (smp->remote_key_dist & KEY_DIST_MASK)) { in smp_distribute_keys()
1243 if (hcon->out) { in smp_distribute_keys()
1252 if (hcon->type == LE_LINK && (*keydist & SMP_DIST_LINK_KEY)) in smp_distribute_keys()
1254 if (hcon->type == ACL_LINK && (*keydist & SMP_DIST_ENC_KEY)) in smp_distribute_keys()
1277 authenticated = hcon->sec_level == BT_SECURITY_HIGH; in smp_distribute_keys()
1278 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, in smp_distribute_keys()
1305 bacpy(&addrinfo.bdaddr, &hcon->src); in smp_distribute_keys()
1306 addrinfo.addr_type = hcon->src_type; in smp_distribute_keys()
1323 if (hcon->sec_level > BT_SECURITY_MEDIUM) in smp_distribute_keys()
1356 hci_disconnect(conn->hcon, HCI_ERROR_REMOTE_USER_TERM); in smp_timeout()
1390 hci_conn_hold(conn->hcon); in smp_chan_create()
1397 struct hci_conn *hcon = smp->conn->hcon; in sc_mackey_and_ltk() local
1400 if (hcon->out) { in sc_mackey_and_ltk()
1408 memcpy(a, &hcon->init_addr, 6); in sc_mackey_and_ltk()
1409 memcpy(b, &hcon->resp_addr, 6); in sc_mackey_and_ltk()
1410 a[6] = hcon->init_addr_type; in sc_mackey_and_ltk()
1411 b[6] = hcon->resp_addr_type; in sc_mackey_and_ltk()
1418 struct hci_conn *hcon = smp->conn->hcon; in sc_dhkey_check() local
1423 memcpy(a, &hcon->init_addr, 6); in sc_dhkey_check()
1424 memcpy(b, &hcon->resp_addr, 6); in sc_dhkey_check()
1425 a[6] = hcon->init_addr_type; in sc_dhkey_check()
1426 b[6] = hcon->resp_addr_type; in sc_dhkey_check()
1428 if (hcon->out) { in sc_dhkey_check()
1441 put_unaligned_le32(hcon->passkey_notify, r); in sc_dhkey_check()
1455 struct hci_conn *hcon = conn->hcon; in sc_passkey_send_confirm() local
1459 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_send_confirm()
1476 struct hci_conn *hcon = conn->hcon; in sc_passkey_round() local
1477 struct hci_dev *hdev = hcon->hdev; in sc_passkey_round()
1486 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_round()
1507 if (!hcon->out) { in sc_passkey_round()
1535 if (hcon->out) { in sc_passkey_round()
1546 if (!hcon->out) in sc_passkey_round()
1563 struct hci_conn *hcon = conn->hcon; in sc_user_reply() local
1576 hcon->passkey_notify = le32_to_cpu(passkey); in sc_user_reply()
1591 if (hcon->out) { in sc_user_reply()
1602 int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey) in smp_user_confirm_reply() argument
1604 struct l2cap_conn *conn = hcon->l2cap_data; in smp_user_confirm_reply()
1672 struct hci_dev *hdev = conn->hcon->hdev; in build_bredr_pairing_cmd()
1711 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_req()
1721 if (conn->hcon->role != HCI_ROLE_SLAVE) in smp_cmd_pairing_req()
1754 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_req()
1756 if (!test_bit(HCI_CONN_AES_CCM, &conn->hcon->flags) && in smp_cmd_pairing_req()
1784 if (conn->hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_pairing_req()
1789 if (sec_level > conn->hcon->pending_sec_level) in smp_cmd_pairing_req()
1790 conn->hcon->pending_sec_level = sec_level; in smp_cmd_pairing_req()
1793 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_req()
1796 method = get_auth_method(smp, conn->hcon->io_capability, in smp_cmd_pairing_req()
1840 struct hci_dev *hdev = smp->conn->hcon->hdev; in sc_send_public_key()
1897 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_rsp()
1906 if (conn->hcon->role != HCI_ROLE_MASTER) in smp_cmd_pairing_rsp()
1938 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_rsp()
1947 else if (conn->hcon->pending_sec_level > BT_SECURITY_HIGH) in smp_cmd_pairing_rsp()
1948 conn->hcon->pending_sec_level = BT_SECURITY_HIGH; in smp_cmd_pairing_rsp()
1951 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_rsp()
1998 if (conn->hcon->out) { in sc_check_confirm()
2014 struct hci_conn *hcon = conn->hcon; in fixup_sc_false_positive() local
2015 struct hci_dev *hdev = hcon->hdev; in fixup_sc_false_positive()
2020 if (hcon->out) in fixup_sc_false_positive()
2053 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_cmd_pairing_confirm()
2075 if (conn->hcon->out) { in smp_cmd_pairing_confirm()
2094 struct hci_conn *hcon = conn->hcon; in smp_cmd_pairing_random() local
2110 if (hcon->out) { in smp_cmd_pairing_random()
2123 if (!hcon->out) in smp_cmd_pairing_random()
2134 if (hcon->out) { in smp_cmd_pairing_random()
2157 if (hcon->out) { in smp_cmd_pairing_random()
2168 err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type, in smp_cmd_pairing_random()
2169 hcon->dst_type, passkey, 0); in smp_cmd_pairing_random()
2181 struct hci_conn *hcon = conn->hcon; in smp_ltk_encrypt() local
2183 key = hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role); in smp_ltk_encrypt()
2190 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) in smp_ltk_encrypt()
2193 hci_le_start_enc(hcon, key->ediv, key->rand, key->val); in smp_ltk_encrypt()
2194 hcon->enc_key_size = key->enc_size; in smp_ltk_encrypt()
2197 clear_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); in smp_ltk_encrypt()
2202 bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level, in smp_sufficient_security() argument
2215 test_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags) && in smp_sufficient_security()
2216 hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role)) in smp_sufficient_security()
2219 if (hcon->sec_level >= sec_level) in smp_sufficient_security()
2229 struct hci_conn *hcon = conn->hcon; in smp_cmd_security_req() local
2230 struct hci_dev *hdev = hcon->hdev; in smp_cmd_security_req()
2239 if (hcon->role != HCI_ROLE_MASTER) in smp_cmd_security_req()
2247 if (hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_security_req()
2252 if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) in smp_cmd_security_req()
2255 if (sec_level > hcon->pending_sec_level) in smp_cmd_security_req()
2256 hcon->pending_sec_level = sec_level; in smp_cmd_security_req()
2258 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_cmd_security_req()
2283 int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) in smp_conn_security() argument
2285 struct l2cap_conn *conn = hcon->l2cap_data; in smp_conn_security()
2291 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); in smp_conn_security()
2297 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) in smp_conn_security()
2300 if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) in smp_conn_security()
2303 if (sec_level > hcon->pending_sec_level) in smp_conn_security()
2304 hcon->pending_sec_level = sec_level; in smp_conn_security()
2306 if (hcon->role == HCI_ROLE_MASTER) in smp_conn_security()
2307 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_conn_security()
2332 if (hci_dev_test_flag(hcon->hdev, HCI_SC_ENABLED)) in smp_conn_security()
2338 if (hcon->io_capability != HCI_IO_NO_INPUT_OUTPUT || in smp_conn_security()
2339 hcon->pending_sec_level > BT_SECURITY_MEDIUM) in smp_conn_security()
2342 if (hcon->role == HCI_ROLE_MASTER) { in smp_conn_security()
2391 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_master_ident()
2392 struct hci_conn *hcon = conn->hcon; in smp_cmd_master_ident() local
2411 authenticated = (hcon->sec_level == BT_SECURITY_HIGH); in smp_cmd_master_ident()
2412 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, SMP_LTK, in smp_cmd_master_ident()
2448 struct hci_conn *hcon = conn->hcon; in smp_cmd_ident_addr_info() local
2483 if (hci_bdaddr_is_rpa(&hcon->dst, hcon->dst_type)) in smp_cmd_ident_addr_info()
2484 bacpy(&rpa, &hcon->dst); in smp_cmd_ident_addr_info()
2488 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, in smp_cmd_ident_addr_info()
2517 if (conn->hcon->sec_level > BT_SECURITY_MEDIUM) in smp_cmd_sign_info()
2532 struct hci_conn *hcon = conn->hcon; in sc_select_method() local
2545 if (hcon->out) { in sc_select_method()
2577 struct hci_conn *hcon = conn->hcon; in smp_cmd_public_key() local
2580 struct hci_dev *hdev = hcon->hdev; in smp_cmd_public_key()
2604 if (!hcon->out) { in smp_cmd_public_key()
2626 hcon->pending_sec_level = BT_SECURITY_MEDIUM; in smp_cmd_public_key()
2628 hcon->pending_sec_level = BT_SECURITY_FIPS; in smp_cmd_public_key()
2634 get_random_bytes(&hcon->passkey_notify, in smp_cmd_public_key()
2635 sizeof(hcon->passkey_notify)); in smp_cmd_public_key()
2636 hcon->passkey_notify %= 1000000; in smp_cmd_public_key()
2637 hcon->passkey_entered = 0; in smp_cmd_public_key()
2639 if (mgmt_user_passkey_notify(hdev, &hcon->dst, hcon->type, in smp_cmd_public_key()
2640 hcon->dst_type, in smp_cmd_public_key()
2641 hcon->passkey_notify, in smp_cmd_public_key()
2642 hcon->passkey_entered)) in smp_cmd_public_key()
2649 if (hcon->out) in smp_cmd_public_key()
2658 if (hcon->out) in smp_cmd_public_key()
2662 if (mgmt_user_passkey_request(hdev, &hcon->dst, hcon->type, in smp_cmd_public_key()
2663 hcon->dst_type)) in smp_cmd_public_key()
2673 if (conn->hcon->out) in smp_cmd_public_key()
2691 struct hci_conn *hcon = conn->hcon; in smp_cmd_dhkey_check() local
2702 memcpy(a, &hcon->init_addr, 6); in smp_cmd_dhkey_check()
2703 memcpy(b, &hcon->resp_addr, 6); in smp_cmd_dhkey_check()
2704 a[6] = hcon->init_addr_type; in smp_cmd_dhkey_check()
2705 b[6] = hcon->resp_addr_type; in smp_cmd_dhkey_check()
2707 if (hcon->out) { in smp_cmd_dhkey_check()
2720 put_unaligned_le32(hcon->passkey_notify, r); in smp_cmd_dhkey_check()
2732 if (!hcon->out) { in smp_cmd_dhkey_check()
2744 if (hcon->out) { in smp_cmd_dhkey_check()
2745 hci_le_start_enc(hcon, 0, 0, smp->tk); in smp_cmd_dhkey_check()
2746 hcon->enc_key_size = smp->enc_key_size; in smp_cmd_dhkey_check()
2765 struct hci_conn *hcon = conn->hcon; in smp_sig_channel() local
2773 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) { in smp_sig_channel()
2869 BT_ERR("%s unexpected SMP command 0x%02x from %pMR", hcon->hdev->name, in smp_sig_channel()
2870 code, &hcon->dst); in smp_sig_channel()
2891 struct hci_conn *hcon = conn->hcon; in bredr_pairing() local
2892 struct hci_dev *hdev = hcon->hdev; in bredr_pairing()
2899 if (!test_bit(HCI_CONN_NEW_LINK_KEY, &hcon->flags)) in bredr_pairing()
2903 if (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in bredr_pairing()
2907 if (hcon->role != HCI_ROLE_MASTER) in bredr_pairing()
2915 if (!test_bit(HCI_CONN_AES_CCM, &hcon->flags) && in bredr_pairing()
2924 if (!lmp_host_le_capable(hcon)) in bredr_pairing()
2960 struct hci_conn *hcon = conn->hcon; in smp_resume_cb() local
2964 if (hcon->type == ACL_LINK) { in smp_resume_cb()
2972 if (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in smp_resume_cb()
2983 struct hci_conn *hcon = conn->hcon; in smp_ready_cb() local
2990 if (hcon->type == ACL_LINK && test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in smp_ready_cb()
3007 hci_disconnect(chan->conn->hcon, HCI_ERROR_AUTH_FAILURE); in smp_recv_cb()