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

Commit a84be2cf authored by Hui Peng's avatar Hui Peng Committed by Gerrit Code Review
Browse files

Merge "[Invisalign2] move btm_ble_increment_sign_ctr to tBTM_SEC_REC" into main

parents 0430149b d337520d
Loading
Loading
Loading
Loading
+12 −19
Original line number Diff line number Diff line
@@ -792,28 +792,21 @@ tBTM_STATUS btm_ble_start_sec_check(const RawAddress& bd_addr, uint16_t psm,

/*******************************************************************************
 *
 * Function         btm_ble_get_enc_key_type
 * Function         increment_sign_counter
 *
 * Description      This function is to increment local sign counter
 * Description      This method is to increment the (local or peer) sign counter
 * Returns         None
 *
 ******************************************************************************/
static void btm_ble_increment_sign_ctr(const RawAddress& bd_addr,
                                       bool is_local) {
  tBTM_SEC_DEV_REC* p_dev_rec;

  LOG_VERBOSE("btm_ble_increment_sign_ctr is_local=%d", is_local);

  p_dev_rec = btm_find_dev(bd_addr);
  if (p_dev_rec != NULL) {
    if (is_local)
      p_dev_rec->sec_rec.ble_keys.local_counter++;
    else
      p_dev_rec->sec_rec.ble_keys.counter++;
    LOG_VERBOSE("is_local=%d local sign counter=%d peer sign counter=%d",
                is_local, p_dev_rec->sec_rec.ble_keys.local_counter,
                p_dev_rec->sec_rec.ble_keys.counter);
void tBTM_SEC_REC::increment_sign_counter(bool local) {
  if (local) {
    ble_keys.local_counter++;
  } else {
    ble_keys.counter++;
  }

  LOG_VERBOSE("local=%d local sign counter=%d peer sign counter=%d", local,
              ble_keys.local_counter, ble_keys.counter);
}

/*******************************************************************************
@@ -1752,7 +1745,7 @@ bool BTM_BleDataSignature(const RawAddress& bd_addr, uint8_t* p_text,

  crypto_toolbox::aes_cmac(p_rec->sec_rec.ble_keys.lcsrk, p_buf,
                           (uint16_t)(len + 4), BTM_CMAC_TLEN_SIZE, p_mac);
  btm_ble_increment_sign_ctr(bd_addr, true);
  p_rec->sec_rec.increment_sign_counter(true);

  LOG_VERBOSE("p_mac = %p", p_mac);
  LOG_VERBOSE(
@@ -1802,7 +1795,7 @@ bool BTM_BleVerifySignature(const RawAddress& bd_addr, uint8_t* p_orig,
    crypto_toolbox::aes_cmac(p_rec->sec_rec.ble_keys.pcsrk, p_orig, len,
                             BTM_CMAC_TLEN_SIZE, p_mac);
    if (CRYPTO_memcmp(p_mac, p_comp, BTM_CMAC_TLEN_SIZE) == 0) {
      btm_ble_increment_sign_ctr(bd_addr, false);
      p_rec->sec_rec.increment_sign_counter(false);
      verified = true;
    }
  }
+2 −0
Original line number Diff line number Diff line
@@ -354,6 +354,8 @@ struct tBTM_SEC_REC {
  }

  uint8_t get_encryption_key_size() const { return enc_key_size; }

  void increment_sign_counter(bool local);
};

class tBTM_SEC_DEV_REC {