Loading system/stack/btm/btm_ble_sec.cc +12 −19 Original line number Diff line number Diff line Loading @@ -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); } /******************************************************************************* Loading Loading @@ -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( Loading Loading @@ -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; } } Loading system/stack/btm/security_device_record.h +2 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading
system/stack/btm/btm_ble_sec.cc +12 −19 Original line number Diff line number Diff line Loading @@ -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); } /******************************************************************************* Loading Loading @@ -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( Loading Loading @@ -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; } } Loading
system/stack/btm/security_device_record.h +2 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading