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

Commit fc8552b5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "SMP: Avoid repeated csrk generation" am: fa973a92 am: 22086ecb

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1906025

Change-Id: I1267d3bedaed53e3a8bd5175817185fdf5ae9e0f
parents 56a014f3 22086ecb
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ static bool pts_test_send_authentication_complete_failure(tSMP_CB* p_cb) {
 * Function         smp_update_key_mask
 * Description      This function updates the key mask for sending or receiving.
 ******************************************************************************/
static void smp_update_key_mask(tSMP_CB* p_cb, uint8_t key_type, bool recv) {
void smp_update_key_mask(tSMP_CB* p_cb, uint8_t key_type, bool recv) {
  SMP_TRACE_DEBUG(
      "%s before update role=%d recv=%d local_i_key = %02x, local_r_key = %02x",
      __func__, p_cb->role, recv, p_cb->local_i_key, p_cb->local_r_key);
@@ -389,6 +389,8 @@ void smp_send_id_info(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
void smp_send_csrk_info(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  SMP_TRACE_DEBUG("%s", __func__);
  smp_update_key_mask(p_cb, SMP_SEC_KEY_TYPE_CSRK, false);
  p_cb->total_tx_unacked =
      p_cb->total_tx_unacked > 0 ? p_cb->total_tx_unacked - 1 : 0;

  if (smp_send_cmd(SMP_OPCODE_SIGN_INFO, p_cb)) {
    tBTM_LE_KEY_VALUE key = {
+1 −0
Original line number Diff line number Diff line
@@ -407,6 +407,7 @@ extern void smp_br_process_link_key(tSMP_CB* p_cb, tSMP_INT_DATA* p_data);
extern void smp_key_distribution_by_transport(tSMP_CB* p_cb,
                                              tSMP_INT_DATA* p_data);
extern void smp_br_pairing_complete(tSMP_CB* p_cb, tSMP_INT_DATA* p_data);
extern void smp_update_key_mask(tSMP_CB* p_cb, uint8_t key_type, bool recv);

/* smp_l2c */
extern void smp_l2cap_if_init(void);
+2 −0
Original line number Diff line number Diff line
@@ -194,12 +194,14 @@ void smp_generate_csrk(tSMP_CB* p_cb, UNUSED_ATTR tSMP_INT_DATA* p_data) {
  bool div_status;

  SMP_TRACE_DEBUG("smp_generate_csrk");
  smp_update_key_mask(p_cb, SMP_SEC_KEY_TYPE_CSRK, false);

  div_status = btm_get_local_div(p_cb->pairing_bda, &p_cb->div);
  if (div_status) {
    smp_compute_csrk(p_cb->div, p_cb);
  } else {
    SMP_TRACE_DEBUG("Generate DIV for CSRK");
    p_cb->total_tx_unacked++;
    btsnd_hcic_ble_rand(Bind(
        [](tSMP_CB* p_cb, BT_OCTET8 rand) {
          uint16_t div;