Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a755e4cd authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Gerrit Code Review
Browse files

Merge "Replace CTKD detection with information from lower layers"

parents 721df0b8 34f101ab
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -89,7 +89,8 @@ static uint8_t bta_dm_pin_cback(const RawAddress& bd_addr, DEV_CLASS dev_class,
static uint8_t bta_dm_new_link_key_cback(const RawAddress& bd_addr,
                                         DEV_CLASS dev_class,
                                         tBTM_BD_NAME bd_name,
                                         const LinkKey& key, uint8_t key_type);
                                         const LinkKey& key, uint8_t key_type,
                                         bool is_ctkd);
static void bta_dm_authentication_complete_cback(const RawAddress& bd_addr,
                                                 DEV_CLASS dev_class,
                                                 tBTM_BD_NAME bd_name,
@@ -2126,7 +2127,8 @@ static uint8_t bta_dm_pin_cback(const RawAddress& bd_addr, DEV_CLASS dev_class,
static uint8_t bta_dm_new_link_key_cback(const RawAddress& bd_addr,
                                         UNUSED_ATTR DEV_CLASS dev_class,
                                         tBTM_BD_NAME bd_name,
                                         const LinkKey& key, uint8_t key_type) {
                                         const LinkKey& key, uint8_t key_type,
                                         bool is_ctkd) {
  tBTA_DM_SEC sec_event;
  tBTA_DM_AUTH_CMPL* p_auth_cmpl;
  tBTA_DM_SEC_EVT event = BTA_DM_AUTH_CMPL_EVT;
@@ -2143,6 +2145,8 @@ static uint8_t bta_dm_new_link_key_cback(const RawAddress& bd_addr,
  p_auth_cmpl->key_type = key_type;
  p_auth_cmpl->success = true;
  p_auth_cmpl->key = key;
  p_auth_cmpl->is_ctkd = is_ctkd;

  sec_event.auth_cmpl.fail_reason = HCI_SUCCESS;

  // Report the BR link key based on the BR/EDR address and type
+1 −0
Original line number Diff line number Diff line
@@ -306,6 +306,7 @@ typedef struct {
      fail_reason; /* The HCI reason/error code for when success=false */
  tBLE_ADDR_TYPE addr_type; /* Peer device address type */
  tBT_DEVICE_TYPE dev_type;
  bool is_ctkd; /* True if key is derived using CTKD procedure */
} tBTA_DM_AUTH_CMPL;

/* Structure associated with BTA_DM_LINK_UP_EVT */
+2 −4
Original line number Diff line number Diff line
@@ -1104,8 +1104,7 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
    }

    bool is_crosskey = false;
    if (pairing_cb.state == BT_BOND_STATE_BONDING &&
        p_auth_cmpl->bd_addr != pairing_cb.bd_addr) {
    if (pairing_cb.state == BT_BOND_STATE_BONDING && p_auth_cmpl->is_ctkd) {
      LOG_INFO("bonding initiated due to cross key pairing");
      is_crosskey = true;
    }
@@ -1138,8 +1137,7 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
      invoke_remote_device_properties_cb(BT_STATUS_SUCCESS, bd_addr, 1, &prop);
    } else {
      /* If bonded due to cross-key, save the static address too*/
      if (pairing_cb.state == BT_BOND_STATE_BONDING &&
          p_auth_cmpl->bd_addr != pairing_cb.bd_addr) {
      if (is_crosskey) {
        BTIF_TRACE_DEBUG(
            "%s: bonding initiated due to cross key, adding static address",
            __func__);
+1 −1
Original line number Diff line number Diff line
@@ -462,7 +462,7 @@ class ShimBondListener : public bluetooth::security::ISecurityManagerListener {
        LinkKey key;  // Never want to send the key to the stack
        (*bta_callbacks_->p_link_key_callback)(
            bluetooth::ToRawAddress(device.GetAddress()), 0, name, key,
            BTM_LKEY_TYPE_COMBINATION);
            BTM_LKEY_TYPE_COMBINATION, false /* is_ctkd */);
      }
      if (*bta_callbacks_->p_auth_complete_callback) {
        (*bta_callbacks_->p_auth_complete_callback)(
+7 −7
Original line number Diff line number Diff line
@@ -3941,9 +3941,9 @@ void btm_sec_link_key_notification(const RawAddress& p_bda,
    if (btm_cb.api.p_link_key_callback) {
      BTM_TRACE_DEBUG("%s() Save LTK derived LK (key_type = %d)", __func__,
                      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, link_key,
                                        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, link_key,
          p_dev_rec->link_key_type, true /* is_ctkd */);
    }
  } else {
    if ((p_dev_rec->link_key_type == BTM_LKEY_TYPE_UNAUTH_COMB_P_256) ||
@@ -3991,9 +3991,9 @@ void btm_sec_link_key_notification(const RawAddress& p_bda,
            " (key_type = %d)",
            p_dev_rec->link_key_type);
      } else {
        (*btm_cb.api.p_link_key_callback)(p_bda, p_dev_rec->dev_class,
                                          p_dev_rec->sec_bd_name, link_key,
                                          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, link_key,
            p_dev_rec->link_key_type, false /* is_ctkd */);
      }
    }
  }
@@ -4579,7 +4579,7 @@ 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, p_dev_rec->link_key_type, false);
}

/*******************************************************************************
Loading