Lines Matching refs:hcon

666 	struct hci_conn *hcon = conn->hcon;  in build_pairing_cmd()  local
667 struct hci_dev *hdev = hcon->hdev; in build_pairing_cmd()
694 if (hcon->dst_type == ADDR_LE_DEV_PUBLIC) in build_pairing_cmd()
699 oob_data = hci_find_remote_oob_data(hdev, &hcon->dst, in build_pairing_cmd()
715 req->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
726 rsp->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
739 struct hci_dev *hdev = conn->hcon->hdev; in check_enc_key_size()
755 struct hci_conn *hcon = conn->hcon; in smp_chan_destroy() local
763 mgmt_smp_complete(hcon, complete); in smp_chan_destroy()
776 !hci_dev_test_flag(hcon->hdev, HCI_KEEP_DEBUG_KEYS)) { in smp_chan_destroy()
802 hci_conn_drop(hcon); in smp_chan_destroy()
807 struct hci_conn *hcon = conn->hcon; in smp_failure() local
814 mgmt_auth_failed(hcon, HCI_ERROR_AUTH_FAILURE); in smp_failure()
862 struct hci_conn *hcon = conn->hcon; in tk_request() local
892 hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in tk_request()
910 if (hcon->pending_sec_level < BT_SECURITY_HIGH) in tk_request()
911 hcon->pending_sec_level = BT_SECURITY_HIGH; in tk_request()
918 if (hcon->role == HCI_ROLE_MASTER) in tk_request()
935 ret = mgmt_user_passkey_request(hcon->hdev, &hcon->dst, in tk_request()
936 hcon->type, hcon->dst_type); in tk_request()
938 ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, in tk_request()
939 hcon->type, hcon->dst_type, in tk_request()
942 ret = mgmt_user_passkey_notify(hcon->hdev, &hcon->dst, in tk_request()
943 hcon->type, hcon->dst_type, in tk_request()
958 conn->hcon->init_addr_type, &conn->hcon->init_addr, in smp_confirm()
959 conn->hcon->resp_addr_type, &conn->hcon->resp_addr, in smp_confirm()
968 if (conn->hcon->out) in smp_confirm()
979 struct hci_conn *hcon = conn->hcon; in smp_random() local
986 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_random()
989 hcon->init_addr_type, &hcon->init_addr, in smp_random()
990 hcon->resp_addr_type, &hcon->resp_addr, confirm); in smp_random()
999 if (hcon->out) { in smp_random()
1006 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) in smp_random()
1009 hci_le_start_enc(hcon, ediv, rand, stk, smp->enc_key_size); in smp_random()
1010 hcon->enc_key_size = smp->enc_key_size; in smp_random()
1011 set_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); in smp_random()
1022 if (hcon->pending_sec_level == BT_SECURITY_HIGH) in smp_random()
1031 hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in smp_random()
1042 struct hci_conn *hcon = conn->hcon; in smp_notify_keys() local
1043 struct hci_dev *hdev = hcon->hdev; in smp_notify_keys()
1048 if (hcon->type == ACL_LINK) { in smp_notify_keys()
1049 if (hcon->key_type == HCI_LK_DEBUG_COMBINATION) in smp_notify_keys()
1053 &hcon->flags); in smp_notify_keys()
1070 if (hcon->type == LE_LINK) { in smp_notify_keys()
1071 bacpy(&hcon->dst, &smp->remote_irk->bdaddr); in smp_notify_keys()
1072 hcon->dst_type = smp->remote_irk->addr_type; in smp_notify_keys()
1078 smp->csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1079 bacpy(&smp->csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1084 smp->slave_csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1085 bacpy(&smp->slave_csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1090 smp->ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1091 bacpy(&smp->ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1096 smp->slave_ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1097 bacpy(&smp->slave_ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1107 else if (hcon->sec_level == BT_SECURITY_FIPS) in smp_notify_keys()
1112 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst, in smp_notify_keys()
1131 struct hci_conn *hcon = smp->conn->hcon; in sc_add_ltk() local
1139 if (hcon->pending_sec_level == BT_SECURITY_FIPS) in sc_add_ltk()
1144 smp->ltk = hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in sc_add_ltk()
1195 struct hci_conn *hcon = smp->conn->hcon; in sc_generate_ltk() local
1196 struct hci_dev *hdev = hcon->hdev; in sc_generate_ltk()
1199 key = hci_find_link_key(hdev, &hcon->dst); in sc_generate_ltk()
1221 struct hci_conn *hcon = conn->hcon; in smp_distribute_keys() local
1222 struct hci_dev *hdev = hcon->hdev; in smp_distribute_keys()
1230 if (hcon->out && (smp->remote_key_dist & KEY_DIST_MASK)) { in smp_distribute_keys()
1237 if (hcon->out) { in smp_distribute_keys()
1246 if (hcon->type == LE_LINK && (*keydist & SMP_DIST_LINK_KEY)) in smp_distribute_keys()
1248 if (hcon->type == ACL_LINK && (*keydist & SMP_DIST_ENC_KEY)) in smp_distribute_keys()
1278 authenticated = hcon->sec_level == BT_SECURITY_HIGH; in smp_distribute_keys()
1279 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, in smp_distribute_keys()
1306 bacpy(&addrinfo.bdaddr, &hcon->src); in smp_distribute_keys()
1307 addrinfo.addr_type = hcon->src_type; in smp_distribute_keys()
1324 if (hcon->sec_level > BT_SECURITY_MEDIUM) in smp_distribute_keys()
1357 hci_disconnect(conn->hcon, HCI_ERROR_REMOTE_USER_TERM); in smp_timeout()
1391 hci_conn_hold(conn->hcon); in smp_chan_create()
1398 struct hci_conn *hcon = smp->conn->hcon; in sc_mackey_and_ltk() local
1401 if (hcon->out) { in sc_mackey_and_ltk()
1409 memcpy(a, &hcon->init_addr, 6); in sc_mackey_and_ltk()
1410 memcpy(b, &hcon->resp_addr, 6); in sc_mackey_and_ltk()
1411 a[6] = hcon->init_addr_type; in sc_mackey_and_ltk()
1412 b[6] = hcon->resp_addr_type; in sc_mackey_and_ltk()
1419 struct hci_conn *hcon = smp->conn->hcon; in sc_dhkey_check() local
1424 memcpy(a, &hcon->init_addr, 6); in sc_dhkey_check()
1425 memcpy(b, &hcon->resp_addr, 6); in sc_dhkey_check()
1426 a[6] = hcon->init_addr_type; in sc_dhkey_check()
1427 b[6] = hcon->resp_addr_type; in sc_dhkey_check()
1429 if (hcon->out) { in sc_dhkey_check()
1442 put_unaligned_le32(hcon->passkey_notify, r); in sc_dhkey_check()
1456 struct hci_conn *hcon = conn->hcon; in sc_passkey_send_confirm() local
1460 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_send_confirm()
1477 struct hci_conn *hcon = conn->hcon; in sc_passkey_round() local
1478 struct hci_dev *hdev = hcon->hdev; in sc_passkey_round()
1487 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_round()
1508 if (!hcon->out) { in sc_passkey_round()
1536 if (hcon->out) { in sc_passkey_round()
1547 if (!hcon->out) in sc_passkey_round()
1564 struct hci_conn *hcon = conn->hcon; in sc_user_reply() local
1577 hcon->passkey_notify = le32_to_cpu(passkey); in sc_user_reply()
1592 if (hcon->out) { in sc_user_reply()
1603 int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey) in smp_user_confirm_reply() argument
1605 struct l2cap_conn *conn = hcon->l2cap_data; in smp_user_confirm_reply()
1673 struct hci_dev *hdev = conn->hcon->hdev; in build_bredr_pairing_cmd()
1692 req->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1701 rsp->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1712 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_req()
1722 if (conn->hcon->role != HCI_ROLE_SLAVE) in smp_cmd_pairing_req()
1755 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_req()
1757 if (!test_bit(HCI_CONN_AES_CCM, &conn->hcon->flags) && in smp_cmd_pairing_req()
1785 if (conn->hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_pairing_req()
1790 if (sec_level > conn->hcon->pending_sec_level) in smp_cmd_pairing_req()
1791 conn->hcon->pending_sec_level = sec_level; in smp_cmd_pairing_req()
1794 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_req()
1797 method = get_auth_method(smp, conn->hcon->io_capability, in smp_cmd_pairing_req()
1841 struct hci_dev *hdev = smp->conn->hcon->hdev; in sc_send_public_key()
1898 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_rsp()
1907 if (conn->hcon->role != HCI_ROLE_MASTER) in smp_cmd_pairing_rsp()
1939 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_rsp()
1948 else if (conn->hcon->pending_sec_level > BT_SECURITY_HIGH) in smp_cmd_pairing_rsp()
1949 conn->hcon->pending_sec_level = BT_SECURITY_HIGH; in smp_cmd_pairing_rsp()
1952 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_rsp()
1999 if (conn->hcon->out) { in sc_check_confirm()
2015 struct hci_conn *hcon = conn->hcon; in fixup_sc_false_positive() local
2016 struct hci_dev *hdev = hcon->hdev; in fixup_sc_false_positive()
2021 if (hcon->out) in fixup_sc_false_positive()
2054 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_cmd_pairing_confirm()
2076 if (conn->hcon->out) { in smp_cmd_pairing_confirm()
2095 struct hci_conn *hcon = conn->hcon; in smp_cmd_pairing_random() local
2111 if (hcon->out) { in smp_cmd_pairing_random()
2124 if (!hcon->out) in smp_cmd_pairing_random()
2135 if (hcon->out) { in smp_cmd_pairing_random()
2158 if (hcon->out) { in smp_cmd_pairing_random()
2169 err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type, in smp_cmd_pairing_random()
2170 hcon->dst_type, passkey, 0); in smp_cmd_pairing_random()
2182 struct hci_conn *hcon = conn->hcon; in smp_ltk_encrypt() local
2184 key = hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role); in smp_ltk_encrypt()
2191 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) in smp_ltk_encrypt()
2194 hci_le_start_enc(hcon, key->ediv, key->rand, key->val, key->enc_size); in smp_ltk_encrypt()
2195 hcon->enc_key_size = key->enc_size; in smp_ltk_encrypt()
2198 clear_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); in smp_ltk_encrypt()
2203 bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level, in smp_sufficient_security() argument
2216 test_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags) && in smp_sufficient_security()
2217 hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role)) in smp_sufficient_security()
2220 if (hcon->sec_level >= sec_level) in smp_sufficient_security()
2230 struct hci_conn *hcon = conn->hcon; in smp_cmd_security_req() local
2231 struct hci_dev *hdev = hcon->hdev; in smp_cmd_security_req()
2240 if (hcon->role != HCI_ROLE_MASTER) in smp_cmd_security_req()
2248 if (hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_security_req()
2253 if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) in smp_cmd_security_req()
2256 if (sec_level > hcon->pending_sec_level) in smp_cmd_security_req()
2257 hcon->pending_sec_level = sec_level; in smp_cmd_security_req()
2259 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_cmd_security_req()
2284 int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) in smp_conn_security() argument
2286 struct l2cap_conn *conn = hcon->l2cap_data; in smp_conn_security()
2292 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); in smp_conn_security()
2298 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) in smp_conn_security()
2301 if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) in smp_conn_security()
2304 if (sec_level > hcon->pending_sec_level) in smp_conn_security()
2305 hcon->pending_sec_level = sec_level; in smp_conn_security()
2307 if (hcon->role == HCI_ROLE_MASTER) in smp_conn_security()
2308 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_conn_security()
2333 if (hci_dev_test_flag(hcon->hdev, HCI_SC_ENABLED)) in smp_conn_security()
2339 if (hcon->io_capability != HCI_IO_NO_INPUT_OUTPUT || in smp_conn_security()
2340 hcon->pending_sec_level > BT_SECURITY_MEDIUM) in smp_conn_security()
2343 if (hcon->role == HCI_ROLE_MASTER) { in smp_conn_security()
2367 void smp_cancel_pairing(struct hci_conn *hcon) in smp_cancel_pairing() argument
2369 struct l2cap_conn *conn = hcon->l2cap_data; in smp_cancel_pairing()
2418 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_master_ident()
2419 struct hci_conn *hcon = conn->hcon; in smp_cmd_master_ident() local
2438 authenticated = (hcon->sec_level == BT_SECURITY_HIGH); in smp_cmd_master_ident()
2439 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, SMP_LTK, in smp_cmd_master_ident()
2475 struct hci_conn *hcon = conn->hcon; in smp_cmd_ident_addr_info() local
2510 if (hci_bdaddr_is_rpa(&hcon->dst, hcon->dst_type)) in smp_cmd_ident_addr_info()
2511 bacpy(&rpa, &hcon->dst); in smp_cmd_ident_addr_info()
2515 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, in smp_cmd_ident_addr_info()
2544 if (conn->hcon->sec_level > BT_SECURITY_MEDIUM) in smp_cmd_sign_info()
2559 struct hci_conn *hcon = conn->hcon; in sc_select_method() local
2572 if (hcon->out) { in sc_select_method()
2604 struct hci_conn *hcon = conn->hcon; in smp_cmd_public_key() local
2607 struct hci_dev *hdev = hcon->hdev; in smp_cmd_public_key()
2631 if (!hcon->out) { in smp_cmd_public_key()
2653 hcon->pending_sec_level = BT_SECURITY_MEDIUM; in smp_cmd_public_key()
2655 hcon->pending_sec_level = BT_SECURITY_FIPS; in smp_cmd_public_key()
2661 get_random_bytes(&hcon->passkey_notify, in smp_cmd_public_key()
2662 sizeof(hcon->passkey_notify)); in smp_cmd_public_key()
2663 hcon->passkey_notify %= 1000000; in smp_cmd_public_key()
2664 hcon->passkey_entered = 0; in smp_cmd_public_key()
2666 if (mgmt_user_passkey_notify(hdev, &hcon->dst, hcon->type, in smp_cmd_public_key()
2667 hcon->dst_type, in smp_cmd_public_key()
2668 hcon->passkey_notify, in smp_cmd_public_key()
2669 hcon->passkey_entered)) in smp_cmd_public_key()
2676 if (hcon->out) in smp_cmd_public_key()
2685 if (hcon->out) in smp_cmd_public_key()
2689 if (mgmt_user_passkey_request(hdev, &hcon->dst, hcon->type, in smp_cmd_public_key()
2690 hcon->dst_type)) in smp_cmd_public_key()
2700 if (conn->hcon->out) in smp_cmd_public_key()
2718 struct hci_conn *hcon = conn->hcon; in smp_cmd_dhkey_check() local
2729 memcpy(a, &hcon->init_addr, 6); in smp_cmd_dhkey_check()
2730 memcpy(b, &hcon->resp_addr, 6); in smp_cmd_dhkey_check()
2731 a[6] = hcon->init_addr_type; in smp_cmd_dhkey_check()
2732 b[6] = hcon->resp_addr_type; in smp_cmd_dhkey_check()
2734 if (hcon->out) { in smp_cmd_dhkey_check()
2747 put_unaligned_le32(hcon->passkey_notify, r); in smp_cmd_dhkey_check()
2759 if (!hcon->out) { in smp_cmd_dhkey_check()
2771 if (hcon->out) { in smp_cmd_dhkey_check()
2772 hci_le_start_enc(hcon, 0, 0, smp->tk, smp->enc_key_size); in smp_cmd_dhkey_check()
2773 hcon->enc_key_size = smp->enc_key_size; in smp_cmd_dhkey_check()
2792 struct hci_conn *hcon = conn->hcon; in smp_sig_channel() local
2800 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) { in smp_sig_channel()
2896 BT_ERR("%s unexpected SMP command 0x%02x from %pMR", hcon->hdev->name, in smp_sig_channel()
2897 code, &hcon->dst); in smp_sig_channel()
2918 struct hci_conn *hcon = conn->hcon; in bredr_pairing() local
2919 struct hci_dev *hdev = hcon->hdev; in bredr_pairing()
2926 if (!test_bit(HCI_CONN_NEW_LINK_KEY, &hcon->flags)) in bredr_pairing()
2930 if (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in bredr_pairing()
2934 if (hcon->role != HCI_ROLE_MASTER) in bredr_pairing()
2942 if (!test_bit(HCI_CONN_AES_CCM, &hcon->flags) && in bredr_pairing()
2951 if (!lmp_host_le_capable(hcon)) in bredr_pairing()
2987 struct hci_conn *hcon = conn->hcon; in smp_resume_cb() local
2991 if (hcon->type == ACL_LINK) { in smp_resume_cb()
2999 if (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in smp_resume_cb()
3010 struct hci_conn *hcon = conn->hcon; in smp_ready_cb() local
3022 if (hcon->type == ACL_LINK && test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in smp_ready_cb()
3039 hci_disconnect(chan->conn->hcon, HCI_ERROR_AUTH_FAILURE); in smp_recv_cb()