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

Commit 64216ddc authored by Martin Brabham's avatar Martin Brabham Committed by Automerger Merge Worker
Browse files

OOB: Utilize SMP state machine to generate the OOB data. am: a4477ccb

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1736639

Change-Id: Ia209f174967688aee6f74429769911e463435e5c
parents ccaf5ce3 a4477ccb
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -3447,6 +3447,14 @@ static uint8_t bta_dm_ble_smp_cback(tBTM_LE_EVT event, const RawAddress& bda,
      bta_dm_cb.p_sec_cback(BTA_DM_BLE_SC_OOB_REQ_EVT, &sec_event);
      bta_dm_cb.p_sec_cback(BTA_DM_BLE_SC_OOB_REQ_EVT, &sec_event);
      break;
      break;


    case BTM_LE_SC_LOC_OOB_EVT:
      tBTA_DM_LOC_OOB_DATA local_oob_data;
      local_oob_data.local_oob_c = p_data->local_oob_data.commitment;
      local_oob_data.local_oob_r = p_data->local_oob_data.randomizer;
      sec_event.local_oob_data = local_oob_data;
      bta_dm_cb.p_sec_cback(BTA_DM_BLE_SC_CR_LOC_OOB_EVT, &sec_event);
      break;

    case BTM_LE_KEY_EVT:
    case BTM_LE_KEY_EVT:
      sec_event.ble_key.bd_addr = bda;
      sec_event.ble_key.bd_addr = bda;
      sec_event.ble_key.key_type = p_data->key.key_type;
      sec_event.ble_key.key_type = p_data->key.key_type;
+8 −0
Original line number Original line Diff line number Diff line
@@ -216,6 +216,8 @@ typedef uint8_t tBTA_DM_BLE_RSSI_ALERT_TYPE;
#define BTA_DM_ENER_INFO_READ 28 /* Energy info read */
#define BTA_DM_ENER_INFO_READ 28 /* Energy info read */
#define BTA_DM_BLE_SC_OOB_REQ_EVT 29 /* SMP SC OOB request event */
#define BTA_DM_BLE_SC_OOB_REQ_EVT 29 /* SMP SC OOB request event */
#define BTA_DM_BLE_CONSENT_REQ_EVT 30 /* SMP consent request event */
#define BTA_DM_BLE_CONSENT_REQ_EVT 30 /* SMP consent request event */
#define BTA_DM_BLE_SC_CR_LOC_OOB_EVT \
  31 /* SMP SC Create Local OOB request event */
typedef uint8_t tBTA_DM_SEC_EVT;
typedef uint8_t tBTA_DM_SEC_EVT;


/* Structure associated with BTA_DM_PIN_REQ_EVT */
/* Structure associated with BTA_DM_PIN_REQ_EVT */
@@ -363,6 +365,11 @@ typedef struct {
  tBTA_STATUS result; /* true of bond cancel succeeded, false if failed. */
  tBTA_STATUS result; /* true of bond cancel succeeded, false if failed. */
} tBTA_DM_BOND_CANCEL_CMPL;
} tBTA_DM_BOND_CANCEL_CMPL;


typedef struct {
  Octet16 local_oob_c; /* Local OOB Data Confirmation/Commitment */
  Octet16 local_oob_r; /* Local OOB Data Randomizer */
} tBTA_DM_LOC_OOB_DATA;

