• Home
  • Raw
  • Download

Lines Matching refs:p_dev_rec

77 extern bool btm_ble_init_pseudo_addr(tBTM_SEC_DEV_REC* p_dev_rec,
82 extern void HACK_acl_check_sm4(tBTM_SEC_DEV_REC& p_dev_rec);
89 static bool btm_sec_start_get_name(tBTM_SEC_DEV_REC* p_dev_rec);
90 static void btm_sec_start_authentication(tBTM_SEC_DEV_REC* p_dev_rec);
94 static tBTM_STATUS btm_sec_dd_create_conn(tBTM_SEC_DEV_REC* p_dev_rec);
106 static void btm_send_link_key_notif(tBTM_SEC_DEV_REC* p_dev_rec);
107 static bool btm_sec_check_prefetch_pin(tBTM_SEC_DEV_REC* p_dev_rec);
109 static tBTM_STATUS btm_sec_send_hci_disconnect(tBTM_SEC_DEV_REC* p_dev_rec,
114 static bool btm_dev_authenticated(tBTM_SEC_DEV_REC* p_dev_rec);
115 static bool btm_dev_encrypted(tBTM_SEC_DEV_REC* p_dev_rec);
124 static void btm_sec_check_pending_enc_req(tBTM_SEC_DEV_REC* p_dev_rec,
128 static bool btm_sec_use_smp_br_chnl(tBTM_SEC_DEV_REC* p_dev_rec);
142 static void NotifyBondingChange(tBTM_SEC_DEV_REC& p_dev_rec, in NotifyBondingChange() argument
146 p_dev_rec.bd_addr, static_cast<uint8_t*>(p_dev_rec.dev_class), in NotifyBondingChange()
147 p_dev_rec.sec_bd_name, status); in NotifyBondingChange()
166 static bool btm_dev_authenticated(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_dev_authenticated() argument
167 if (p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED) { in btm_dev_authenticated()
182 static bool btm_dev_encrypted(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_dev_encrypted() argument
183 if (p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED) { in btm_dev_encrypted()
198 static bool btm_dev_16_digit_authenticated(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_dev_16_digit_authenticated() argument
200 if (p_dev_rec->sec_flags & BTM_SEC_16_DIGIT_PIN_AUTHED) { in btm_dev_16_digit_authenticated()
302 tBTM_SEC_DEV_REC* p_dev_rec; in BTM_GetSecurityFlags() local
304 p_dev_rec = btm_find_dev(bd_addr); in BTM_GetSecurityFlags()
305 if (p_dev_rec != NULL) { in BTM_GetSecurityFlags()
306 *p_sec_flags = (uint8_t)p_dev_rec->sec_flags; in BTM_GetSecurityFlags()
349 tBTM_SEC_DEV_REC* p_dev_rec; in BTM_GetSecurityFlagsByTransport() local
351 p_dev_rec = btm_find_dev(bd_addr); in BTM_GetSecurityFlagsByTransport()
352 if (p_dev_rec != NULL) { in BTM_GetSecurityFlagsByTransport()
354 *p_sec_flags = (uint8_t)p_dev_rec->sec_flags; in BTM_GetSecurityFlagsByTransport()
356 *p_sec_flags = (uint8_t)(p_dev_rec->sec_flags >> 8); in BTM_GetSecurityFlagsByTransport()
617 tBTM_SEC_DEV_REC* p_dev_rec; in BTM_PINCodeReply() local
637 p_dev_rec = btm_find_dev(bd_addr); in BTM_PINCodeReply()
638 if (p_dev_rec == NULL) { in BTM_PINCodeReply()
659 p_dev_rec->security_required = BTM_SEC_NONE; in BTM_PINCodeReply()
664 p_dev_rec->sec_flags |= BTM_SEC_LINK_KEY_AUTHED; in BTM_PINCodeReply()
665 p_dev_rec->pin_code_length = pin_len; in BTM_PINCodeReply()
667 p_dev_rec->sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED; in BTM_PINCodeReply()
671 (p_dev_rec->hci_handle == HCI_INVALID_HANDLE) && in BTM_PINCodeReply()
695 else if (p_dev_rec->sm4 & BTM_SM4_CONN_PEND) { in BTM_PINCodeReply()
700 } else if (btm_sec_dd_create_conn(p_dev_rec) != BTM_CMD_STARTED) { in BTM_PINCodeReply()
702 p_dev_rec->sec_flags &= ~BTM_SEC_LINK_KEY_AUTHED; in BTM_PINCodeReply()
704 NotifyBondingChange(*p_dev_rec, HCI_ERR_AUTH_FAILURE); in BTM_PINCodeReply()
730 tBTM_SEC_DEV_REC* p_dev_rec; in btm_sec_bond_by_transport() local
744 p_dev_rec = btm_find_or_alloc_dev(bd_addr); in btm_sec_bond_by_transport()
745 if (p_dev_rec == NULL) { in btm_sec_bond_by_transport()
754 BTM_TRACE_DEBUG("before update sec_flags=0x%x", p_dev_rec->sec_flags); in btm_sec_bond_by_transport()
757 if (((p_dev_rec->hci_handle != HCI_INVALID_HANDLE) && in btm_sec_bond_by_transport()
759 (p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED)) || in btm_sec_bond_by_transport()
760 ((p_dev_rec->ble_hci_handle != HCI_INVALID_HANDLE) && in btm_sec_bond_by_transport()
762 (p_dev_rec->sec_flags & BTM_SEC_LE_AUTHENTICATED))) { in btm_sec_bond_by_transport()
774 p_dev_rec->pin_code_length = pin_len; in btm_sec_bond_by_transport()
782 p_dev_rec->security_required = BTM_SEC_OUT_AUTHENTICATE; in btm_sec_bond_by_transport()
783 p_dev_rec->is_originator = true; in btm_sec_bond_by_transport()
789 btm_ble_init_pseudo_addr(p_dev_rec, bd_addr); in btm_sec_bond_by_transport()
790 p_dev_rec->sec_flags &= ~BTM_SEC_LE_MASK; in btm_sec_bond_by_transport()
794 p_dev_rec->sec_state = BTM_SEC_STATE_AUTHENTICATING; in btm_sec_bond_by_transport()
803 p_dev_rec->sec_flags &= in btm_sec_bond_by_transport()
807 BTM_TRACE_DEBUG("after update sec_flags=0x%x", p_dev_rec->sec_flags); in btm_sec_bond_by_transport()
812 if (((p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK) == in btm_sec_bond_by_transport()
814 (p_dev_rec->dev_class[2] & BTM_COD_MINOR_KEYBOARD) && in btm_sec_bond_by_transport()
822 p_dev_rec->sm4, p_dev_rec->hci_handle); in btm_sec_bond_by_transport()
825 p_dev_rec->sec_flags &= ~BTM_SEC_NAME_KNOWN; in btm_sec_bond_by_transport()
830 btm_sec_start_authentication(p_dev_rec); in btm_sec_bond_by_transport()
839 BTM_TRACE_DEBUG("sec mode: %d sm4:x%x", btm_cb.security_mode, p_dev_rec->sm4); in btm_sec_bond_by_transport()
841 (p_dev_rec->sm4 == BTM_SM4_KNOWN)) { in btm_sec_bond_by_transport()
842 if (btm_sec_check_prefetch_pin(p_dev_rec)) return (BTM_CMD_STARTED); in btm_sec_bond_by_transport()
846 BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4)) { in btm_sec_bond_by_transport()
848 if ((p_dev_rec->sm4 & BTM_SM4_CONN_PEND) == 0) { in btm_sec_bond_by_transport()
860 btm_pair_state_descr(btm_cb.pairing_state), p_dev_rec->sm4, in btm_sec_bond_by_transport()
861 p_dev_rec->sec_state); in btm_sec_bond_by_transport()
864 status = btm_sec_dd_create_conn(p_dev_rec); in btm_sec_bond_by_transport()
931 tBTM_SEC_DEV_REC* p_dev_rec; in BTM_SecBondCancel() local
936 p_dev_rec = btm_find_dev(bd_addr); in BTM_SecBondCancel()
937 if (!p_dev_rec || btm_cb.pairing_bda != bd_addr) { in BTM_SecBondCancel()
942 if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING) { in BTM_SecBondCancel()
951 BTM_TRACE_DEBUG("hci_handle:0x%x sec_state:%d", p_dev_rec->hci_handle, in BTM_SecBondCancel()
952 p_dev_rec->sec_state); in BTM_SecBondCancel()
964 if (p_dev_rec->hci_handle != HCI_INVALID_HANDLE) { in BTM_SecBondCancel()
966 if ((p_dev_rec->sec_state == BTM_SEC_STATE_DISCONNECTING) || in BTM_SecBondCancel()
967 (p_dev_rec->sec_state == BTM_SEC_STATE_DISCONNECTING_BOTH)) in BTM_SecBondCancel()
972 return btm_sec_send_hci_disconnect(p_dev_rec, HCI_ERR_PEER_USER, in BTM_SecBondCancel()
973 p_dev_rec->hci_handle); in BTM_SecBondCancel()
1012 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); in BTM_SecGetDeviceLinkKeyType() local
1014 if ((p_dev_rec != NULL) && (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN)) { in BTM_SecGetDeviceLinkKeyType()
1015 return p_dev_rec->link_key_type; in BTM_SecGetDeviceLinkKeyType()
1058 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); in BTM_SetEncryption() local
1059 if (!p_dev_rec || in BTM_SetEncryption()
1061 p_dev_rec->hci_handle == HCI_INVALID_HANDLE) || in BTM_SetEncryption()
1063 p_dev_rec->ble_hci_handle == HCI_INVALID_HANDLE)) { in BTM_SetEncryption()
1074 (p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED)) { in BTM_SetEncryption()
1084 if (p_dev_rec->p_callback || (p_dev_rec->sec_state != BTM_SEC_STATE_IDLE)) { in BTM_SetEncryption()
1098 p_dev_rec->p_callback = p_callback; in BTM_SetEncryption()
1099 p_dev_rec->p_ref_data = p_ref_data; in BTM_SetEncryption()
1100 p_dev_rec->security_required |= in BTM_SetEncryption()
1102 p_dev_rec->is_originator = false; in BTM_SetEncryption()
1107 p_dev_rec->hci_handle, p_dev_rec->sec_state, p_dev_rec->sec_flags, in BTM_SetEncryption()
1108 p_dev_rec->security_required, p_dev_rec, p_callback); in BTM_SetEncryption()
1120 rc = btm_sec_execute_procedure(p_dev_rec); in BTM_SetEncryption()
1128 __func__, p_callback, p_dev_rec, transport, in BTM_SetEncryption()
1130 p_dev_rec->p_callback = NULL; in BTM_SetEncryption()
1131 (*p_callback)(&bd_addr, transport, p_dev_rec->p_ref_data, rc); in BTM_SetEncryption()
1139 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); in BTM_SecIsSecurityPending() local
1140 return p_dev_rec && (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING || in BTM_SecIsSecurityPending()
1141 p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING); in BTM_SecIsSecurityPending()
1147 static tBTM_STATUS btm_sec_send_hci_disconnect(tBTM_SEC_DEV_REC* p_dev_rec, in btm_sec_send_hci_disconnect() argument
1151 static_cast<tSECURITY_STATE>(p_dev_rec->sec_state); in btm_sec_send_hci_disconnect()
1157 if (conn_handle == p_dev_rec->hci_handle) { in btm_sec_send_hci_disconnect()
1162 p_dev_rec->sec_state = BTM_SEC_STATE_DISCONNECTING_BOTH; in btm_sec_send_hci_disconnect()
1166 if (conn_handle == p_dev_rec->ble_hci_handle) { in btm_sec_send_hci_disconnect()
1171 p_dev_rec->sec_state = BTM_SEC_STATE_DISCONNECTING_BOTH; in btm_sec_send_hci_disconnect()
1179 p_dev_rec->sec_state = (conn_handle == p_dev_rec->hci_handle) in btm_sec_send_hci_disconnect()
1259 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); in BTM_PasskeyReqReply() local
1260 if (p_dev_rec != NULL) { in BTM_PasskeyReqReply()
1263 if (p_dev_rec->hci_handle != HCI_INVALID_HANDLE) in BTM_PasskeyReqReply()
1264 btm_sec_send_hci_disconnect(p_dev_rec, HCI_ERR_AUTH_FAILURE, in BTM_PasskeyReqReply()
1265 p_dev_rec->hci_handle); in BTM_PasskeyReqReply()
1269 p_dev_rec->sec_flags &= in BTM_PasskeyReqReply()
1369 tBTM_SEC_DEV_REC* p_dev_rec; in BTM_PeerSupportsSecureConnections() local
1371 p_dev_rec = btm_find_dev(bd_addr); in BTM_PeerSupportsSecureConnections()
1372 if (p_dev_rec == NULL) { in BTM_PeerSupportsSecureConnections()
1377 return (p_dev_rec->SupportsSecureConnections()); in BTM_PeerSupportsSecureConnections()
1396 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); in BTM_GetPeerDeviceTypeFromFeatures() local
1397 if (p_dev_rec == nullptr) { in BTM_GetPeerDeviceTypeFromFeatures()
1400 if (p_dev_rec->remote_supports_ble && p_dev_rec->remote_supports_bredr) { in BTM_GetPeerDeviceTypeFromFeatures()
1402 } else if (p_dev_rec->remote_supports_bredr) { in BTM_GetPeerDeviceTypeFromFeatures()
1404 } else if (p_dev_rec->remote_supports_ble) { in BTM_GetPeerDeviceTypeFromFeatures()
1427 static bool btm_sec_is_upgrade_possible(tBTM_SEC_DEV_REC* p_dev_rec, in btm_sec_is_upgrade_possible() argument
1432 if (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN) { in btm_sec_is_upgrade_possible()
1438 if ((p_dev_rec->security_required & mtm_check) /* needs MITM */ in btm_sec_is_upgrade_possible()
1439 && ((p_dev_rec->link_key_type == BTM_LKEY_TYPE_UNAUTH_COMB) || in btm_sec_is_upgrade_possible()
1440 (p_dev_rec->link_key_type == BTM_LKEY_TYPE_UNAUTH_COMB_P_256)) in btm_sec_is_upgrade_possible()
1443 && (p_dev_rec->rmt_io_caps < BTM_IO_CAP_MAX) /* a valid peer IO cap */ in btm_sec_is_upgrade_possible()
1444 && (btm_sec_io_map[p_dev_rec->rmt_io_caps][btm_cb.devcb.loc_io_caps])) in btm_sec_is_upgrade_possible()
1456 p_dev_rec->sec_flags); in btm_sec_is_upgrade_possible()
1470 static void btm_sec_check_upgrade(tBTM_SEC_DEV_REC* p_dev_rec, in btm_sec_check_upgrade() argument
1475 if (!(p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN)) return; in btm_sec_check_upgrade()
1477 if (btm_sec_is_upgrade_possible(p_dev_rec, is_originator)) { in btm_sec_check_upgrade()
1478 BTM_TRACE_DEBUG("need upgrade!! sec_flags:0x%x", p_dev_rec->sec_flags); in btm_sec_check_upgrade()
1480 p_dev_rec->sm4 |= BTM_SM4_UPGRADE; in btm_sec_check_upgrade()
1483 p_dev_rec->sec_flags &= ~(BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_LINK_KEY_AUTHED); in btm_sec_check_upgrade()
1484 p_dev_rec->sec_flags &= ~BTM_SEC_AUTHENTICATED; in btm_sec_check_upgrade()
1485 BTM_TRACE_DEBUG("sec_flags:0x%x", p_dev_rec->sec_flags); in btm_sec_check_upgrade()
1504 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(bd_addr); in btm_sec_l2cap_access_req_by_requirement() local
1506 p_dev_rec->hci_handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_BR_EDR); in btm_sec_l2cap_access_req_by_requirement()
1513 if (!local_supports_sc || !p_dev_rec->SupportsSecureConnections()) { in btm_sec_l2cap_access_req_by_requirement()
1518 logbool(p_dev_rec->SupportsSecureConnections()).c_str()); in btm_sec_l2cap_access_req_by_requirement()
1531 if ((p_dev_rec->p_callback) || in btm_sec_l2cap_access_req_by_requirement()
1534 p_dev_rec->sec_flags); in btm_sec_l2cap_access_req_by_requirement()
1537 (BTM_SM4_KNOWN == p_dev_rec->sm4) || in btm_sec_l2cap_access_req_by_requirement()
1538 (BTM_SEC_IS_SM4(p_dev_rec->sm4) && in btm_sec_l2cap_access_req_by_requirement()
1539 (!btm_sec_is_upgrade_possible(p_dev_rec, is_originator)))) { in btm_sec_l2cap_access_req_by_requirement()
1546 btm_dev_authenticated(p_dev_rec))) || in btm_sec_l2cap_access_req_by_requirement()
1549 btm_dev_encrypted(p_dev_rec)))) { in btm_sec_l2cap_access_req_by_requirement()
1556 btm_dev_authenticated(p_dev_rec)) || in btm_sec_l2cap_access_req_by_requirement()
1559 btm_dev_encrypted(p_dev_rec))) { in btm_sec_l2cap_access_req_by_requirement()
1564 btm_dev_16_digit_authenticated(p_dev_rec))) { in btm_sec_l2cap_access_req_by_requirement()
1571 (p_dev_rec->link_key_type != BTM_LKEY_TYPE_AUTH_COMB_P_256)) { in btm_sec_l2cap_access_req_by_requirement()
1587 p_dev_rec->required_security_flags_for_pairing = security_required; in btm_sec_l2cap_access_req_by_requirement()
1592 if (BTM_SEC_IS_SM4(p_dev_rec->sm4)) { in btm_sec_l2cap_access_req_by_requirement()
1604 } else if (!(BTM_SM4_KNOWN & p_dev_rec->sm4)) { in btm_sec_l2cap_access_req_by_requirement()
1608 p_dev_rec->sec_flags, (is_originator) ? "initiator" : "acceptor"); in btm_sec_l2cap_access_req_by_requirement()
1610 p_dev_rec->sm4 |= BTM_SM4_REQ_PEND; in btm_sec_l2cap_access_req_by_requirement()
1617 p_dev_rec->sm4, p_dev_rec->sec_flags, security_required, in btm_sec_l2cap_access_req_by_requirement()
1620 p_dev_rec->security_required = security_required; in btm_sec_l2cap_access_req_by_requirement()
1621 p_dev_rec->p_ref_data = p_ref_data; in btm_sec_l2cap_access_req_by_requirement()
1622 p_dev_rec->is_originator = is_originator; in btm_sec_l2cap_access_req_by_requirement()
1628 (p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED), in btm_sec_l2cap_access_req_by_requirement()
1629 (p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED)); in btm_sec_l2cap_access_req_by_requirement()
1632 if ((0 == (p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED)) || in btm_sec_l2cap_access_req_by_requirement()
1633 (0 == (p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED))) { in btm_sec_l2cap_access_req_by_requirement()
1644 p_dev_rec->p_callback = p_callback; in btm_sec_l2cap_access_req_by_requirement()
1645 p_dev_rec->sec_state = BTM_SEC_STATE_DELAY_FOR_ENC; in btm_sec_l2cap_access_req_by_requirement()
1652 p_dev_rec->p_callback = p_callback; in btm_sec_l2cap_access_req_by_requirement()
1654 if (BTM_SEC_IS_SM4(p_dev_rec->sm4)) { in btm_sec_l2cap_access_req_by_requirement()
1655 if ((p_dev_rec->security_required & BTM_SEC_MODE4_LEVEL4) && in btm_sec_l2cap_access_req_by_requirement()
1656 (p_dev_rec->link_key_type != BTM_LKEY_TYPE_AUTH_COMB_P_256)) { in btm_sec_l2cap_access_req_by_requirement()
1659 if ((p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN) != 0) { in btm_sec_l2cap_access_req_by_requirement()
1660 p_dev_rec->sm4 |= BTM_SM4_UPGRADE; in btm_sec_l2cap_access_req_by_requirement()
1662 p_dev_rec->sec_flags &= in btm_sec_l2cap_access_req_by_requirement()
1665 BTM_TRACE_DEBUG("%s: sec_flags:0x%x", __func__, p_dev_rec->sec_flags); in btm_sec_l2cap_access_req_by_requirement()
1669 btm_sec_check_upgrade(p_dev_rec, is_originator); in btm_sec_l2cap_access_req_by_requirement()
1673 rc = btm_sec_execute_procedure(p_dev_rec); in btm_sec_l2cap_access_req_by_requirement()
1676 __func__, p_dev_rec, p_dev_rec->p_callback); in btm_sec_l2cap_access_req_by_requirement()
1677 p_dev_rec->p_callback = NULL; in btm_sec_l2cap_access_req_by_requirement()
1678 (*p_callback)(&bd_addr, transport, p_dev_rec->p_ref_data, rc); in btm_sec_l2cap_access_req_by_requirement()
1768 tBTM_SEC_DEV_REC* p_dev_rec; in btm_sec_mx_access_request() local
1778 p_dev_rec = btm_find_or_alloc_dev(bd_addr); in btm_sec_mx_access_request()
1783 if ((p_dev_rec->p_callback) || in btm_sec_mx_access_request()
1791 (BTM_SM4_KNOWN == p_dev_rec->sm4) || in btm_sec_mx_access_request()
1792 (BTM_SEC_IS_SM4(p_dev_rec->sm4) && in btm_sec_mx_access_request()
1793 (!btm_sec_is_upgrade_possible(p_dev_rec, is_originator)))) { in btm_sec_mx_access_request()
1800 btm_dev_authenticated(p_dev_rec))) || in btm_sec_mx_access_request()
1803 btm_dev_encrypted(p_dev_rec)))) { in btm_sec_mx_access_request()
1810 btm_dev_authenticated(p_dev_rec))) || in btm_sec_mx_access_request()
1813 btm_dev_encrypted(p_dev_rec)))) { in btm_sec_mx_access_request()
1818 btm_dev_16_digit_authenticated(p_dev_rec))) { in btm_sec_mx_access_request()
1824 (p_dev_rec->link_key_type != BTM_LKEY_TYPE_AUTH_COMB_P_256)) { in btm_sec_mx_access_request()
1830 if (p_dev_rec->sec_state != BTM_SEC_STATE_IDLE) { in btm_sec_mx_access_request()
1854 if (!(local_supports_sc) || !(p_dev_rec->SupportsSecureConnections())) { in btm_sec_mx_access_request()
1859 logbool(p_dev_rec->SupportsSecureConnections()).c_str()); in btm_sec_mx_access_request()
1875 p_dev_rec->required_security_flags_for_pairing = security_required; in btm_sec_mx_access_request()
1876 p_dev_rec->security_required = security_required; in btm_sec_mx_access_request()
1880 if (BTM_SEC_IS_SM4(p_dev_rec->sm4)) { in btm_sec_mx_access_request()
1881 if ((p_dev_rec->security_required & BTM_SEC_MODE4_LEVEL4) && in btm_sec_mx_access_request()
1882 (p_dev_rec->link_key_type != BTM_LKEY_TYPE_AUTH_COMB_P_256)) { in btm_sec_mx_access_request()
1885 if ((p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN) != 0) { in btm_sec_mx_access_request()
1886 p_dev_rec->sm4 |= BTM_SM4_UPGRADE; in btm_sec_mx_access_request()
1889 p_dev_rec->sec_flags &= in btm_sec_mx_access_request()
1892 BTM_TRACE_DEBUG("%s: sec_flags:0x%x", __func__, p_dev_rec->sec_flags); in btm_sec_mx_access_request()
1895 btm_sec_check_upgrade(p_dev_rec, is_originator); in btm_sec_mx_access_request()
1900 p_dev_rec->is_originator = is_originator; in btm_sec_mx_access_request()
1901 p_dev_rec->p_callback = p_callback; in btm_sec_mx_access_request()
1902 p_dev_rec->p_ref_data = p_ref_data; in btm_sec_mx_access_request()
1904 rc = btm_sec_execute_procedure(p_dev_rec); in btm_sec_mx_access_request()
1906 PRIVATE_ADDRESS(p_dev_rec->RemoteAddress()), in btm_sec_mx_access_request()
1910 p_dev_rec->p_callback = NULL; in btm_sec_mx_access_request()
1929 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bda); in btm_sec_conn_req() local
1956 if (!p_dev_rec) { in btm_sec_conn_req()
1958 p_dev_rec = btm_sec_alloc_dev(bda); in btm_sec_conn_req()
1960 p_dev_rec->sm4 |= BTM_SM4_CONN_PEND; in btm_sec_conn_req()
1974 tBTM_SEC_DEV_REC* p_dev_rec; in btm_sec_bond_cancel_complete() local
1990 p_dev_rec = btm_find_dev(btm_cb.pairing_bda); in btm_sec_bond_cancel_complete()
1991 if (p_dev_rec != NULL) p_dev_rec->security_required = BTM_SEC_NONE; in btm_sec_bond_cancel_complete()
2128 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); in btm_sec_abort_access_req() local
2130 if (!p_dev_rec) return; in btm_sec_abort_access_req()
2132 if ((p_dev_rec->sec_state != BTM_SEC_STATE_AUTHORIZING) && in btm_sec_abort_access_req()
2133 (p_dev_rec->sec_state != BTM_SEC_STATE_AUTHENTICATING)) in btm_sec_abort_access_req()
2136 p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; in btm_sec_abort_access_req()
2139 __func__, p_dev_rec, p_dev_rec->p_callback); in btm_sec_abort_access_req()
2140 p_dev_rec->p_callback = NULL; in btm_sec_abort_access_req()
2153 static tBTM_STATUS btm_sec_dd_create_conn(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_sec_dd_create_conn() argument
2154 tBTM_STATUS status = l2cu_ConnectAclForSecurity(p_dev_rec->bd_addr); in btm_sec_dd_create_conn()
2165 VLOG(1) << "Security Manager: " << p_dev_rec->bd_addr; in btm_sec_dd_create_conn()
2173 tBTM_SEC_DEV_REC* p_dev_rec = static_cast<tBTM_SEC_DEV_REC*>(data); in is_state_getting_name() local
2175 if (p_dev_rec->sec_state == BTM_SEC_STATE_GETTING_NAME) { in is_state_getting_name()
2193 tBTM_SEC_DEV_REC* p_dev_rec; in btm_sec_rmt_name_request_complete() local
2208 p_dev_rec = btm_find_dev(*p_bd_addr); in btm_sec_rmt_name_request_complete()
2213 p_dev_rec = static_cast<tBTM_SEC_DEV_REC*>(list_node(node)); in btm_sec_rmt_name_request_complete()
2214 p_bd_addr = &p_dev_rec->bd_addr; in btm_sec_rmt_name_request_complete()
2216 p_dev_rec = NULL; in btm_sec_rmt_name_request_complete()
2224 if (p_dev_rec) { in btm_sec_rmt_name_request_complete()
2229 p_dev_rec->sec_state, p_dev_rec); in btm_sec_rmt_name_request_complete()
2236 if (p_dev_rec) { in btm_sec_rmt_name_request_complete()
2237 old_sec_state = p_dev_rec->sec_state; in btm_sec_rmt_name_request_complete()
2239 strlcpy((char*)p_dev_rec->sec_bd_name, (char*)p_bd_name, in btm_sec_rmt_name_request_complete()
2241 p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN; in btm_sec_rmt_name_request_complete()
2243 p_dev_rec->sec_flags); in btm_sec_rmt_name_request_complete()
2247 p_dev_rec->sec_bd_name[0] = 0; in btm_sec_rmt_name_request_complete()
2250 if (p_dev_rec->sec_state == BTM_SEC_STATE_GETTING_NAME) in btm_sec_rmt_name_request_complete()
2251 p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; in btm_sec_rmt_name_request_complete()
2256 (*btm_cb.p_rmt_name_callback[i])(*p_bd_addr, p_dev_rec->dev_class, in btm_sec_rmt_name_request_complete()
2257 p_dev_rec->sec_bd_name); in btm_sec_rmt_name_request_complete()
2288 p_dev_rec->bd_addr, p_dev_rec->dev_class, p_bd_name, in btm_sec_rmt_name_request_complete()
2289 (p_dev_rec->required_security_flags_for_pairing & in btm_sec_rmt_name_request_complete()
2302 __func__, p_dev_rec->sm4, status); in btm_sec_rmt_name_request_complete()
2311 return NotifyBondingChange(*p_dev_rec, status); in btm_sec_rmt_name_request_complete()
2316 if (BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4)) { in btm_sec_rmt_name_request_complete()
2323 p_dev_rec->sm4 |= BTM_SM4_KNOWN; in btm_sec_rmt_name_request_complete()
2327 __func__, p_dev_rec->sm4, in btm_sec_rmt_name_request_complete()
2328 BTM_SEC_IS_SM4_LEGACY(p_dev_rec->sm4), in btm_sec_rmt_name_request_complete()
2329 BTM_SEC_IS_SM4(p_dev_rec->sm4), in btm_sec_rmt_name_request_complete()
2330 BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4)); in btm_sec_rmt_name_request_complete()
2337 if ((p_dev_rec->sm4 != BTM_SM4_KNOWN) || in btm_sec_rmt_name_request_complete()
2338 !btm_sec_check_prefetch_pin(p_dev_rec)) { in btm_sec_rmt_name_request_complete()
2348 else if (btm_sec_dd_create_conn(p_dev_rec) != BTM_CMD_STARTED) { in btm_sec_rmt_name_request_complete()
2353 NotifyBondingChange(*p_dev_rec, HCI_ERR_MEMORY_FULL); in btm_sec_rmt_name_request_complete()
2362 NotifyBondingChange(*p_dev_rec, HCI_ERR_MEMORY_FULL); in btm_sec_rmt_name_request_complete()
2370 if (p_dev_rec->link_key_not_sent) { in btm_sec_rmt_name_request_complete()
2372 if (p_dev_rec->hci_handle == HCI_INVALID_HANDLE) return; in btm_sec_rmt_name_request_complete()
2374 p_dev_rec->link_key_not_sent = false; in btm_sec_rmt_name_request_complete()
2375 btm_send_link_key_notif(p_dev_rec); in btm_sec_rmt_name_request_complete()
2380 (p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED)) { in btm_sec_rmt_name_request_complete()
2382 p_dev_rec->security_required &= ~(BTM_SEC_OUT_AUTHENTICATE); in btm_sec_rmt_name_request_complete()
2383 l2cu_start_post_bond_timer(p_dev_rec->hci_handle); in btm_sec_rmt_name_request_complete()
2391 btm_sec_dev_rec_cback_event(p_dev_rec, BTM_ERR_PROCESSING, false); in btm_sec_rmt_name_request_complete()
2395 if (p_dev_rec->sm4 & BTM_SM4_REQ_PEND) { in btm_sec_rmt_name_request_complete()
2401 tBTM_STATUS btm_status = btm_sec_execute_procedure(p_dev_rec); in btm_sec_rmt_name_request_complete()
2408 btm_sec_dev_rec_cback_event(p_dev_rec, btm_status, false); in btm_sec_rmt_name_request_complete()
2422 tBTM_SEC_DEV_REC* p_dev_rec; in btm_sec_rmt_host_support_feat_evt() local
2427 p_dev_rec = btm_find_or_alloc_dev(bd_addr); in btm_sec_rmt_host_support_feat_evt()
2430 p_dev_rec->sm4, p[0]); in btm_sec_rmt_host_support_feat_evt()
2432 if (BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4)) { in btm_sec_rmt_host_support_feat_evt()
2433 p_dev_rec->sm4 = BTM_SM4_KNOWN; in btm_sec_rmt_host_support_feat_evt()
2436 p_dev_rec->sm4 = BTM_SM4_TRUE; in btm_sec_rmt_host_support_feat_evt()
2440 p_dev_rec->sm4, features[0]); in btm_sec_rmt_host_support_feat_evt()
2463 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(p); in btm_io_capabilities_req() local
2466 (!p_dev_rec->remote_feature_received)) { in btm_io_capabilities_req()
2471 p_dev_rec->remote_features_needed = true; in btm_io_capabilities_req()
2491 p_dev_rec->sm4 |= BTM_SM4_TRUE; in btm_io_capabilities_req()
2542 if (!(local_supports_sc) || !(p_dev_rec->SupportsSecureConnections())) { in btm_io_capabilities_req()
2547 logbool(p_dev_rec->SupportsSecureConnections()).c_str()); in btm_io_capabilities_req()
2563 (p_dev_rec->required_security_flags_for_pairing & in btm_io_capabilities_req()
2570 (p_dev_rec->required_security_flags_for_pairing & BTM_SEC_OUT_MITM) in btm_io_capabilities_req()
2583 memcpy(p_dev_rec->dev_class, btm_cb.connecting_dc, DEV_CLASS_LEN); in btm_io_capabilities_req()
2588 if (p_dev_rec->sm4 & BTM_SM4_UPGRADE) { in btm_io_capabilities_req()
2589 p_dev_rec->sm4 &= ~BTM_SM4_UPGRADE; in btm_io_capabilities_req()
2639 tBTM_SEC_DEV_REC* p_dev_rec; in btm_io_capabilities_rsp() local
2648 p_dev_rec = btm_find_or_alloc_dev(evt_data.bd_addr); in btm_io_capabilities_rsp()
2666 memcpy(p_dev_rec->dev_class, btm_cb.connecting_dc, DEV_CLASS_LEN); in btm_io_capabilities_rsp()
2679 p_dev_rec->rmt_io_caps = evt_data.io_cap; in btm_io_capabilities_rsp()
2680 p_dev_rec->rmt_auth_req = evt_data.auth_req; in btm_io_capabilities_rsp()
2703 tBTM_SEC_DEV_REC* p_dev_rec; in btm_proc_sp_req_evt() local
2711 p_dev_rec = btm_find_dev(p_bda); in btm_proc_sp_req_evt()
2712 if ((p_dev_rec != NULL) && (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_proc_sp_req_evt()
2714 evt_data.cfm_req.bd_addr = p_dev_rec->bd_addr; in btm_proc_sp_req_evt()
2715 memcpy(evt_data.cfm_req.dev_class, p_dev_rec->dev_class, DEV_CLASS_LEN); in btm_proc_sp_req_evt()
2717 strlcpy((char*)evt_data.cfm_req.bd_name, (char*)p_dev_rec->sec_bd_name, in btm_proc_sp_req_evt()
2734 if (p_dev_rec->rmt_io_caps == BTM_IO_CAP_UNKNOWN) { in btm_proc_sp_req_evt()
2743 if ((p_dev_rec->rmt_io_caps == BTM_IO_CAP_IO) && in btm_proc_sp_req_evt()
2745 ((p_dev_rec->rmt_auth_req & BTM_AUTH_SP_YES) || in btm_proc_sp_req_evt()
2757 p_dev_rec->rmt_io_caps, btm_cb.devcb.loc_auth_req, in btm_proc_sp_req_evt()
2758 p_dev_rec->rmt_auth_req); in btm_proc_sp_req_evt()
2761 evt_data.cfm_req.rmt_auth_req = p_dev_rec->rmt_auth_req; in btm_proc_sp_req_evt()
2763 evt_data.cfm_req.rmt_io_caps = p_dev_rec->rmt_io_caps; in btm_proc_sp_req_evt()
2818 p_dev_rec = btm_find_dev(p_bda); in btm_proc_sp_req_evt()
2819 if (p_dev_rec != NULL) { in btm_proc_sp_req_evt()
2820 btm_sec_disconnect(p_dev_rec->hci_handle, HCI_ERR_AUTH_FAILURE); in btm_proc_sp_req_evt()
2839 tBTM_SEC_DEV_REC* p_dev_rec; in btm_simple_pair_complete() local
2846 p_dev_rec = btm_find_dev(bd_addr); in btm_simple_pair_complete()
2847 if (p_dev_rec == NULL) { in btm_simple_pair_complete()
2854 btm_pair_state_descr(btm_cb.pairing_state), status, p_dev_rec->sec_state); in btm_simple_pair_complete()
2857 p_dev_rec->sec_flags |= BTM_SEC_AUTHENTICATED; in btm_simple_pair_complete()
2869 if (p_dev_rec->sec_state != BTM_SEC_STATE_AUTHENTICATING) { in btm_simple_pair_complete()
2883 btm_sec_send_hci_disconnect(p_dev_rec, HCI_ERR_AUTH_FAILURE, in btm_simple_pair_complete()
2884 p_dev_rec->hci_handle); in btm_simple_pair_complete()
2901 tBTM_SEC_DEV_REC* p_dev_rec; in btm_rem_oob_req() local
2910 p_dev_rec = btm_find_dev(p_bda); in btm_rem_oob_req()
2911 if ((p_dev_rec != NULL) && btm_cb.api.p_sp_callback) { in btm_rem_oob_req()
2912 evt_data.bd_addr = p_dev_rec->bd_addr; in btm_rem_oob_req()
2913 memcpy(evt_data.dev_class, p_dev_rec->dev_class, DEV_CLASS_LEN); in btm_rem_oob_req()
2914 strlcpy((char*)evt_data.bd_name, (char*)p_dev_rec->sec_bd_name, in btm_rem_oob_req()
2971 tBTM_SEC_DEV_REC* p_dev_rec; in btm_sec_auth_collision() local
2979 p_dev_rec = btm_sec_find_dev_by_sec_state(BTM_SEC_STATE_AUTHENTICATING); in btm_sec_auth_collision()
2980 if (p_dev_rec == NULL) in btm_sec_auth_collision()
2981 p_dev_rec = btm_sec_find_dev_by_sec_state(BTM_SEC_STATE_ENCRYPTING); in btm_sec_auth_collision()
2983 p_dev_rec = btm_find_dev_by_handle(handle); in btm_sec_auth_collision()
2985 if (p_dev_rec != NULL) { in btm_sec_auth_collision()
2988 p_dev_rec->sec_state); in btm_sec_auth_collision()
2990 if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING || in btm_sec_auth_collision()
2991 p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING) in btm_sec_auth_collision()
2992 p_dev_rec->sec_state = 0; in btm_sec_auth_collision()
2994 btm_cb.p_collided_dev_rec = p_dev_rec; in btm_sec_auth_collision()
3012 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(handle); in btm_sec_auth_retry() local
3013 if (!p_dev_rec) return false; in btm_sec_auth_retry()
3016 uint8_t old_sm4 = p_dev_rec->sm4; in btm_sec_auth_retry()
3017 p_dev_rec->sm4 &= ~BTM_SM4_RETRY; in btm_sec_auth_retry()
3021 BTM_SEC_IS_SM4(p_dev_rec->sm4)) { in btm_sec_auth_retry()
3028 p_dev_rec->sm4 |= BTM_SM4_RETRY; in btm_sec_auth_retry()
3029 p_dev_rec->sec_flags &= ~BTM_SEC_LINK_KEY_KNOWN; in btm_sec_auth_retry()
3031 p_dev_rec->sm4, p_dev_rec->sec_flags); in btm_sec_auth_retry()
3037 p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; in btm_sec_auth_retry()
3038 btm_sec_execute_procedure(p_dev_rec); in btm_sec_auth_retry()
3047 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(handle); in btm_sec_auth_complete() local
3051 if (p_dev_rec) { in btm_sec_auth_complete()
3055 << "dev->sec_state:" << p_dev_rec->sec_state in btm_sec_auth_complete()
3056 << " bda:" << p_dev_rec->bd_addr in btm_sec_auth_complete()
3057 << "RName:" << p_dev_rec->sec_bd_name; in btm_sec_auth_complete()
3081 if (p_dev_rec && (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in btm_sec_auth_complete()
3083 p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE; in btm_sec_auth_complete()
3085 l2cu_start_post_bond_timer(p_dev_rec->hci_handle); in btm_sec_auth_complete()
3088 if (!p_dev_rec) return; in btm_sec_auth_complete()
3090 if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING) { in btm_sec_auth_complete()
3091 p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; in btm_sec_auth_complete()
3101 ((p_dev_rec->sec_flags & (BTM_SEC_AUTHENTICATED | BTM_SEC_ENCRYPTED)) == in btm_sec_auth_complete()
3106 p_dev_rec->sec_flags |= BTM_SEC_AUTHENTICATED; in btm_sec_auth_complete()
3111 (p_dev_rec->bd_addr == btm_cb.pairing_bda)) { in btm_sec_auth_complete()
3120 NotifyBondingChange(*p_dev_rec, status); in btm_sec_auth_complete()
3130 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_auth_complete()
3131 p_dev_rec->dev_class, in btm_sec_auth_complete()
3132 p_dev_rec->sec_bd_name, status); in btm_sec_auth_complete()
3137 p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE; in btm_sec_auth_complete()
3142 btm_sec_send_hci_disconnect(p_dev_rec, HCI_ERR_PEER_USER, in btm_sec_auth_complete()
3143 p_dev_rec->hci_handle); in btm_sec_auth_complete()
3145 BTM_LogHistory(kBtmLogTag, p_dev_rec->bd_addr, "Bonding completed", in btm_sec_auth_complete()
3148 if (p_dev_rec->new_encryption_key_is_p256 && in btm_sec_auth_complete()
3149 (btm_sec_use_smp_br_chnl(p_dev_rec)) in btm_sec_auth_complete()
3151 && (!(p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN) || in btm_sec_auth_complete()
3153 (!(p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_AUTHED) && in btm_sec_auth_complete()
3154 (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_AUTHED)))) { in btm_sec_auth_complete()
3159 BTM_GetRole(p_dev_rec->bd_addr, &role); in btm_sec_auth_complete()
3163 BTM_SetEncryption(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR, NULL, NULL, in btm_sec_auth_complete()
3167 l2cu_start_post_bond_timer(p_dev_rec->hci_handle); in btm_sec_auth_complete()
3175 btm_sec_dev_rec_cback_event(p_dev_rec, BTM_ERR_PROCESSING, false); in btm_sec_auth_complete()
3178 btm_sec_send_hci_disconnect(p_dev_rec, HCI_ERR_AUTH_FAILURE, in btm_sec_auth_complete()
3179 p_dev_rec->hci_handle); in btm_sec_auth_complete()
3184 if (p_dev_rec->pin_code_length >= 16 || in btm_sec_auth_complete()
3185 p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB || in btm_sec_auth_complete()
3186 p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB_P_256) { in btm_sec_auth_complete()
3189 p_dev_rec->sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED; in btm_sec_auth_complete()
3193 tBTM_STATUS btm_status = btm_sec_execute_procedure(p_dev_rec); in btm_sec_auth_complete()
3198 btm_sec_dev_rec_cback_event(p_dev_rec, btm_status, false); in btm_sec_auth_complete()
3213 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(handle); in btm_sec_encrypt_change() local
3216 status, (p_dev_rec) ? p_dev_rec->sec_state : 0, encr_enable); in btm_sec_encrypt_change()
3218 (p_dev_rec) ? p_dev_rec->sec_flags : 0); in btm_sec_encrypt_change()
3229 if (!p_dev_rec) return; in btm_sec_encrypt_change()
3232 if (p_dev_rec->hci_handle == handle) { in btm_sec_encrypt_change()
3233 p_dev_rec->sec_flags |= (BTM_SEC_AUTHENTICATED | BTM_SEC_ENCRYPTED); in btm_sec_encrypt_change()
3234 if (p_dev_rec->pin_code_length >= 16 || in btm_sec_encrypt_change()
3235 p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB || in btm_sec_encrypt_change()
3236 p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB_P_256) { in btm_sec_encrypt_change()
3237 p_dev_rec->sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED; in btm_sec_encrypt_change()
3240 p_dev_rec->sec_flags |= (BTM_SEC_LE_AUTHENTICATED | BTM_SEC_LE_ENCRYPTED); in btm_sec_encrypt_change()
3248 if (p_dev_rec->hci_handle == handle) in btm_sec_encrypt_change()
3249 p_dev_rec->sec_flags &= ~BTM_SEC_ENCRYPTED; in btm_sec_encrypt_change()
3251 p_dev_rec->sec_flags &= ~BTM_SEC_LE_ENCRYPTED; in btm_sec_encrypt_change()
3255 p_dev_rec->sec_flags); in btm_sec_encrypt_change()
3259 btm_sec_check_pending_enc_req(p_dev_rec, transport, encr_enable); in btm_sec_encrypt_change()
3264 p_dev_rec->sec_flags &= ~(BTM_SEC_LE_LINK_KEY_KNOWN); in btm_sec_encrypt_change()
3265 p_dev_rec->ble.key_type = BTM_LE_KEY_NONE; in btm_sec_encrypt_change()
3267 btm_ble_link_encrypted(p_dev_rec->ble.pseudo_addr, encr_enable); in btm_sec_encrypt_change()
3271 p_dev_rec->enc_key_size = 16; in btm_sec_encrypt_change()
3275 p_dev_rec->new_encryption_key_is_p256); in btm_sec_encrypt_change()
3278 (p_dev_rec->hci_handle == handle)) { in btm_sec_encrypt_change()
3281 if (p_dev_rec->rmt_auth_req == BTM_AUTH_SP_NO && in btm_sec_encrypt_change()
3288 BTM_GetRole(p_dev_rec->bd_addr, &role); in btm_sec_encrypt_change()
3289 if (p_dev_rec->new_encryption_key_is_p256) { in btm_sec_encrypt_change()
3290 if (btm_sec_use_smp_br_chnl(p_dev_rec) && role == HCI_ROLE_CENTRAL && in btm_sec_encrypt_change()
3292 (!(p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN) || in btm_sec_encrypt_change()
3294 (!(p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_AUTHED) && in btm_sec_encrypt_change()
3295 (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_AUTHED))) && in btm_sec_encrypt_change()
3298 p_dev_rec->new_encryption_key_is_p256 = false; in btm_sec_encrypt_change()
3301 SMP_BR_PairWith(p_dev_rec->bd_addr); in btm_sec_encrypt_change()
3308 (p_dev_rec->link_key_type == BTM_LKEY_TYPE_UNAUTH_COMB_P_256 || in btm_sec_encrypt_change()
3309 p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB_P_256)) { in btm_sec_encrypt_change()
3310 if (p_dev_rec->link_key_type == BTM_LKEY_TYPE_UNAUTH_COMB_P_256) in btm_sec_encrypt_change()
3311 p_dev_rec->link_key_type = BTM_LKEY_TYPE_UNAUTH_COMB; in btm_sec_encrypt_change()
3313 p_dev_rec->link_key_type = BTM_LKEY_TYPE_AUTH_COMB; in btm_sec_encrypt_change()
3316 p_dev_rec->link_key_type); in btm_sec_encrypt_change()
3317 btm_send_link_key_notif(p_dev_rec); in btm_sec_encrypt_change()
3323 if (p_dev_rec->sec_state != BTM_SEC_STATE_ENCRYPTING) { in btm_sec_encrypt_change()
3324 if (BTM_SEC_STATE_DELAY_FOR_ENC == p_dev_rec->sec_state) { in btm_sec_encrypt_change()
3325 p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; in btm_sec_encrypt_change()
3327 __func__, p_dev_rec, p_dev_rec->p_callback); in btm_sec_encrypt_change()
3328 p_dev_rec->p_callback = NULL; in btm_sec_encrypt_change()
3329 l2cu_resubmit_pending_sec_req(&p_dev_rec->bd_addr); in btm_sec_encrypt_change()
3334 p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; in btm_sec_encrypt_change()
3337 btm_sec_dev_rec_cback_event(p_dev_rec, BTM_ERR_PROCESSING, false); in btm_sec_encrypt_change()
3342 tBTM_STATUS btm_status = btm_sec_execute_procedure(p_dev_rec); in btm_sec_encrypt_change()
3346 btm_sec_dev_rec_cback_event(p_dev_rec, btm_status, false); in btm_sec_encrypt_change()
3360 tBTM_SEC_DEV_REC* p_dev_rec = btm_cb.p_collided_dev_rec; in btm_sec_connect_after_reject_timeout() local
3365 if (btm_sec_dd_create_conn(p_dev_rec) != BTM_CMD_STARTED) { in btm_sec_connect_after_reject_timeout()
3371 NotifyBondingChange(*p_dev_rec, HCI_ERR_MEMORY_FULL); in btm_sec_connect_after_reject_timeout()
3388 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bda); in btm_sec_connected() local
3396 if (!p_dev_rec) { in btm_sec_connected()
3404 p_dev_rec = btm_sec_alloc_dev(bda); in btm_sec_connected()
3428 p_dev_rec->sec_bd_name); in btm_sec_connected()
3430 bit_shift = (handle == p_dev_rec->ble_hci_handle) ? 8 : 0; in btm_sec_connected()
3431 p_dev_rec->timestamp = btm_cb.dev_rec_count++; in btm_sec_connected()
3432 if (p_dev_rec->sm4 & BTM_SM4_CONN_PEND) { in btm_sec_connected()
3435 (btm_cb.pairing_bda == p_dev_rec->bd_addr) && in btm_sec_connected()
3446 p_dev_rec->sm4 &= ~BTM_SM4_CONN_PEND; in btm_sec_connected()
3447 if (p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) { in btm_sec_connected()
3450 btm_cb.p_collided_dev_rec = p_dev_rec; in btm_sec_connected()
3455 if (BTM_ReadRemoteDeviceName(p_dev_rec->bd_addr, NULL, in btm_sec_connected()
3464 l2cu_update_lcb_4_bonding(p_dev_rec->bd_addr, true); in btm_sec_connected()
3468 p_dev_rec->sm4 &= ~BTM_SM4_CONN_PEND; in btm_sec_connected()
3472 p_dev_rec->device_type |= BT_DEVICE_TYPE_BREDR; in btm_sec_connected()
3483 btm_cb.pairing_flags, p_dev_rec->sm4); in btm_sec_connected()
3486 if (BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4)) { in btm_sec_connected()
3501 btm_cb.p_collided_dev_rec = p_dev_rec; in btm_sec_connected()
3525 p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE; in btm_sec_connected()
3526 p_dev_rec->sec_flags &= in btm_sec_connected()
3528 BTM_TRACE_DEBUG("security_required:%x ", p_dev_rec->security_required); in btm_sec_connected()
3533 NotifyBondingChange(*p_dev_rec, status); in btm_sec_connected()
3541 else if ((p_dev_rec->link_key_type <= BTM_LKEY_TYPE_REMOTE_UNIT) && in btm_sec_connected()
3550 p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE; in btm_sec_connected()
3551 p_dev_rec->sec_flags &= ~(BTM_SEC_LE_LINK_KEY_KNOWN << bit_shift); in btm_sec_connected()
3561 NotifyBondingChange(*p_dev_rec, status); in btm_sec_connected()
3566 p_dev_rec = btm_find_dev(bda); in btm_sec_connected()
3567 if (!p_dev_rec) { in btm_sec_connected()
3579 btm_sec_dev_rec_cback_event(p_dev_rec, BTM_DEVICE_TIMEOUT, false); in btm_sec_connected()
3581 btm_sec_dev_rec_cback_event(p_dev_rec, BTM_ERR_PROCESSING, false); in btm_sec_connected()
3589 if (is_pairing_device && (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN)) { in btm_sec_connected()
3590 if (p_dev_rec->link_key_not_sent) { in btm_sec_connected()
3591 p_dev_rec->link_key_not_sent = false; in btm_sec_connected()
3592 btm_send_link_key_notif(p_dev_rec); in btm_sec_connected()
3595 p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE; in btm_sec_connected()
3608 l2cu_update_lcb_4_bonding(p_dev_rec->bd_addr, true); in btm_sec_connected()
3614 p_dev_rec->hci_handle = handle; in btm_sec_connected()
3631 p_dev_rec->sec_flags &= in btm_sec_connected()
3636 p_dev_rec->sec_flags |= in btm_sec_connected()
3639 if (p_dev_rec->pin_code_length >= 16 || in btm_sec_connected()
3640 p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB || in btm_sec_connected()
3641 p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB_P_256) { in btm_sec_connected()
3642 p_dev_rec->sec_flags |= (BTM_SEC_16_DIGIT_PIN_AUTHED << bit_shift); in btm_sec_connected()
3649 logbool(p_dev_rec->is_originator).c_str()); in btm_sec_connected()
3650 if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) || in btm_sec_connected()
3651 p_dev_rec->is_originator) { in btm_sec_connected()
3652 res = btm_sec_execute_procedure(p_dev_rec); in btm_sec_connected()
3654 btm_sec_dev_rec_cback_event(p_dev_rec, res, false); in btm_sec_connected()
3660 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(handle); in btm_sec_disconnect() local
3663 if (!p_dev_rec) { in btm_sec_disconnect()
3671 (btm_cb.pairing_bda == p_dev_rec->bd_addr) && in btm_sec_disconnect()
3678 return (btm_sec_send_hci_disconnect(p_dev_rec, reason, handle)); in btm_sec_disconnect()
3690 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(handle); in btm_sec_disconnected() local
3691 if (p_dev_rec == nullptr) { in btm_sec_disconnected()
3697 (handle == p_dev_rec->hci_handle) ? BT_TRANSPORT_BR_EDR : BT_TRANSPORT_LE; in btm_sec_disconnected()
3700 p_dev_rec->sm4 &= BTM_SM4_TRUE; in btm_sec_disconnected()
3706 (btm_cb.pairing_bda == p_dev_rec->bd_addr)) { in btm_sec_disconnected()
3710 p_dev_rec->sec_flags &= ~BTM_SEC_LINK_KEY_KNOWN; in btm_sec_disconnected()
3722 NotifyBondingChange(*p_dev_rec, status); in btm_sec_disconnected()
3724 p_dev_rec = btm_find_dev_by_handle(handle); in btm_sec_disconnected()
3725 if (p_dev_rec == nullptr) { in btm_sec_disconnected()
3735 PRIVATE_ADDRESS(p_dev_rec->bd_addr), p_dev_rec->sec_bd_name, in btm_sec_disconnected()
3737 hci_reason_code_text(reason).c_str(), p_dev_rec->security_required); in btm_sec_disconnected()
3740 btm_ble_update_mode_operation(HCI_ROLE_UNKNOWN, &p_dev_rec->bd_addr, in btm_sec_disconnected()
3745 p_dev_rec->ble_hci_handle = HCI_INVALID_HANDLE; in btm_sec_disconnected()
3746 p_dev_rec->sec_flags &= ~(BTM_SEC_LE_AUTHENTICATED | BTM_SEC_LE_ENCRYPTED | in btm_sec_disconnected()
3748 p_dev_rec->enc_key_size = 0; in btm_sec_disconnected()
3750 if ((p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN) == 0) { in btm_sec_disconnected()
3751 p_dev_rec->sec_flags &= in btm_sec_disconnected()
3757 if (!p_dev_rec->IsLocallyInitiated()) { in btm_sec_disconnected()
3761 p_dev_rec->hci_handle = HCI_INVALID_HANDLE; in btm_sec_disconnected()
3762 p_dev_rec->sec_flags &= in btm_sec_disconnected()
3767 if (p_dev_rec->bond_type == tBTM_SEC_DEV_REC::BOND_TYPE_TEMPORARY) in btm_sec_disconnected()
3768 p_dev_rec->sec_flags &= ~(BTM_SEC_LINK_KEY_KNOWN); in btm_sec_disconnected()
3775 if (is_sample_ltk(p_dev_rec->ble.keys.pltk)) { in btm_sec_disconnected()
3778 << p_dev_rec->bd_addr; in btm_sec_disconnected()
3780 bta_dm_remove_device(p_dev_rec->bd_addr); in btm_sec_disconnected()
3784 if (p_dev_rec->sec_state == BTM_SEC_STATE_DISCONNECTING_BOTH) { in btm_sec_disconnected()
3787 p_dev_rec->sec_state = (transport == BT_TRANSPORT_LE) in btm_sec_disconnected()
3792 p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; in btm_sec_disconnected()
3793 p_dev_rec->security_required = BTM_SEC_NONE; in btm_sec_disconnected()
3795 if (p_dev_rec->p_callback != nullptr) { in btm_sec_disconnected()
3796 tBTM_SEC_CALLBACK* p_callback = p_dev_rec->p_callback; in btm_sec_disconnected()
3799 p_dev_rec->p_callback = nullptr; in btm_sec_disconnected()
3800 (*p_callback)(&p_dev_rec->bd_addr, transport, p_dev_rec->p_ref_data, in btm_sec_disconnected()
3803 PRIVATE_ADDRESS(p_dev_rec->bd_addr), in btm_sec_disconnected()
3811 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(p_bda); in btm_sec_link_key_notification() local
3827 p_dev_rec->link_key_type = key_type; in btm_sec_link_key_notification()
3829 p_dev_rec->sec_flags |= BTM_SEC_LINK_KEY_KNOWN; in btm_sec_link_key_notification()
3835 if (p_dev_rec->pin_code_length >= 16 || in btm_sec_link_key_notification()
3836 p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB || in btm_sec_link_key_notification()
3837 p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB_P_256) { in btm_sec_link_key_notification()
3838 p_dev_rec->sec_flags |= BTM_SEC_LINK_KEY_AUTHED; in btm_sec_link_key_notification()
3839 p_dev_rec->sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED; in btm_sec_link_key_notification()
3843 p_dev_rec->enc_key_size = 16; in btm_sec_link_key_notification()
3844 p_dev_rec->link_key = link_key; in btm_sec_link_key_notification()
3858 p_dev_rec->link_key_type); in btm_sec_link_key_notification()
3859 (*btm_cb.api.p_link_key_callback)(p_bda, p_dev_rec->dev_class, in btm_sec_link_key_notification()
3860 p_dev_rec->sec_bd_name, link_key, in btm_sec_link_key_notification()
3861 p_dev_rec->link_key_type); in btm_sec_link_key_notification()
3864 if ((p_dev_rec->link_key_type == BTM_LKEY_TYPE_UNAUTH_COMB_P_256) || in btm_sec_link_key_notification()
3865 (p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB_P_256)) { in btm_sec_link_key_notification()
3866 p_dev_rec->new_encryption_key_is_p256 = true; in btm_sec_link_key_notification()
3868 p_dev_rec->new_encryption_key_is_p256); in btm_sec_link_key_notification()
3876 if ((!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) && in btm_sec_link_key_notification()
3877 ((p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK) != in btm_sec_link_key_notification()
3882 p_dev_rec->link_key_not_sent = true; in btm_sec_link_key_notification()
3891 p_dev_rec->rmt_io_caps, p_dev_rec->sec_flags, in btm_sec_link_key_notification()
3892 p_dev_rec->dev_class[1]) in btm_sec_link_key_notification()
3899 if (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_AUTHED) in btm_sec_link_key_notification()
3907 p_dev_rec->link_key_type); in btm_sec_link_key_notification()
3909 (*btm_cb.api.p_link_key_callback)(p_bda, p_dev_rec->dev_class, in btm_sec_link_key_notification()
3910 p_dev_rec->sec_bd_name, link_key, in btm_sec_link_key_notification()
3911 p_dev_rec->link_key_type); in btm_sec_link_key_notification()
3930 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(bda); in btm_sec_link_key_request() local
3944 if (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN) { in btm_sec_link_key_request()
3945 btsnd_hcic_link_key_req_reply(bda, p_dev_rec->link_key); in btm_sec_link_key_request()
3968 tBTM_SEC_DEV_REC* p_dev_rec; in btm_sec_pairing_timeout() local
3974 p_dev_rec = btm_find_dev(p_cb->pairing_bda); in btm_sec_pairing_timeout()
3991 if (p_dev_rec == NULL) { in btm_sec_pairing_timeout()
3996 NotifyBondingChange(*p_dev_rec, HCI_ERR_CONNECTION_TOUT); in btm_sec_pairing_timeout()
4029 if (p_dev_rec == NULL) { in btm_sec_pairing_timeout()
4035 btm_sec_send_hci_disconnect(p_dev_rec, HCI_ERR_AUTH_FAILURE, in btm_sec_pairing_timeout()
4036 p_dev_rec->hci_handle); in btm_sec_pairing_timeout()
4046 if (p_dev_rec == NULL) { in btm_sec_pairing_timeout()
4051 NotifyBondingChange(*p_dev_rec, HCI_ERR_CONNECTION_TOUT); in btm_sec_pairing_timeout()
4074 tBTM_SEC_DEV_REC* p_dev_rec; in btm_sec_pin_code_request() local
4108 p_dev_rec = btm_find_or_alloc_dev(p_bda); in btm_sec_pin_code_request()
4110 p_dev_rec->sm4 = BTM_SM4_KNOWN; in btm_sec_pin_code_request()
4130 memcpy(p_dev_rec->dev_class, p_cb->connecting_dc, DEV_CLASS_LEN); in btm_sec_pin_code_request()
4159 || (!p_dev_rec->IsLocallyInitiated() && in btm_sec_pin_code_request()
4160 ((p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK) == in btm_sec_pin_code_request()
4162 (p_dev_rec->dev_class[2] & BTM_COD_MINOR_KEYBOARD))) { in btm_sec_pin_code_request()
4166 p_cb->pairing_disabled, p_cb->api.p_pin_callback, p_dev_rec); in btm_sec_pin_code_request()
4175 memcpy(p_cb->connecting_dc, p_dev_rec->dev_class, DEV_CLASS_LEN); in btm_sec_pin_code_request()
4183 if (p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) { in btm_sec_pin_code_request()
4189 p_bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, in btm_sec_pin_code_request()
4190 (p_dev_rec->required_security_flags_for_pairing & in btm_sec_pin_code_request()
4199 SendRemoteNameRequest(p_dev_rec->bd_addr); in btm_sec_pin_code_request()
4216 tBTM_SEC_DEV_REC* p_dev_rec; in btm_sec_update_clock_offset() local
4219 p_dev_rec = btm_find_dev_by_handle(handle); in btm_sec_update_clock_offset()
4220 if (p_dev_rec == NULL) return; in btm_sec_update_clock_offset()
4222 p_dev_rec->clock_offset = clock_offset | BTM_CLOCK_OFFSET_VALID; in btm_sec_update_clock_offset()
4224 p_inq_info = BTM_InqDbRead(p_dev_rec->bd_addr); in btm_sec_update_clock_offset()
4231 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(remote_bda); in BTM_GetClockOffset() local
4232 return (p_dev_rec) ? p_dev_rec->clock_offset : 0; in BTM_GetClockOffset()
4254 tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_sec_execute_procedure() argument
4255 CHECK(p_dev_rec != nullptr); in btm_sec_execute_procedure()
4258 p_dev_rec->security_required, p_dev_rec->sec_flags, in btm_sec_execute_procedure()
4259 security_state_text(static_cast<tSECURITY_STATE>(p_dev_rec->sec_state)) in btm_sec_execute_procedure()
4261 p_dev_rec->sec_state); in btm_sec_execute_procedure()
4263 if (p_dev_rec->sec_state != BTM_SEC_STATE_IDLE) { in btm_sec_execute_procedure()
4271 HACK_acl_check_sm4(*p_dev_rec); in btm_sec_execute_procedure()
4275 if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) && in btm_sec_execute_procedure()
4276 (p_dev_rec->hci_handle != HCI_INVALID_HANDLE)) { in btm_sec_execute_procedure()
4278 if (!btm_sec_start_get_name(p_dev_rec)) { in btm_sec_execute_procedure()
4287 if ((((!(p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED)) && in btm_sec_execute_procedure()
4288 ((p_dev_rec->IsLocallyInitiated() && in btm_sec_execute_procedure()
4289 (p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE)) || in btm_sec_execute_procedure()
4290 (!p_dev_rec->IsLocallyInitiated() && in btm_sec_execute_procedure()
4291 (p_dev_rec->security_required & BTM_SEC_IN_AUTHENTICATE)))) || in btm_sec_execute_procedure()
4292 (!(p_dev_rec->sec_flags & BTM_SEC_16_DIGIT_PIN_AUTHED) && in btm_sec_execute_procedure()
4293 (!p_dev_rec->IsLocallyInitiated() && in btm_sec_execute_procedure()
4294 (p_dev_rec->security_required & BTM_SEC_IN_MIN_16_DIGIT_PIN)))) && in btm_sec_execute_procedure()
4295 (p_dev_rec->hci_handle != HCI_INVALID_HANDLE)) { in btm_sec_execute_procedure()
4316 if ((p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN) && in btm_sec_execute_procedure()
4317 (!(p_dev_rec->sec_flags & BTM_SEC_16_DIGIT_PIN_AUTHED) && in btm_sec_execute_procedure()
4318 (!p_dev_rec->IsLocallyInitiated() && in btm_sec_execute_procedure()
4319 (p_dev_rec->security_required & BTM_SEC_IN_MIN_16_DIGIT_PIN)))) { in btm_sec_execute_procedure()
4320 p_dev_rec->sec_flags &= in btm_sec_execute_procedure()
4325 btm_sec_start_authentication(p_dev_rec); in btm_sec_execute_procedure()
4333 if (!(p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED) && in btm_sec_execute_procedure()
4334 ((p_dev_rec->IsLocallyInitiated() && in btm_sec_execute_procedure()
4335 (p_dev_rec->security_required & BTM_SEC_OUT_ENCRYPT)) || in btm_sec_execute_procedure()
4336 (!p_dev_rec->IsLocallyInitiated() && in btm_sec_execute_procedure()
4337 (p_dev_rec->security_required & BTM_SEC_IN_ENCRYPT))) && in btm_sec_execute_procedure()
4338 (p_dev_rec->hci_handle != HCI_INVALID_HANDLE)) { in btm_sec_execute_procedure()
4341 btsnd_hcic_set_conn_encrypt(p_dev_rec->hci_handle, true); in btm_sec_execute_procedure()
4342 p_dev_rec->sec_state = BTM_SEC_STATE_ENCRYPTING; in btm_sec_execute_procedure()
4348 if ((p_dev_rec->security_required & BTM_SEC_MODE4_LEVEL4) && in btm_sec_execute_procedure()
4349 (p_dev_rec->link_key_type != BTM_LKEY_TYPE_AUTH_COMB_P_256)) { in btm_sec_execute_procedure()
4352 "security failure", __func__, p_dev_rec->link_key_type); in btm_sec_execute_procedure()
4357 p_dev_rec->security_required &= in btm_sec_execute_procedure()
4375 static bool btm_sec_start_get_name(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_sec_start_get_name() argument
4378 p_dev_rec->sec_state = BTM_SEC_STATE_GETTING_NAME; in btm_sec_start_get_name()
4382 SendRemoteNameRequest(p_dev_rec->bd_addr); in btm_sec_start_get_name()
4393 static void btm_sec_start_authentication(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_sec_start_authentication() argument
4394 p_dev_rec->sec_state = BTM_SEC_STATE_AUTHENTICATING; in btm_sec_start_authentication()
4395 btsnd_hcic_auth_request(p_dev_rec->hci_handle); in btm_sec_start_authentication()
4459 static void btm_send_link_key_notif(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_send_link_key_notif() argument
4462 p_dev_rec->bd_addr, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, in btm_send_link_key_notif()
4463 p_dev_rec->link_key, p_dev_rec->link_key_type); in btm_send_link_key_notif()
4490 tBTM_SEC_DEV_REC* p_dev_rec = static_cast<tBTM_SEC_DEV_REC*>(data); in is_sec_state_equal() local
4493 if (p_dev_rec->sec_state == *state) return false; in is_sec_state_equal()
4605 void btm_sec_dev_rec_cback_event(tBTM_SEC_DEV_REC* p_dev_rec, in btm_sec_dev_rec_cback_event() argument
4607 ASSERT(p_dev_rec != nullptr); in btm_sec_dev_rec_cback_event()
4611 tBTM_SEC_CALLBACK* p_callback = p_dev_rec->p_callback; in btm_sec_dev_rec_cback_event()
4612 p_dev_rec->p_callback = NULL; in btm_sec_dev_rec_cback_event()
4615 (*p_callback)(&p_dev_rec->ble.pseudo_addr, BT_TRANSPORT_LE, in btm_sec_dev_rec_cback_event()
4616 p_dev_rec->p_ref_data, btm_status); in btm_sec_dev_rec_cback_event()
4618 (*p_callback)(&p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR, in btm_sec_dev_rec_cback_event()
4619 p_dev_rec->p_ref_data, btm_status); in btm_sec_dev_rec_cback_event()
4668 static bool btm_sec_check_prefetch_pin(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_sec_check_prefetch_pin() argument
4669 uint8_t major = (uint8_t)(p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK); in btm_sec_check_prefetch_pin()
4670 uint8_t minor = (uint8_t)(p_dev_rec->dev_class[2] & BTM_COD_MINOR_CLASS_MASK); in btm_sec_check_prefetch_pin()
4690 BTM_PINCodeReply(p_dev_rec->bd_addr, BTM_SUCCESS, btm_cb.pin_code_len, in btm_sec_check_prefetch_pin()
4697 if (BTM_IsAclConnectionUp(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR)) in btm_sec_check_prefetch_pin()
4700 p_dev_rec->bd_addr, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, in btm_sec_check_prefetch_pin()
4701 (p_dev_rec->required_security_flags_for_pairing & in btm_sec_check_prefetch_pin()
4749 static void btm_sec_check_pending_enc_req(tBTM_SEC_DEV_REC* p_dev_rec, in btm_sec_check_pending_enc_req() argument
4760 if (p_e->bd_addr == p_dev_rec->bd_addr && p_e->psm == 0 && in btm_sec_check_pending_enc_req()
4766 p_dev_rec->sec_flags & BTM_SEC_LE_AUTHENTICATED)) { in btm_sec_check_pending_enc_req()
4768 (*p_e->p_callback)(&p_dev_rec->bd_addr, transport, p_e->p_ref_data, in btm_sec_check_pending_enc_req()
4806 void btm_sec_clear_ble_keys(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_sec_clear_ble_keys() argument
4808 p_dev_rec->ble.key_type = BTM_LE_KEY_NONE; in btm_sec_clear_ble_keys()
4809 memset(&p_dev_rec->ble.keys, 0, sizeof(tBTM_SEC_BLE_KEYS)); in btm_sec_clear_ble_keys()
4811 btm_ble_resolving_list_remove_dev(p_dev_rec); in btm_sec_clear_ble_keys()
4824 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bda); in btm_sec_is_a_bonded_dev() local
4827 if (p_dev_rec && ((p_dev_rec->ble.key_type && in btm_sec_is_a_bonded_dev()
4828 (p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN)) || in btm_sec_is_a_bonded_dev()
4829 (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN))) { in btm_sec_is_a_bonded_dev()
4851 static bool btm_sec_use_smp_br_chnl(tBTM_SEC_DEV_REC* p_dev_rec) { in btm_sec_use_smp_br_chnl() argument
4856 p_dev_rec->link_key_type); in btm_sec_use_smp_br_chnl()
4858 if ((p_dev_rec->link_key_type != BTM_LKEY_TYPE_UNAUTH_COMB_P_256) && in btm_sec_use_smp_br_chnl()
4859 (p_dev_rec->link_key_type != BTM_LKEY_TYPE_AUTH_COMB_P_256)) in btm_sec_use_smp_br_chnl()
4862 if (!L2CA_GetPeerFeatures(p_dev_rec->bd_addr, &ext_feat, chnl_mask)) in btm_sec_use_smp_br_chnl()
4884 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(hci_handle); in btm_sec_set_peer_sec_caps() local
4885 if (p_dev_rec == nullptr) return; in btm_sec_set_peer_sec_caps()
4887 p_dev_rec->remote_feature_received = true; in btm_sec_set_peer_sec_caps()
4888 p_dev_rec->remote_supports_hci_role_switch = hci_role_switch_supported; in btm_sec_set_peer_sec_caps()
4890 uint8_t req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND); in btm_sec_set_peer_sec_caps()
4892 if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) || in btm_sec_set_peer_sec_caps()
4893 p_dev_rec->is_originator) { in btm_sec_set_peer_sec_caps()
4894 tBTM_STATUS btm_status = btm_sec_execute_procedure(p_dev_rec); in btm_sec_set_peer_sec_caps()
4898 btm_sec_dev_rec_cback_event(p_dev_rec, btm_status, false); in btm_sec_set_peer_sec_caps()
4906 p_dev_rec->sm4 = BTM_SM4_TRUE; in btm_sec_set_peer_sec_caps()
4907 p_dev_rec->remote_supports_secure_connections = sc_supported; in btm_sec_set_peer_sec_caps()
4909 p_dev_rec->sm4 = BTM_SM4_KNOWN; in btm_sec_set_peer_sec_caps()
4910 p_dev_rec->remote_supports_secure_connections = false; in btm_sec_set_peer_sec_caps()
4913 if (p_dev_rec->remote_features_needed) { in btm_sec_set_peer_sec_caps()
4915 btm_io_capabilities_req(p_dev_rec->bd_addr); in btm_sec_set_peer_sec_caps()
4916 p_dev_rec->remote_features_needed = false; in btm_sec_set_peer_sec_caps()
4921 l2cu_resubmit_pending_sec_req(&p_dev_rec->bd_addr); in btm_sec_set_peer_sec_caps()
4924 p_dev_rec->remote_supports_bredr = br_edr_supported; in btm_sec_set_peer_sec_caps()
4925 p_dev_rec->remote_supports_ble = le_supported; in btm_sec_set_peer_sec_caps()
4930 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(bda); in btm_get_dev_class() local
4931 return p_dev_rec->dev_class; in btm_get_dev_class()
4936 tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); in BTM_update_version_info() local
4937 if (p_dev_rec == NULL) return; in BTM_update_version_info()
4939 p_dev_rec->remote_version_info = remote_version_info; in BTM_update_version_info()