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

Commit 45340e07 authored by JohnLai's avatar JohnLai Committed by John Lai
Browse files

Floss: Set le sec_flags in btm_sec_encrypt_change

The flag BTM_SEC_LE_AUTHENTICATED is used to encrypt data with authenticated pairing. Because we may pair and encrypt data without authenticated pairing, we should only set the sec_flags to BTM_SEC_LE_ENCRYPTED.

Bug: 274360278
Tag: #floss
Test: Manually
Change-Id: I7d0646d51082064be35c5916d7f3700e89ae9ccd
parent 852e184c
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -1782,16 +1782,6 @@ impl IBluetooth for Bluetooth {
            return false;
        }

        let is_bonding = match self.found_devices.get(&device.address) {
            Some(d) => d.bond_state == BtBondState::Bonding,
            None => false,
        };

        if !is_bonding {
            warn!("Can't set pairing confirmation. Device {} isn't bonding.", device.address);
            return false;
        }

        self.intf.lock().unwrap().ssp_reply(
            &addr.unwrap(),
            BtSspVariant::PasskeyConfirmation,
+1 −2
Original line number Diff line number Diff line
@@ -3355,8 +3355,7 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status,
          p_dev_rec->sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED;
        }
      } else if (p_dev_rec->ble_hci_handle == handle) {  // BLE
        p_dev_rec->sec_flags |=
            (BTM_SEC_LE_AUTHENTICATED | BTM_SEC_LE_ENCRYPTED);
        p_dev_rec->sec_flags |= BTM_SEC_LE_ENCRYPTED;
      } else {
        LOG_ERROR(
            "Received encryption change for unknown device handle:0x%04x "
+2 −4
Original line number Diff line number Diff line
@@ -309,13 +309,11 @@ TEST_F(StackBtmWithInitFreeTest, btm_sec_encrypt_change) {

  // With le device encryption enable
  btm_sec_encrypt_change(ble_handle, HCI_SUCCESS, 0x01);
  ASSERT_EQ(BTM_SEC_IN_USE | BTM_SEC_LE_AUTHENTICATED | BTM_SEC_LE_ENCRYPTED,
            device_record->sec_flags);
  ASSERT_EQ(BTM_SEC_IN_USE | BTM_SEC_LE_ENCRYPTED, device_record->sec_flags);

  // With le device encryption disable
  btm_sec_encrypt_change(ble_handle, HCI_SUCCESS, 0x00);
  ASSERT_EQ(BTM_SEC_IN_USE | BTM_SEC_LE_AUTHENTICATED,
            device_record->sec_flags);
  ASSERT_EQ(BTM_SEC_IN_USE, device_record->sec_flags);
  device_record->sec_flags = BTM_SEC_IN_USE;

  wipe_secrets_and_remove(device_record);