Lines Matching refs:hcon
599 bt_dev_dbg(conn->hcon->hdev, "code 0x%2.2x", code); in smp_send_cmd()
653 struct hci_conn *hcon = conn->hcon; in build_pairing_cmd() local
654 struct hci_dev *hdev = hcon->hdev; in build_pairing_cmd()
681 if (hcon->dst_type == ADDR_LE_DEV_PUBLIC) in build_pairing_cmd()
686 oob_data = hci_find_remote_oob_data(hdev, &hcon->dst, in build_pairing_cmd()
702 req->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
713 rsp->io_capability = conn->hcon->io_capability; in build_pairing_cmd()
726 struct hci_dev *hdev = conn->hcon->hdev; in check_enc_key_size()
729 if (conn->hcon->pending_sec_level == BT_SECURITY_FIPS && in check_enc_key_size()
746 struct hci_conn *hcon = conn->hcon; in smp_chan_destroy() local
754 mgmt_smp_complete(hcon, complete); in smp_chan_destroy()
767 !hci_dev_test_flag(hcon->hdev, HCI_KEEP_DEBUG_KEYS)) { in smp_chan_destroy()
793 hci_conn_drop(hcon); in smp_chan_destroy()
798 struct hci_conn *hcon = conn->hcon; in smp_failure() local
805 mgmt_auth_failed(hcon, HCI_ERROR_AUTH_FAILURE); in smp_failure()
853 struct hci_conn *hcon = conn->hcon; in tk_request() local
863 bt_dev_dbg(hcon->hdev, "auth:%u lcl:%u rem:%u", auth, local_io, in tk_request()
884 hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in tk_request()
890 ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, in tk_request()
891 hcon->type, in tk_request()
892 hcon->dst_type, in tk_request()
909 if (hcon->pending_sec_level < BT_SECURITY_HIGH) in tk_request()
910 hcon->pending_sec_level = BT_SECURITY_HIGH; in tk_request()
929 bt_dev_dbg(hcon->hdev, "PassKey: %u", passkey); in tk_request()
934 ret = mgmt_user_passkey_request(hcon->hdev, &hcon->dst, in tk_request()
935 hcon->type, hcon->dst_type); in tk_request()
937 ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, in tk_request()
938 hcon->type, hcon->dst_type, in tk_request()
941 ret = mgmt_user_passkey_notify(hcon->hdev, &hcon->dst, in tk_request()
942 hcon->type, hcon->dst_type, in tk_request()
954 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn); in smp_confirm()
957 conn->hcon->init_addr_type, &conn->hcon->init_addr, in smp_confirm()
958 conn->hcon->resp_addr_type, &conn->hcon->resp_addr, in smp_confirm()
978 struct hci_conn *hcon = conn->hcon; in smp_random() local
982 bt_dev_dbg(conn->hcon->hdev, "conn %p %s", conn, in smp_random()
987 hcon->init_addr_type, &hcon->init_addr, in smp_random()
988 hcon->resp_addr_type, &hcon->resp_addr, confirm); in smp_random()
993 bt_dev_err(hcon->hdev, "pairing failed " in smp_random()
1005 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) in smp_random()
1008 hci_le_start_enc(hcon, ediv, rand, stk, smp->enc_key_size); in smp_random()
1009 hcon->enc_key_size = smp->enc_key_size; in smp_random()
1010 set_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); in smp_random()
1027 hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in smp_random()
1038 struct hci_conn *hcon = conn->hcon; in smp_notify_keys() local
1039 struct hci_dev *hdev = hcon->hdev; in smp_notify_keys()
1044 if (hcon->type == ACL_LINK) { in smp_notify_keys()
1045 if (hcon->key_type == HCI_LK_DEBUG_COMBINATION) in smp_notify_keys()
1049 &hcon->flags); in smp_notify_keys()
1066 if (hcon->type == LE_LINK) { in smp_notify_keys()
1067 bacpy(&hcon->dst, &smp->remote_irk->bdaddr); in smp_notify_keys()
1068 hcon->dst_type = smp->remote_irk->addr_type; in smp_notify_keys()
1079 smp->csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1080 bacpy(&smp->csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1085 smp->responder_csrk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1086 bacpy(&smp->responder_csrk->bdaddr, &hcon->dst); in smp_notify_keys()
1091 smp->ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1092 bacpy(&smp->ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1097 smp->responder_ltk->bdaddr_type = hcon->dst_type; in smp_notify_keys()
1098 bacpy(&smp->responder_ltk->bdaddr, &hcon->dst); in smp_notify_keys()
1108 else if (hcon->sec_level == BT_SECURITY_FIPS) in smp_notify_keys()
1113 key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst, in smp_notify_keys()
1132 struct hci_conn *hcon = smp->conn->hcon; in sc_add_ltk() local
1140 if (hcon->pending_sec_level == BT_SECURITY_FIPS) in sc_add_ltk()
1145 smp->ltk = hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, in sc_add_ltk()
1204 struct hci_conn *hcon = smp->conn->hcon; in sc_generate_ltk() local
1205 struct hci_dev *hdev = hcon->hdev; in sc_generate_ltk()
1208 key = hci_find_link_key(hdev, &hcon->dst); in sc_generate_ltk()
1241 struct hci_conn *hcon = conn->hcon; in smp_distribute_keys() local
1242 struct hci_dev *hdev = hcon->hdev; in smp_distribute_keys()
1267 if (hcon->type == LE_LINK && (*keydist & SMP_DIST_LINK_KEY)) in smp_distribute_keys()
1269 if (hcon->type == ACL_LINK && (*keydist & SMP_DIST_ENC_KEY)) in smp_distribute_keys()
1299 authenticated = hcon->sec_level == BT_SECURITY_HIGH; in smp_distribute_keys()
1300 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, in smp_distribute_keys()
1328 bacpy(&addrinfo.bdaddr, &hcon->src); in smp_distribute_keys()
1329 addrinfo.addr_type = hcon->src_type; in smp_distribute_keys()
1346 if (hcon->sec_level > BT_SECURITY_MEDIUM) in smp_distribute_keys()
1377 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn); in smp_timeout()
1379 hci_disconnect(conn->hcon, HCI_ERROR_AUTH_FAILURE); in smp_timeout()
1384 struct hci_conn *hcon = conn->hcon; in smp_chan_create() local
1394 bt_dev_err(hcon->hdev, "Unable to create CMAC crypto context"); in smp_chan_create()
1400 bt_dev_err(hcon->hdev, "Unable to create ECDH crypto context"); in smp_chan_create()
1411 hci_conn_hold(hcon); in smp_chan_create()
1424 struct hci_conn *hcon = smp->conn->hcon; in sc_mackey_and_ltk() local
1435 memcpy(a, &hcon->init_addr, 6); in sc_mackey_and_ltk()
1436 memcpy(b, &hcon->resp_addr, 6); in sc_mackey_and_ltk()
1437 a[6] = hcon->init_addr_type; in sc_mackey_and_ltk()
1438 b[6] = hcon->resp_addr_type; in sc_mackey_and_ltk()
1445 struct hci_conn *hcon = smp->conn->hcon; in sc_dhkey_check() local
1450 memcpy(a, &hcon->init_addr, 6); in sc_dhkey_check()
1451 memcpy(b, &hcon->resp_addr, 6); in sc_dhkey_check()
1452 a[6] = hcon->init_addr_type; in sc_dhkey_check()
1453 b[6] = hcon->resp_addr_type; in sc_dhkey_check()
1468 put_unaligned_le32(hcon->passkey_notify, r); in sc_dhkey_check()
1482 struct hci_conn *hcon = conn->hcon; in sc_passkey_send_confirm() local
1486 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_send_confirm()
1503 struct hci_conn *hcon = conn->hcon; in sc_passkey_round() local
1504 struct hci_dev *hdev = hcon->hdev; in sc_passkey_round()
1513 r = ((hcon->passkey_notify >> smp->passkey_round) & 0x01); in sc_passkey_round()
1590 struct hci_conn *hcon = conn->hcon; in sc_user_reply() local
1603 hcon->passkey_notify = le32_to_cpu(passkey); in sc_user_reply()
1629 int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey) in smp_user_confirm_reply() argument
1631 struct l2cap_conn *conn = hcon->l2cap_data; in smp_user_confirm_reply()
1640 bt_dev_dbg(conn->hcon->hdev, ""); in smp_user_confirm_reply()
1663 bt_dev_dbg(conn->hcon->hdev, "PassKey: %u", value); in smp_user_confirm_reply()
1699 struct hci_dev *hdev = conn->hcon->hdev; in build_bredr_pairing_cmd()
1719 req->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1729 rsp->max_key_size = conn->hcon->enc_key_size; in build_bredr_pairing_cmd()
1740 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_req()
1781 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_req()
1783 if (!test_bit(HCI_CONN_AES_CCM, &conn->hcon->flags) && in smp_cmd_pairing_req()
1818 if (conn->hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_pairing_req()
1823 if (sec_level > conn->hcon->pending_sec_level) in smp_cmd_pairing_req()
1824 conn->hcon->pending_sec_level = sec_level; in smp_cmd_pairing_req()
1827 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_req()
1830 method = get_auth_method(smp, conn->hcon->io_capability, in smp_cmd_pairing_req()
1878 struct hci_dev *hdev = smp->conn->hcon->hdev; in sc_send_public_key()
1934 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_pairing_rsp()
1978 if (conn->hcon->type == ACL_LINK) { in smp_cmd_pairing_rsp()
1987 else if (conn->hcon->pending_sec_level > BT_SECURITY_HIGH) in smp_cmd_pairing_rsp()
1988 conn->hcon->pending_sec_level = BT_SECURITY_HIGH; in smp_cmd_pairing_rsp()
1991 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { in smp_cmd_pairing_rsp()
2033 bt_dev_dbg(conn->hcon->hdev, ""); in sc_check_confirm()
2054 struct hci_conn *hcon = conn->hcon; in fixup_sc_false_positive() local
2055 struct hci_dev *hdev = hcon->hdev; in fixup_sc_false_positive()
2092 struct hci_conn *hcon = conn->hcon; in smp_cmd_pairing_confirm() local
2093 struct hci_dev *hdev = hcon->hdev; in smp_cmd_pairing_confirm()
2138 struct hci_conn *hcon = conn->hcon; in smp_cmd_pairing_random() local
2143 bt_dev_dbg(hcon->hdev, "conn %p", conn); in smp_cmd_pairing_random()
2219 err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type, in smp_cmd_pairing_random()
2220 hcon->dst_type, passkey, confirm_hint); in smp_cmd_pairing_random()
2232 struct hci_conn *hcon = conn->hcon; in smp_ltk_encrypt() local
2234 key = hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role); in smp_ltk_encrypt()
2241 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) in smp_ltk_encrypt()
2244 hci_le_start_enc(hcon, key->ediv, key->rand, key->val, key->enc_size); in smp_ltk_encrypt()
2245 hcon->enc_key_size = key->enc_size; in smp_ltk_encrypt()
2248 clear_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags); in smp_ltk_encrypt()
2253 bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level, in smp_sufficient_security() argument
2266 test_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags) && in smp_sufficient_security()
2267 hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role)) in smp_sufficient_security()
2270 if (hcon->sec_level >= sec_level) in smp_sufficient_security()
2280 if (smp->conn->hcon->type == ACL_LINK) in smp_send_pairing_req()
2297 struct hci_conn *hcon = conn->hcon; in smp_cmd_security_req() local
2298 struct hci_dev *hdev = hcon->hdev; in smp_cmd_security_req()
2307 if (hcon->role != HCI_ROLE_MASTER) in smp_cmd_security_req()
2315 if (hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) in smp_cmd_security_req()
2320 if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) { in smp_cmd_security_req()
2325 smp_ltk_encrypt(conn, hcon->sec_level); in smp_cmd_security_req()
2329 if (sec_level > hcon->pending_sec_level) in smp_cmd_security_req()
2330 hcon->pending_sec_level = sec_level; in smp_cmd_security_req()
2332 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_cmd_security_req()
2361 int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) in smp_conn_security() argument
2363 struct l2cap_conn *conn = hcon->l2cap_data; in smp_conn_security()
2369 bt_dev_dbg(hcon->hdev, "conn %p hcon %p level 0x%2.2x", conn, hcon, in smp_conn_security()
2376 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) in smp_conn_security()
2379 if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) in smp_conn_security()
2382 if (sec_level > hcon->pending_sec_level) in smp_conn_security()
2383 hcon->pending_sec_level = sec_level; in smp_conn_security()
2385 if (hcon->role == HCI_ROLE_MASTER) in smp_conn_security()
2386 if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) in smp_conn_security()
2391 bt_dev_err(hcon->hdev, "security requested but not available"); in smp_conn_security()
2411 if (hci_dev_test_flag(hcon->hdev, HCI_SC_ENABLED)) { in smp_conn_security()
2413 if (hci_dev_test_flag(hcon->hdev, HCI_SSP_ENABLED)) in smp_conn_security()
2420 if (!hci_dev_test_flag(hcon->hdev, HCI_FORCE_NO_MITM)) { in smp_conn_security()
2424 if (hcon->io_capability != HCI_IO_NO_INPUT_OUTPUT || in smp_conn_security()
2425 hcon->pending_sec_level > BT_SECURITY_MEDIUM) in smp_conn_security()
2429 if (hcon->role == HCI_ROLE_MASTER) in smp_conn_security()
2444 struct hci_conn *hcon; in smp_cancel_and_remove_pairing() local
2453 hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type); in smp_cancel_and_remove_pairing()
2454 if (!hcon) in smp_cancel_and_remove_pairing()
2457 conn = hcon->l2cap_data; in smp_cancel_and_remove_pairing()
2494 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn); in smp_cmd_encrypt_info()
2500 if (hci_is_blocked_key(conn->hcon->hdev, HCI_BLOCKED_KEY_TYPE_LTK, in smp_cmd_encrypt_info()
2502 bt_dev_warn_ratelimited(conn->hcon->hdev, in smp_cmd_encrypt_info()
2504 &conn->hcon->dst); in smp_cmd_encrypt_info()
2522 struct hci_dev *hdev = conn->hcon->hdev; in smp_cmd_initiator_ident()
2523 struct hci_conn *hcon = conn->hcon; in smp_cmd_initiator_ident() local
2542 authenticated = (hcon->sec_level == BT_SECURITY_HIGH); in smp_cmd_initiator_ident()
2543 ltk = hci_add_ltk(hdev, &hcon->dst, hcon->dst_type, SMP_LTK, in smp_cmd_initiator_ident()
2559 bt_dev_dbg(conn->hcon->hdev, ""); in smp_cmd_ident_info()
2565 if (hci_is_blocked_key(conn->hcon->hdev, HCI_BLOCKED_KEY_TYPE_IRK, in smp_cmd_ident_info()
2567 bt_dev_warn_ratelimited(conn->hcon->hdev, in smp_cmd_ident_info()
2569 &conn->hcon->dst); in smp_cmd_ident_info()
2588 struct hci_conn *hcon = conn->hcon; in smp_cmd_ident_addr_info() local
2591 bt_dev_dbg(hcon->hdev, ""); in smp_cmd_ident_addr_info()
2616 bt_dev_err(hcon->hdev, "ignoring IRK with no identity address"); in smp_cmd_ident_addr_info()
2625 if (hci_is_identity_address(&hcon->dst, hcon->dst_type) && in smp_cmd_ident_addr_info()
2626 (bacmp(&info->bdaddr, &hcon->dst) || in smp_cmd_ident_addr_info()
2627 info->addr_type != hcon->dst_type)) { in smp_cmd_ident_addr_info()
2628 bt_dev_err(hcon->hdev, in smp_cmd_ident_addr_info()
2636 if (hci_bdaddr_is_rpa(&hcon->dst, hcon->dst_type)) in smp_cmd_ident_addr_info()
2637 bacpy(&rpa, &hcon->dst); in smp_cmd_ident_addr_info()
2641 smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, in smp_cmd_ident_addr_info()
2658 bt_dev_dbg(conn->hcon->hdev, "conn %p", conn); in smp_cmd_sign_info()
2670 if (conn->hcon->sec_level > BT_SECURITY_MEDIUM) in smp_cmd_sign_info()
2728 struct hci_conn *hcon = conn->hcon; in smp_cmd_public_key() local
2731 struct hci_dev *hdev = hcon->hdev; in smp_cmd_public_key()
2804 hcon->pending_sec_level = BT_SECURITY_MEDIUM; in smp_cmd_public_key()
2806 hcon->pending_sec_level = BT_SECURITY_FIPS; in smp_cmd_public_key()
2812 get_random_bytes(&hcon->passkey_notify, in smp_cmd_public_key()
2813 sizeof(hcon->passkey_notify)); in smp_cmd_public_key()
2814 hcon->passkey_notify %= 1000000; in smp_cmd_public_key()
2815 hcon->passkey_entered = 0; in smp_cmd_public_key()
2817 if (mgmt_user_passkey_notify(hdev, &hcon->dst, hcon->type, in smp_cmd_public_key()
2818 hcon->dst_type, in smp_cmd_public_key()
2819 hcon->passkey_notify, in smp_cmd_public_key()
2820 hcon->passkey_entered)) in smp_cmd_public_key()
2840 if (mgmt_user_passkey_request(hdev, &hcon->dst, hcon->type, in smp_cmd_public_key()
2841 hcon->dst_type)) in smp_cmd_public_key()
2869 struct hci_conn *hcon = conn->hcon; in smp_cmd_dhkey_check() local
2875 bt_dev_dbg(hcon->hdev, "conn %p", conn); in smp_cmd_dhkey_check()
2880 memcpy(a, &hcon->init_addr, 6); in smp_cmd_dhkey_check()
2881 memcpy(b, &hcon->resp_addr, 6); in smp_cmd_dhkey_check()
2882 a[6] = hcon->init_addr_type; in smp_cmd_dhkey_check()
2883 b[6] = hcon->resp_addr_type; in smp_cmd_dhkey_check()
2898 put_unaligned_le32(hcon->passkey_notify, r); in smp_cmd_dhkey_check()
2923 hci_le_start_enc(hcon, 0, 0, smp->tk, smp->enc_key_size); in smp_cmd_dhkey_check()
2924 hcon->enc_key_size = smp->enc_key_size; in smp_cmd_dhkey_check()
2935 bt_dev_dbg(conn->hcon->hdev, "value 0x%02x", kp->value); in smp_cmd_keypress_notify()
2943 struct hci_conn *hcon = conn->hcon; in smp_sig_channel() local
2951 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) { in smp_sig_channel()
3049 bt_dev_dbg(hcon->hdev, "Unknown command code 0x%2.2x", code); in smp_sig_channel()
3064 bt_dev_err(hcon->hdev, "unexpected SMP command 0x%02x from %pMR", in smp_sig_channel()
3065 code, &hcon->dst); in smp_sig_channel()
3074 bt_dev_dbg(conn->hcon->hdev, "chan %p", chan); in smp_teardown_cb()
3086 struct hci_conn *hcon = conn->hcon; in bredr_pairing() local
3087 struct hci_dev *hdev = hcon->hdev; in bredr_pairing()
3093 if (!test_bit(HCI_CONN_NEW_LINK_KEY, &hcon->flags)) in bredr_pairing()
3097 if (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in bredr_pairing()
3101 if (hcon->role != HCI_ROLE_MASTER) in bredr_pairing()
3109 if (!test_bit(HCI_CONN_AES_CCM, &hcon->flags) && in bredr_pairing()
3118 if (!lmp_host_le_capable(hcon)) in bredr_pairing()
3146 struct hci_conn *hcon = conn->hcon; in smp_resume_cb() local
3148 bt_dev_dbg(hcon->hdev, "chan %p", chan); in smp_resume_cb()
3150 if (hcon->type == ACL_LINK) { in smp_resume_cb()
3158 if (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in smp_resume_cb()
3169 struct hci_conn *hcon = conn->hcon; in smp_ready_cb() local
3171 bt_dev_dbg(hcon->hdev, "chan %p", chan); in smp_ready_cb()
3181 if (hcon->type == ACL_LINK && test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) in smp_ready_cb()
3189 bt_dev_dbg(chan->conn->hcon->hdev, "chan %p", chan); in smp_recv_cb()
3198 hci_disconnect(chan->conn->hcon, HCI_ERROR_AUTH_FAILURE); in smp_recv_cb()