Lines Matching refs:hcon

663 	struct hci_conn *hcon = conn->hcon;  in build_pairing_cmd()  local
664 struct hci_dev *hdev = hcon->hdev; in build_pairing_cmd()
691 if (hcon->dst_type == ADDR_LE_DEV_PUBLIC) in build_pairing_cmd()
696 oob_data = hci_find_remote_oob_data(hdev, &hcon->dst, in build_pairing_cmd()
712 req->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
723 rsp->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
736 struct hci_dev *hdev = conn->hcon->hdev; in check_enc_key_size()
752 struct hci_conn *hcon = conn->hcon; in smp_chan_destroy() local
760 mgmt_smp_complete(hcon, complete); in smp_chan_destroy()
773 !hci_dev_test_flag(hcon->hdev, HCI_KEEP_DEBUG_KEYS)) { in smp_chan_destroy()
799 hci_conn_drop(hcon); in smp_chan_destroy()
804 struct hci_conn *hcon = conn->hcon; in smp_failure() local
811 mgmt_auth_failed(hcon, HCI_ERROR_AUTH_FAILURE); in smp_failure()
859 struct hci_conn *hcon = conn->hcon; in tk_request() local
889 hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in tk_request()
907 if (hcon->pending_sec_level < BT_SECURITY_HIGH) in tk_request()
908 hcon->pending_sec_level = BT_SECURITY_HIGH; in tk_request()
915 if (hcon->role == HCI_ROLE_MASTER) in tk_request()
932 ret = mgmt_user_passkey_request(hcon->hdev, &hcon->dst, in tk_request()
933 hcon->type, hcon->dst_type); in tk_request()
935 ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, in tk_request()
936 hcon->type, hcon->dst_type, in tk_request()
939 ret = mgmt_user_passkey_notify(hcon->hdev, &hcon->dst, in tk_request()
940 hcon->type, hcon->dst_type, in tk_request()
955 conn->hcon->init_addr_type, &conn->hcon->init_addr, in smp_confirm()
956 conn->hcon->resp_addr_type, &conn->hcon->resp_addr, in smp_confirm()
965 if (conn->hcon->out) in smp_confirm()
976 struct hci_conn *hcon = conn->hcon; in smp_random() local
980 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_random()
983 hcon->init_addr_type, &hcon->init_addr, in smp_random()
984 hcon->resp_addr_type, &hcon->resp_addr, confirm); in smp_random()
989 bt_dev_err(hcon->hdev, "pairing failed " in smp_random()
994 if (hcon->out) { in smp_random()
1001 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) in smp_random()
1004 hci_le_start_enc(hcon, ediv, rand, stk, smp->enc_key_size); in smp_random()
1005 hcon->enc_key_size = smp->enc_key_size; in smp_random()
1006 set_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); in smp_random()
1017 if (hcon->pending_sec_level == BT_SECURITY_HIGH) in smp_random()
1026 hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in smp_random()
1037 struct hci_conn *hcon = conn->hcon; in smp_notify_keys() local
1038 struct hci_dev *hdev = hcon->hdev; in smp_notify_keys()
1043 if (hcon->type == ACL_LINK) { in smp_notify_keys()
1044 if (hcon->key_type == HCI_LK_DEBUG_COMBINATION) in smp_notify_keys()
1048 &hcon->flags); in smp_notify_keys()
1065 if (hcon->type == LE_LINK) { in smp_notify_keys()
1066 bacpy(&hcon->dst, &smp->remote_irk->bdaddr); in smp_notify_keys()
1067 hcon->dst_type = smp->remote_irk->addr_type; in smp_notify_keys()
1073 smp->csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1074 bacpy(&smp->csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1079 smp->slave_csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1080 bacpy(&smp->slave_csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1085 smp->ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1086 bacpy(&smp->ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1091 smp->slave_ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1092 bacpy(&smp->slave_ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1102 else if (hcon->sec_level == BT_SECURITY_FIPS) in smp_notify_keys()
1107 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst, in smp_notify_keys()
1126 struct hci_conn *hcon = smp->conn->hcon; in sc_add_ltk() local
1134 if (hcon->pending_sec_level == BT_SECURITY_FIPS) in sc_add_ltk()
1139 smp->ltk = hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in sc_add_ltk()
1198 struct hci_conn *hcon = smp->conn->hcon; in sc_generate_ltk() local
1199 struct hci_dev *hdev = hcon->hdev; in sc_generate_ltk()
1202 key = hci_find_link_key(hdev, &hcon->dst); in sc_generate_ltk()
1235 struct hci_conn *hcon = conn->hcon; in smp_distribute_keys() local
1236 struct hci_dev *hdev = hcon->hdev; in smp_distribute_keys()
1244 if (hcon->out && (smp->remote_key_dist & KEY_DIST_MASK)) { in smp_distribute_keys()
1251 if (hcon->out) { in smp_distribute_keys()
1260 if (hcon->type == LE_LINK && (*keydist & SMP_DIST_LINK_KEY)) in smp_distribute_keys()
1262 if (hcon->type == ACL_LINK && (*keydist & SMP_DIST_ENC_KEY)) in smp_distribute_keys()
1292 authenticated = hcon->sec_level == BT_SECURITY_HIGH; in smp_distribute_keys()
1293 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, in smp_distribute_keys()
1320 bacpy(&addrinfo.bdaddr, &hcon->src); in smp_distribute_keys()
1321 addrinfo.addr_type = hcon->src_type; in smp_distribute_keys()
1338 if (hcon->sec_level > BT_SECURITY_MEDIUM) in smp_distribute_keys()
1371 hci_disconnect(conn->hcon, HCI_ERROR_REMOTE_USER_TERM); in smp_timeout()
1402 hci_conn_hold(conn->hcon); in smp_chan_create()
1415 struct hci_conn *hcon = smp->conn->hcon; in sc_mackey_and_ltk() local
1418 if (hcon->out) { in sc_mackey_and_ltk()
1426 memcpy(a, &hcon->init_addr, 6); in sc_mackey_and_ltk()
1427 memcpy(b, &hcon->resp_addr, 6); in sc_mackey_and_ltk()
1428 a[6] = hcon->init_addr_type; in sc_mackey_and_ltk()
1429 b[6] = hcon->resp_addr_type; in sc_mackey_and_ltk()
1436 struct hci_conn *hcon = smp->conn->hcon; in sc_dhkey_check() local
1441 memcpy(a, &hcon->init_addr, 6); in sc_dhkey_check()
1442 memcpy(b, &hcon->resp_addr, 6); in sc_dhkey_check()
1443 a[6] = hcon->init_addr_type; in sc_dhkey_check()
1444 b[6] = hcon->resp_addr_type; in sc_dhkey_check()
1446 if (hcon->out) { in sc_dhkey_check()
1459 put_unaligned_le32(hcon->passkey_notify, r); in sc_dhkey_check()
1473 struct hci_conn *hcon = conn->hcon; in sc_passkey_send_confirm() local
1477 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_send_confirm()
1494 struct hci_conn *hcon = conn->hcon; in sc_passkey_round() local
1495 struct hci_dev *hdev = hcon->hdev; in sc_passkey_round()
1504 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_round()
1525 if (!hcon->out) { in sc_passkey_round()
1553 if (hcon->out) { in sc_passkey_round()
1564 if (!hcon->out) in sc_passkey_round()
1581 struct hci_conn *hcon = conn->hcon; in sc_user_reply() local
1594 hcon->passkey_notify = le32_to_cpu(passkey); in sc_user_reply()
1609 if (hcon->out) { in sc_user_reply()
1620 int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey) in smp_user_confirm_reply() argument
1622 struct l2cap_conn *conn = hcon->l2cap_data; in smp_user_confirm_reply()
1690 struct hci_dev *hdev = conn->hcon->hdev; in build_bredr_pairing_cmd()
1710 req->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1720 rsp->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1731 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_req()
1741 if (conn->hcon->role != HCI_ROLE_SLAVE) in smp_cmd_pairing_req()
1774 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_req()
1776 if (!test_bit(HCI_CONN_AES_CCM, &conn->hcon->flags) && in smp_cmd_pairing_req()
1811 if (conn->hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_pairing_req()
1816 if (sec_level > conn->hcon->pending_sec_level) in smp_cmd_pairing_req()
1817 conn->hcon->pending_sec_level = sec_level; in smp_cmd_pairing_req()
1820 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_req()
1823 method = get_auth_method(smp, conn->hcon->io_capability, in smp_cmd_pairing_req()
1867 struct hci_dev *hdev = smp->conn->hcon->hdev; in sc_send_public_key()
1923 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_rsp()
1932 if (conn->hcon->role != HCI_ROLE_MASTER) in smp_cmd_pairing_rsp()
1967 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_rsp()
1976 else if (conn->hcon->pending_sec_level > BT_SECURITY_HIGH) in smp_cmd_pairing_rsp()
1977 conn->hcon->pending_sec_level = BT_SECURITY_HIGH; in smp_cmd_pairing_rsp()
1980 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_rsp()
2027 if (conn->hcon->out) { in sc_check_confirm()
2043 struct hci_conn *hcon = conn->hcon; in fixup_sc_false_positive() local
2044 struct hci_dev *hdev = hcon->hdev; in fixup_sc_false_positive()
2049 if (hcon->out) in fixup_sc_false_positive()
2082 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); in smp_cmd_pairing_confirm()
2104 if (conn->hcon->out) { in smp_cmd_pairing_confirm()
2123 struct hci_conn *hcon = conn->hcon; in smp_cmd_pairing_random() local
2139 if (hcon->out) { in smp_cmd_pairing_random()
2152 if (!hcon->out) in smp_cmd_pairing_random()
2163 if (hcon->out) { in smp_cmd_pairing_random()
2186 if (hcon->out) { in smp_cmd_pairing_random()
2197 err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type, in smp_cmd_pairing_random()
2198 hcon->dst_type, passkey, 0); in smp_cmd_pairing_random()
2210 struct hci_conn *hcon = conn->hcon; in smp_ltk_encrypt() local
2212 key = hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role); in smp_ltk_encrypt()
2219 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) in smp_ltk_encrypt()
2222 hci_le_start_enc(hcon, key->ediv, key->rand, key->val, key->enc_size); in smp_ltk_encrypt()
2223 hcon->enc_key_size = key->enc_size; in smp_ltk_encrypt()
2226 clear_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); in smp_ltk_encrypt()
2231 bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level, in smp_sufficient_security() argument
2244 test_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags) && in smp_sufficient_security()
2245 hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role)) in smp_sufficient_security()
2248 if (hcon->sec_level >= sec_level) in smp_sufficient_security()
2258 struct hci_conn *hcon = conn->hcon; in smp_cmd_security_req() local
2259 struct hci_dev *hdev = hcon->hdev; in smp_cmd_security_req()
2268 if (hcon->role != HCI_ROLE_MASTER) in smp_cmd_security_req()
2276 if (hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_security_req()
2281 if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) { in smp_cmd_security_req()
2286 smp_ltk_encrypt(conn, hcon->sec_level); in smp_cmd_security_req()
2290 if (sec_level > hcon->pending_sec_level) in smp_cmd_security_req()
2291 hcon->pending_sec_level = sec_level; in smp_cmd_security_req()
2293 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_cmd_security_req()
2318 int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) in smp_conn_security() argument
2320 struct l2cap_conn *conn = hcon->l2cap_data; in smp_conn_security()
2326 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); in smp_conn_security()
2332 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) in smp_conn_security()
2335 if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) in smp_conn_security()
2338 if (sec_level > hcon->pending_sec_level) in smp_conn_security()
2339 hcon->pending_sec_level = sec_level; in smp_conn_security()
2341 if (hcon->role == HCI_ROLE_MASTER) in smp_conn_security()
2342 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_conn_security()
2347 bt_dev_err(hcon->hdev, "security requested but not available"); in smp_conn_security()
2367 if (hci_dev_test_flag(hcon->hdev, HCI_SC_ENABLED)) { in smp_conn_security()
2369 if (hci_dev_test_flag(hcon->hdev, HCI_SSP_ENABLED)) in smp_conn_security()
2376 if (hcon->io_capability != HCI_IO_NO_INPUT_OUTPUT || in smp_conn_security()
2377 hcon->pending_sec_level > BT_SECURITY_MEDIUM) in smp_conn_security()
2380 if (hcon->role == HCI_ROLE_MASTER) { in smp_conn_security()
2407 struct hci_conn *hcon; in smp_cancel_and_remove_pairing() local
2416 hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type); in smp_cancel_and_remove_pairing()
2417 if (!hcon) in smp_cancel_and_remove_pairing()
2420 conn = hcon->l2cap_data; in smp_cancel_and_remove_pairing()
2476 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_master_ident()
2477 struct hci_conn *hcon = conn->hcon; in smp_cmd_master_ident() local
2496 authenticated = (hcon->sec_level == BT_SECURITY_HIGH); in smp_cmd_master_ident()
2497 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, SMP_LTK, in smp_cmd_master_ident()
2533 struct hci_conn *hcon = conn->hcon; in smp_cmd_ident_addr_info() local
2561 bt_dev_err(hcon->hdev, "ignoring IRK with no identity address"); in smp_cmd_ident_addr_info()
2570 if (hci_is_identity_address(&hcon->dst, hcon->dst_type) && in smp_cmd_ident_addr_info()
2571 (bacmp(&info->bdaddr, &hcon->dst) || in smp_cmd_ident_addr_info()
2572 info->addr_type != hcon->dst_type)) { in smp_cmd_ident_addr_info()
2573 bt_dev_err(hcon->hdev, in smp_cmd_ident_addr_info()
2581 if (hci_bdaddr_is_rpa(&hcon->dst, hcon->dst_type)) in smp_cmd_ident_addr_info()
2582 bacpy(&rpa, &hcon->dst); in smp_cmd_ident_addr_info()
2586 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, in smp_cmd_ident_addr_info()
2615 if (conn->hcon->sec_level > BT_SECURITY_MEDIUM) in smp_cmd_sign_info()
2630 struct hci_conn *hcon = conn->hcon; in sc_select_method() local
2643 if (hcon->out) { in sc_select_method()
2675 struct hci_conn *hcon = conn->hcon; in smp_cmd_public_key() local
2678 struct hci_dev *hdev = hcon->hdev; in smp_cmd_public_key()
2703 if (!hcon->out) { in smp_cmd_public_key()
2742 hcon->pending_sec_level = BT_SECURITY_MEDIUM; in smp_cmd_public_key()
2744 hcon->pending_sec_level = BT_SECURITY_FIPS; in smp_cmd_public_key()
2750 get_random_bytes(&hcon->passkey_notify, in smp_cmd_public_key()
2751 sizeof(hcon->passkey_notify)); in smp_cmd_public_key()
2752 hcon->passkey_notify %= 1000000; in smp_cmd_public_key()
2753 hcon->passkey_entered = 0; in smp_cmd_public_key()
2755 if (mgmt_user_passkey_notify(hdev, &hcon->dst, hcon->type, in smp_cmd_public_key()
2756 hcon->dst_type, in smp_cmd_public_key()
2757 hcon->passkey_notify, in smp_cmd_public_key()
2758 hcon->passkey_entered)) in smp_cmd_public_key()
2765 if (hcon->out) in smp_cmd_public_key()
2774 if (hcon->out) in smp_cmd_public_key()
2778 if (mgmt_user_passkey_request(hdev, &hcon->dst, hcon->type, in smp_cmd_public_key()
2779 hcon->dst_type)) in smp_cmd_public_key()
2789 if (conn->hcon->out) in smp_cmd_public_key()
2807 struct hci_conn *hcon = conn->hcon; in smp_cmd_dhkey_check() local
2818 memcpy(a, &hcon->init_addr, 6); in smp_cmd_dhkey_check()
2819 memcpy(b, &hcon->resp_addr, 6); in smp_cmd_dhkey_check()
2820 a[6] = hcon->init_addr_type; in smp_cmd_dhkey_check()
2821 b[6] = hcon->resp_addr_type; in smp_cmd_dhkey_check()
2823 if (hcon->out) { in smp_cmd_dhkey_check()
2836 put_unaligned_le32(hcon->passkey_notify, r); in smp_cmd_dhkey_check()
2848 if (!hcon->out) { in smp_cmd_dhkey_check()
2860 if (hcon->out) { in smp_cmd_dhkey_check()
2861 hci_le_start_enc(hcon, 0, 0, smp->tk, smp->enc_key_size); in smp_cmd_dhkey_check()
2862 hcon->enc_key_size = smp->enc_key_size; in smp_cmd_dhkey_check()
2881 struct hci_conn *hcon = conn->hcon; in smp_sig_channel() local
2889 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) { in smp_sig_channel()
2985 bt_dev_err(hcon->hdev, "unexpected SMP command 0x%02x from %pMR", in smp_sig_channel()
2986 code, &hcon->dst); in smp_sig_channel()
3007 struct hci_conn *hcon = conn->hcon; in bredr_pairing() local
3008 struct hci_dev *hdev = hcon->hdev; in bredr_pairing()
3015 if (!test_bit(HCI_CONN_NEW_LINK_KEY, &hcon->flags)) in bredr_pairing()
3019 if (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in bredr_pairing()
3023 if (hcon->role != HCI_ROLE_MASTER) in bredr_pairing()
3031 if (!test_bit(HCI_CONN_AES_CCM, &hcon->flags) && in bredr_pairing()
3040 if (!lmp_host_le_capable(hcon)) in bredr_pairing()
3075 struct hci_conn *hcon = conn->hcon; in smp_resume_cb() local
3079 if (hcon->type == ACL_LINK) { in smp_resume_cb()
3087 if (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in smp_resume_cb()
3098 struct hci_conn *hcon = conn->hcon; in smp_ready_cb() local
3110 if (hcon->type == ACL_LINK && test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in smp_ready_cb()
3127 hci_disconnect(chan->conn->hcon, HCI_ERROR_AUTH_FAILURE); in smp_recv_cb()