/* Union of all security callback structures */
/* Union of all security callback structures */
typedef union {
typedef union {
  tBTA_DM_PIN_REQ pin_req;        /* PIN request. */
  tBTA_DM_PIN_REQ pin_req;        /* PIN request. */
@@ -378,6 +385,7 @@ typedef union {
  tBTA_DM_BLE_KEY ble_key;            /* BLE SMP keys used when pairing */
  tBTA_DM_BLE_KEY ble_key;            /* BLE SMP keys used when pairing */
  tBTA_BLE_LOCAL_ID_KEYS ble_id_keys; /* IR event */
  tBTA_BLE_LOCAL_ID_KEYS ble_id_keys; /* IR event */
  Octet16 ble_er;                     /* ER event data */
  Octet16 ble_er;                     /* ER event data */
  tBTA_DM_LOC_OOB_DATA local_oob_data; /* Local OOB data generated by us */
} tBTA_DM_SEC;
} tBTA_DM_SEC;


/* Security callback */
/* Security callback */
+8 −1
Original line number Original line Diff line number Diff line
@@ -1677,6 +1677,13 @@ static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
      BTIF_TRACE_DEBUG("BTA_DM_BLE_SC_OOB_REQ_EVT. ");
      BTIF_TRACE_DEBUG("BTA_DM_BLE_SC_OOB_REQ_EVT. ");
      btif_dm_ble_sc_oob_req_evt(&p_data->rmt_oob);
      btif_dm_ble_sc_oob_req_evt(&p_data->rmt_oob);
      break;
      break;
    case BTA_DM_BLE_SC_CR_LOC_OOB_EVT:
      BTIF_TRACE_DEBUG("BTA_DM_BLE_SC_CR_LOC_OOB_EVT");
      btif_dm_proc_loc_oob(BT_TRANSPORT_LE, true,
                           p_data->local_oob_data.local_oob_c,
                           p_data->local_oob_data.local_oob_r);
      break;

    case BTA_DM_BLE_LOCAL_IR_EVT:
    case BTA_DM_BLE_LOCAL_IR_EVT:
      BTIF_TRACE_DEBUG("BTA_DM_BLE_LOCAL_IR_EVT. ");
      BTIF_TRACE_DEBUG("BTA_DM_BLE_LOCAL_IR_EVT. ");
      ble_local_key_cb.is_id_keys_rcvd = true;
      ble_local_key_cb.is_id_keys_rcvd = true;
@@ -2816,7 +2823,7 @@ static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type) {


  /* make sure OOB data is for this particular device */
  /* make sure OOB data is for this particular device */
  if (req_oob_type->bd_addr != oob_cb.bdaddr) {
  if (req_oob_type->bd_addr != oob_cb.bdaddr) {
    LOG_WARN("remote address didn't match OOB data address");
    LOG_ERROR("remote address didn't match OOB data address");
    return;
    return;
  }
  }


+7 −1
Original line number Original line Diff line number Diff line
@@ -1848,7 +1848,13 @@ tBTM_STATUS btm_proc_smp_cback(tSMP_EVT event, const RawAddress& bd_addr,
        break;
        break;
    }
    }
  } else {
  } else {
    BTM_TRACE_ERROR("btm_proc_smp_cback received for unknown device");
    // If we are being paired with via OOB we haven't created a dev rec for
    // the device yet
    if (event == SMP_SC_LOC_OOB_DATA_UP_EVT) {
      btm_sec_cr_loc_oob_data_cback_event(bd_addr, p_data->loc_oob_data);
    } else {
      LOG_WARN("Unexpected event '%d' without p_dev_rec", event);
    }
  }
  }


  return BTM_SUCCESS;
  return BTM_SUCCESS;
+13 −2
Original line number Original line Diff line number Diff line
@@ -4611,17 +4611,28 @@ void btm_sec_dev_rec_cback_event(tBTM_SEC_DEV_REC* p_dev_rec,
  tBTM_SEC_CALLBACK* p_callback = p_dev_rec->p_callback;
  tBTM_SEC_CALLBACK* p_callback = p_dev_rec->p_callback;
  p_dev_rec->p_callback = NULL;
  p_dev_rec->p_callback = NULL;
  if (p_callback != nullptr) {
  if (p_callback != nullptr) {
    if (is_le_transport)
    if (is_le_transport) {
      (*p_callback)(&p_dev_rec->ble.pseudo_addr, BT_TRANSPORT_LE,
      (*p_callback)(&p_dev_rec->ble.pseudo_addr, BT_TRANSPORT_LE,
                    p_dev_rec->p_ref_data, btm_status);
                    p_dev_rec->p_ref_data, btm_status);
    else
    } else {
      (*p_callback)(&p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR,
      (*p_callback)(&p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR,
                    p_dev_rec->p_ref_data, btm_status);
                    p_dev_rec->p_ref_data, btm_status);
    }
    }
  }


  btm_sec_check_pending_reqs();
  btm_sec_check_pending_reqs();
}
}


void btm_sec_cr_loc_oob_data_cback_event(const RawAddress& address,
                                         tSMP_LOC_OOB_DATA loc_oob_data) {
  tBTM_LE_EVT_DATA evt_data = {
      .local_oob_data = loc_oob_data,
  };
  if (btm_cb.api.p_le_callback) {
    (*btm_cb.api.p_le_callback)(BTM_LE_SC_LOC_OOB_EVT, address, &evt_data);
  }
}

/*******************************************************************************
/*******************************************************************************
 *
 *
 * Function         btm_sec_queue_mx_request
 * Function         btm_sec_queue_mx_request
Loading