|
|
@@ -3932,10 +3932,11 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
|
|
|
(BTM_SEC_AUTHENTICATED | BTM_SEC_ENCRYPTED))) {
|
|
|
status = HCI_SUCCESS;
|
|
|
}
|
|
|
+
|
|
|
/* Currently we do not notify user if it is a keyboard which connects */
|
|
|
- /* User probably Disabled the keyboard while it was asleap. Let her try */
|
|
|
+ /* User probably Disabled the keyboard while it was asleep. Let her try */
|
|
|
if (btm_cb.api.p_auth_complete_callback) {
|
|
|
- /* report the suthentication status */
|
|
|
+ /* report the authentication status */
|
|
|
if (old_state != BTM_PAIR_STATE_IDLE) {
|
|
|
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
|
|
p_dev_rec->dev_class,
|
|
|
@@ -3945,6 +3946,9 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
|
|
|
|
|
|
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
|
|
|
|
|
|
+#if (CLASSIC_BT_INCLUDED == TRUE)
|
|
|
+ btm_sec_update_legacy_auth_state(btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR), BTM_ACL_LEGACY_AUTH_SELF);
|
|
|
+#endif
|
|
|
/* If this is a bonding procedure can disconnect the link now */
|
|
|
if (are_bonding) {
|
|
|
p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE;
|
|
|
@@ -4674,12 +4678,24 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
|
|
|
/* If connection was made to do bonding restore link security if changed */
|
|
|
btm_restore_mode();
|
|
|
|
|
|
+ /* Store the previous state of secure connection as current state. Since
|
|
|
+ * this is the first encounter with the remote device, whatever the remote
|
|
|
+ * device's SC state is, it cannot lower the SC level from this. */
|
|
|
+ p_dev_rec->remote_secure_connection_previous_state = p_dev_rec->remote_supports_secure_connections;
|
|
|
+ if (p_dev_rec->remote_supports_secure_connections) {
|
|
|
+ BTM_TRACE_EVENT ("Remote device supports Secure Connection");
|
|
|
+ } else {
|
|
|
+ BTM_TRACE_EVENT ("Remote device does not support Secure Connection");
|
|
|
+ }
|
|
|
if (key_type != BTM_LKEY_TYPE_CHANGED_COMB) {
|
|
|
p_dev_rec->link_key_type = key_type;
|
|
|
}
|
|
|
|
|
|
p_dev_rec->sec_flags |= BTM_SEC_LINK_KEY_KNOWN;
|
|
|
|
|
|
+#if (CLASSIC_BT_INCLUDED == TRUE)
|
|
|
+ btm_sec_update_legacy_auth_state(btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR), BTM_ACL_LEGACY_AUTH_NONE);
|
|
|
+#endif
|
|
|
/*
|
|
|
* Until this point in time, we do not know if MITM was enabled, hence we
|
|
|
* add the extended security flag here.
|
|
|
@@ -4712,7 +4728,8 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
|
|
|
__FUNCTION__, p_dev_rec->link_key_type);
|
|
|
(*btm_cb.api.p_link_key_callback) (p_bda, p_dev_rec->dev_class,
|
|
|
p_dev_rec->sec_bd_name,
|
|
|
- p_link_key, p_dev_rec->link_key_type);
|
|
|
+ p_link_key, p_dev_rec->link_key_type,
|
|
|
+ p_dev_rec->remote_supports_secure_connections);
|
|
|
}
|
|
|
} else {
|
|
|
if ((p_dev_rec->link_key_type == BTM_LKEY_TYPE_UNAUTH_COMB_P_256) ||
|
|
|
@@ -4769,7 +4786,8 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
|
|
|
} else {
|
|
|
(*btm_cb.api.p_link_key_callback) (p_bda, p_dev_rec->dev_class,
|
|
|
p_dev_rec->sec_bd_name,
|
|
|
- p_link_key, p_dev_rec->link_key_type);
|
|
|
+ p_link_key, p_dev_rec->link_key_type,
|
|
|
+ p_dev_rec->remote_supports_secure_connections);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -5562,7 +5580,9 @@ static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec)
|
|
|
if (btm_cb.api.p_link_key_callback) {
|
|
|
(*btm_cb.api.p_link_key_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
|
|
p_dev_rec->sec_bd_name, p_dev_rec->link_key,
|
|
|
- p_dev_rec->link_key_type);
|
|
|
+ p_dev_rec->link_key_type,
|
|
|
+ p_dev_rec->remote_supports_secure_connections);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
#endif ///SMP_INCLUDED == TRUE
|
|
|
@@ -5920,6 +5940,29 @@ void btm_sec_set_peer_sec_caps(tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec)
|
|
|
BTM_TRACE_API("%s: sm4: 0x%02x, rmt_support_for_secure_connections %d\n", __FUNCTION__,
|
|
|
p_dev_rec->sm4, p_dev_rec->remote_supports_secure_connections);
|
|
|
|
|
|
+ /* Store previous state of remote device to check if peer device downgraded
|
|
|
+ * it's secure connection state. */
|
|
|
+#if (CLASSIC_BT_INCLUDED == TRUE)
|
|
|
+ if (p_dev_rec->remote_supports_secure_connections >= p_dev_rec->remote_secure_connection_previous_state) {
|
|
|
+ p_dev_rec->remote_secure_connection_previous_state = p_dev_rec->remote_supports_secure_connections;
|
|
|
+ } else {
|
|
|
+ BTM_TRACE_ERROR("Remote Device downgraded security from SC, deleting Link Key");
|
|
|
+
|
|
|
+ /* Mark in ACL packet that secure connection is downgraded. */
|
|
|
+ p_acl_cb->sc_downgrade = 1;
|
|
|
+ p_dev_rec->remote_secure_connection_previous_state = 0;
|
|
|
+
|
|
|
+ /* As peer device downgraded it's security, peer device is a suspicious
|
|
|
+ * device. Hence remove pairing information by removing link key
|
|
|
+ * information. */
|
|
|
+ memset(p_dev_rec->link_key, 0, LINK_KEY_LEN);
|
|
|
+ p_dev_rec->sec_flags &= ~(BTM_SEC_AUTHORIZED | BTM_SEC_AUTHENTICATED
|
|
|
+ | BTM_SEC_ENCRYPTED | BTM_SEC_NAME_KNOWN
|
|
|
+ | BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_LINK_KEY_AUTHED
|
|
|
+ | BTM_SEC_ROLE_SWITCHED | BTM_SEC_16_DIGIT_PIN_AUTHED);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+#endif
|
|
|
|
|
|
if (p_dev_rec->remote_features_needed) {
|
|
|
BTM_TRACE_EVENT("%s: Now device in SC Only mode, waiting for peer remote features!\n",
|
|
|
@@ -6185,5 +6228,62 @@ static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec)
|
|
|
tACL_CONN *p = btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR);
|
|
|
return (p && (p->link_role == BTM_ROLE_MASTER));
|
|
|
}
|
|
|
-#endif ///SMP_INCLUDED == TRUE
|
|
|
|
|
|
+#if (CLASSIC_BT_INCLUDED == TRUE)
|
|
|
+/*******************************************************************************
|
|
|
+**
|
|
|
+** Function btm_sec_legacy_authentication_mutual
|
|
|
+**
|
|
|
+** Description This function is called when legacy authentication is used
|
|
|
+** and only remote device has completed the authentication
|
|
|
+**
|
|
|
+** Returns TRUE if aunthentication command sent successfully
|
|
|
+**
|
|
|
+*******************************************************************************/
|
|
|
+BOOLEAN btm_sec_legacy_authentication_mutual (tBTM_SEC_DEV_REC *p_dev_rec)
|
|
|
+{
|
|
|
+ return (btm_sec_start_authentication (p_dev_rec));
|
|
|
+}
|
|
|
+
|
|
|
+/*******************************************************************************
|
|
|
+**
|
|
|
+** Function btm_sec_update_legacy_auth_state
|
|
|
+**
|
|
|
+** Description This function updates the legacy authentication state
|
|
|
+**
|
|
|
+** Returns void
|
|
|
+**
|
|
|
+*******************************************************************************/
|
|
|
+void btm_sec_update_legacy_auth_state(tACL_CONN *p_acl_cb, UINT8 legacy_auth_state)
|
|
|
+{
|
|
|
+ if (p_acl_cb) {
|
|
|
+ tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (p_acl_cb->hci_handle);
|
|
|
+ if (p_dev_rec) {
|
|
|
+ if ((BTM_BothEndsSupportSecureConnections(p_dev_rec->bd_addr) == 0) &&
|
|
|
+ (legacy_auth_state != BTM_ACL_LEGACY_AUTH_NONE)) {
|
|
|
+ p_acl_cb->legacy_auth_state |= legacy_auth_state;
|
|
|
+ } else {
|
|
|
+ p_acl_cb->legacy_auth_state = BTM_ACL_LEGACY_AUTH_NONE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*******************************************************************************
|
|
|
+**
|
|
|
+** Function btm_sec_handle_remote_legacy_auth_cmp
|
|
|
+**
|
|
|
+** Description This function updates the legacy authneticaiton state
|
|
|
+** to indicate that remote device has completed the authentication
|
|
|
+**
|
|
|
+** Returns void
|
|
|
+**
|
|
|
+*******************************************************************************/
|
|
|
+void btm_sec_handle_remote_legacy_auth_cmp(UINT16 handle)
|
|
|
+{
|
|
|
+ tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
|
|
|
+ tACL_CONN *p_acl_cb = btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR);
|
|
|
+ btm_sec_update_legacy_auth_state(p_acl_cb, BTM_ACL_LEGACY_AUTH_REMOTE);
|
|
|
+}
|
|
|
+#endif /// (CLASSIC_BT_INCLUDED == TRUE)
|
|
|
+#endif ///SMP_INCLUDED == TRUE
|