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

Commit 72327c55 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Fix 0 key size for LE link

If it's first encryption between devices, during pairing, we don't
have the keys stored. They are remembered in the SMP control block
to be stored after encryption is successfull.

Bug: 383249088
Test: see b/383249088 it talks about test implementation
Test: mma -j32;
Flag: exempt, trivial fix
Change-Id: I9596393315630b9ba2d4252326c59126ec12c66a
parent 403bfc31
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3227,6 +3227,11 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status, uint8_t encr_en

  if (transport == BT_TRANSPORT_LE) {
    key_size = p_dev_rec->sec_rec.ble_keys.key_size;
    if (key_size == 0 && status == HCI_SUCCESS && encr_enable == HCI_ENCRYPT_MODE_ON) {
      /* Only case when key size is 0 during successfull encryption is pairing - for this case look
       * up the key size */
      key_size = SMP_GetPendingPairingKeySize();
    }
  }

  log::debug(
+9 −0
Original line number Diff line number Diff line
@@ -200,6 +200,15 @@ void SMP_ClearLocScOobData();
 ******************************************************************************/
void SMP_SirkConfirmDeviceReply(const RawAddress& bd_addr, uint8_t res);

/*******************************************************************************
 *
 * Function         SMP_SirkConfirmDeviceReply
 *
 * Description      Returns the key size of peinding LE pairing
 *
 ******************************************************************************/
uint16_t SMP_GetPendingPairingKeySize();

// Called when LTK request is received from controller.
bool smp_proc_ltk_request(const RawAddress& bda);

+5 −0
Original line number Diff line number Diff line
@@ -525,3 +525,8 @@ void SMP_SirkConfirmDeviceReply(const RawAddress& bd_addr, uint8_t res) {
    smp_sm_event(p_cb, SMP_SIRK_DEVICE_VALID_EVT, &smp_int_data);
  }
}

uint16_t SMP_GetPendingPairingKeySize() {
  tSMP_CB* p_cb = &smp_cb;
  return p_cb->loc_enc_size;
}
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -69,3 +69,8 @@ void SMP_ClearLocScOobData() { inc_func_call_count(__func__); }
void SMP_SirkConfirmDeviceReply(const RawAddress& /* bd_addr */, uint8_t /* res */) {
  inc_func_call_count(__func__);
}

uint16_t SMP_GetPendingPairingKeySize() {
  inc_func_call_count(__func__);
  return 0;
}
 No newline at end of file