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

Commit c73e0297 authored by Josh Wu's avatar Josh Wu
Browse files

SMP: Calculate LTK on BR SMP begin

With the original code, SMP central device calculates LTK after
receiveing keys from peripheral, but this should be done before
key distribution.

Tag: #compatibility
Bug: 198554515
Test: atest BluetoothInstrumentationTests
Change-Id: I2127f7210374ad2afaaacee31b3916c7ce3e2597
parent f8b8cdee
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -910,6 +910,15 @@ void smp_br_check_authorization_request(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  }
  SMP_TRACE_DEBUG("%s: use h7 = %d", __func__, p_cb->key_derivation_h7_used);

  /* SMP over BR/EDR should always be used with CTKD, so derive LTK from
   * LK before receiving keys */
  if ((p_cb->role == HCI_ROLE_CENTRAL &&
       (p_cb->local_i_key & SMP_SEC_KEY_TYPE_ENC)) ||
      (p_cb->role == HCI_ROLE_PERIPHERAL &&
       (p_cb->local_r_key & SMP_SEC_KEY_TYPE_ENC))) {
    smp_generate_ltk(p_cb, p_data);
  }

  SMP_TRACE_DEBUG(
      "%s rcvs upgrades: i_keys=0x%x r_keys=0x%x (i-initiator r-responder)",
      __func__, p_cb->local_i_key, p_cb->local_r_key);
+1 −1
Original line number Diff line number Diff line
@@ -530,7 +530,7 @@ static void smp_generate_ltk_cont(uint16_t div, tSMP_CB* p_cb) {
void smp_generate_ltk(tSMP_CB* p_cb, UNUSED_ATTR tSMP_INT_DATA* p_data) {
  SMP_TRACE_DEBUG("%s", __func__);

  if (smp_get_br_state() == SMP_BR_STATE_BOND_PENDING) {
  if (p_cb->smp_over_br) {
    smp_br_process_link_key(p_cb, NULL);
    return;
  } else if (p_cb->le_secure_connections_mode_is_used) {