[Invisalign2] move btm_ble_increment_sign_ctr to tBTM_SEC_REC
btm_ble_increment_sign_ctr -->
tBTM_SEC_REC::increment_sign_counter
Bug: 301661850
Test: m com.android.btservices
Flag: EXEMPT, no-op
Change-Id: I9e749f15ce13c81e4e36c0e1a1f94688c3835fce
diff --git a/system/stack/btm/btm_ble_sec.cc b/system/stack/btm/btm_ble_sec.cc
index 8f32406..15a7a5d 100644
--- a/system/stack/btm/btm_ble_sec.cc
+++ b/system/stack/btm/btm_ble_sec.cc
@@ -792,28 +792,21 @@
/*******************************************************************************
*
- * 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 @@
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 @@
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;
}
}
diff --git a/system/stack/btm/security_device_record.h b/system/stack/btm/security_device_record.h
index 385b001..821d4e3 100644
--- a/system/stack/btm/security_device_record.h
+++ b/system/stack/btm/security_device_record.h
@@ -354,6 +354,8 @@
}
uint8_t get_encryption_key_size() const { return enc_key_size; }
+
+ void increment_sign_counter(bool local);
};
class tBTM_SEC_DEV_REC {