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

Commit eee7ec6f authored by Josh Wu's avatar Josh Wu Committed by Cherrypicker Worker
Browse files

SMP: Set pairing parameters for CTKD by properties

These configurations were in bt_stack.conf and shared between LE and
CTKD(SMP over BR/EDR). Devices may need different parameters for these 2
modes and to configure them, so we need properties to control them.

Bug: 269773251
Test: net_test_stack_btm
Test: Avatar - test CTKD over BR/EDR on 2 directions
Change-Id: Iaf250e12cc58abb8df8ebad32c6593ebcd974ee8
(cherry picked from https://android-review.googlesource.com/q/commit:4da8aad839d9cfb2fe0227b36eb5b3a95f7300f4)
Merged-In: Iaf250e12cc58abb8df8ebad32c6593ebcd974ee8
Bug: 263323082
parent bd87b220
Loading
Loading
Loading
Loading
+28 −5
Original line number Diff line number Diff line
@@ -62,6 +62,22 @@ extern void gatt_notify_phy_updated(tGATT_STATUS status, uint16_t handle,
#define PROPERTY_BLE_PRIVACY_ENABLED "bluetooth.core.gap.le.privacy.enabled"
#endif

// Pairing parameters defined in Vol 3, Part H, Chapter 3.5.1 - 3.5.2
// All present in the exact decimal values, not hex
// Ex: bluetooth.core.smp.le.ctkd.initiator_key_distribution 15(0x0f)
static const char kPropertyCtkdAuthRequest[] =
    "bluetooth.core.smp.le.ctkd.auth_request";
static const char kPropertyCtkdIoCapabilities[] =
    "bluetooth.core.smp.le.ctkd.io_capabilities";
// Vol 3, Part H, Chapter 3.6.1, Figure 3.11
// |EncKey(1)|IdKey(1)|SignKey(1)|LinkKey(1)|Reserved(4)|
static const char kPropertyCtkdInitiatorKeyDistribution[] =
    "bluetooth.core.smp.le.ctkd.initiator_key_distribution";
static const char kPropertyCtkdResponderKeyDistribution[] =
    "bluetooth.core.smp.le.ctkd.responder_key_distribution";
static const char kPropertyCtkdMaxKeySize[] =
    "bluetooth.core.smp.le.ctkd.max_key_size";

/******************************************************************************/
/* External Function to be called by other modules                            */
/******************************************************************************/
@@ -1731,11 +1747,18 @@ uint8_t btm_ble_br_keys_req(tBTM_SEC_DEV_REC* p_dev_rec,
                            tBTM_LE_IO_REQ* p_data) {
  uint8_t callback_rc = BTM_SUCCESS;
  BTM_TRACE_DEBUG("%s", __func__);
  if (btm_cb.api.p_le_callback) {
    /* the callback function implementation may change the IO capability... */
    callback_rc = (*btm_cb.api.p_le_callback)(
        BTM_LE_IO_REQ_EVT, p_dev_rec->bd_addr, (tBTM_LE_EVT_DATA*)p_data);
  }
  p_data->io_cap =
      osi_property_get_int32(kPropertyCtkdIoCapabilities, BTM_IO_CAP_UNKNOWN);
  p_data->auth_req = osi_property_get_int32(kPropertyCtkdAuthRequest,
                                            BTM_LE_AUTH_REQ_SC_MITM_BOND);
  p_data->init_keys = osi_property_get_int32(
      kPropertyCtkdInitiatorKeyDistribution, SMP_BR_SEC_DEFAULT_KEY);
  p_data->resp_keys = osi_property_get_int32(
      kPropertyCtkdResponderKeyDistribution, SMP_BR_SEC_DEFAULT_KEY);
  p_data->max_key_size =
      osi_property_get_int32(kPropertyCtkdMaxKeySize, BTM_BLE_MAX_KEY_SIZE);
  // No OOB data for BR/EDR
  p_data->oob_data = false;

  return callback_rc;
}