Commit da9d491a authored by Alain Michaud's avatar Alain Michaud Committed by Commit Bot

Revert [Bluetooth] Fetch and parse blocked LTKs.

Reason for revert: The flag has never been used and the underlying
fix is being replaced by an upstream bluez fix which does not rely
on this interface.

Bug:None
Test:Built

Cq-Depend: chromium:1948095
Change-Id: Ieb8eec8b15b4931c49cddc3f288ed7d1723b437a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949152
Commit-Queue: Alain Michaud <alainm@chromium.org>
Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarSonny Sasaka <sonnysasaka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748371}
parent d9cf9d14
...@@ -51,11 +51,6 @@ const base::Feature kBluetoothPhoneFilter{"BluetoothPhoneFilter", ...@@ -51,11 +51,6 @@ const base::Feature kBluetoothPhoneFilter{"BluetoothPhoneFilter",
const base::Feature kBluetoothKernelSuspendNotifier{ const base::Feature kBluetoothKernelSuspendNotifier{
"BluetoothKernelSuspendNotifier", base::FEATURE_DISABLED_BY_DEFAULT}; "BluetoothKernelSuspendNotifier", base::FEATURE_DISABLED_BY_DEFAULT};
// Feature containing param to block provided long term keys.
const base::Feature kBlueZLongTermKeyBlocklist{
"BlueZLongTermKeyBlocklist", base::FEATURE_DISABLED_BY_DEFAULT};
const char kBlueZLongTermKeyBlocklistParamName[] = "ltk_blocklist";
// Enable or disables running the Camera App as a System Web App. // Enable or disables running the Camera App as a System Web App.
const base::Feature kCameraSystemWebApp{"CameraSystemWebApp", const base::Feature kCameraSystemWebApp{"CameraSystemWebApp",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -32,10 +32,6 @@ extern const base::Feature kBluetoothPhoneFilter; ...@@ -32,10 +32,6 @@ extern const base::Feature kBluetoothPhoneFilter;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kBluetoothKernelSuspendNotifier; extern const base::Feature kBluetoothKernelSuspendNotifier;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kBlueZLongTermKeyBlocklist;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kBlueZLongTermKeyBlocklistParamName[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kCameraSystemWebApp; extern const base::Feature kCameraSystemWebApp;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kCrostiniPortForwarding; extern const base::Feature kCrostiniPortForwarding;
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "device/bluetooth/chromeos/bluetooth_utils.h" #include "device/bluetooth/chromeos/bluetooth_utils.h"
#include <string>
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
...@@ -16,6 +14,7 @@ ...@@ -16,6 +14,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "device/base/features.h" #include "device/base/features.h"
namespace device { namespace device {
...@@ -28,8 +27,6 @@ const char kHIDServiceUUID[] = "1812"; ...@@ -28,8 +27,6 @@ const char kHIDServiceUUID[] = "1812";
// https://www.bluetooth.com/specifications/assigned-numbers/16-bit-uuids-for-sdos. // https://www.bluetooth.com/specifications/assigned-numbers/16-bit-uuids-for-sdos.
const char kSecurityKeyServiceUUID[] = "FFFD"; const char kSecurityKeyServiceUUID[] = "FFFD";
const size_t kLongTermKeyHexStringLength = 32;
constexpr base::TimeDelta kMaxDeviceSelectionDuration = constexpr base::TimeDelta kMaxDeviceSelectionDuration =
base::TimeDelta::FromSeconds(30); base::TimeDelta::FromSeconds(30);
...@@ -154,31 +151,6 @@ device::BluetoothAdapter::DeviceList FilterBluetoothDeviceList( ...@@ -154,31 +151,6 @@ device::BluetoothAdapter::DeviceList FilterBluetoothDeviceList(
return GetLimitedNumDevices(max_devices, filtered_devices); return GetLimitedNumDevices(max_devices, filtered_devices);
} }
std::vector<std::vector<uint8_t>> GetBlockedLongTermKeys() {
std::string blocklist = base::GetFieldTrialParamValueByFeature(
chromeos::features::kBlueZLongTermKeyBlocklist,
chromeos::features::kBlueZLongTermKeyBlocklistParamName);
std::vector<std::vector<uint8_t>> long_term_keys;
if (blocklist.empty())
return long_term_keys;
std::vector<std::string> hex_keys = base::SplitString(
blocklist, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
for (const auto& hex_key : hex_keys) {
// Must be |kLongTermKeyHexStringLength| nibbles in length.
if (hex_key.length() != kLongTermKeyHexStringLength) {
LOG(WARNING) << "Incorrect Long Term Key length";
continue;
}
std::vector<uint8_t> bytes_key;
if (base::HexStringToBytes(hex_key, &bytes_key))
long_term_keys.push_back(std::move(bytes_key));
}
return long_term_keys;
}
void RecordDeviceSelectionDuration(base::TimeDelta duration, void RecordDeviceSelectionDuration(base::TimeDelta duration,
BluetoothUiSurface surface, BluetoothUiSurface surface,
bool was_paired, bool was_paired,
...@@ -225,5 +197,4 @@ void RecordDeviceSelectionDuration(base::TimeDelta duration, ...@@ -225,5 +197,4 @@ void RecordDeviceSelectionDuration(base::TimeDelta duration,
RecordDeviceSelectionDuration(transport_histogram_name, duration); RecordDeviceSelectionDuration(transport_histogram_name, duration);
} }
} }
} // namespace device } // namespace device
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef DEVICE_BLUETOOTH_CHROMEOS_BLUETOOTH_UTILS_H_ #ifndef DEVICE_BLUETOOTH_CHROMEOS_BLUETOOTH_UTILS_H_
#define DEVICE_BLUETOOTH_CHROMEOS_BLUETOOTH_UTILS_H_ #define DEVICE_BLUETOOTH_CHROMEOS_BLUETOOTH_UTILS_H_
#include <vector>
#include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_export.h" #include "device/bluetooth/bluetooth_export.h"
...@@ -37,9 +35,6 @@ FilterBluetoothDeviceList(const BluetoothAdapter::DeviceList& devices, ...@@ -37,9 +35,6 @@ FilterBluetoothDeviceList(const BluetoothAdapter::DeviceList& devices,
BluetoothFilterType filter_type, BluetoothFilterType filter_type,
int max_devices); int max_devices);
std::vector<std::vector<uint8_t>> DEVICE_BLUETOOTH_EXPORT
GetBlockedLongTermKeys();
// Record how long it took for a user to find and select the device they wished // Record how long it took for a user to find and select the device they wished
// to connect to. // to connect to.
void DEVICE_BLUETOOTH_EXPORT void DEVICE_BLUETOOTH_EXPORT
...@@ -47,7 +42,6 @@ RecordDeviceSelectionDuration(base::TimeDelta duration, ...@@ -47,7 +42,6 @@ RecordDeviceSelectionDuration(base::TimeDelta duration,
BluetoothUiSurface surface, BluetoothUiSurface surface,
bool was_paired, bool was_paired,
BluetoothTransport transport); BluetoothTransport transport);
} // namespace device } // namespace device
#endif // DEVICE_BLUETOOTH_CHROMEOS_BLUETOOTH_UTILS_H_ #endif // DEVICE_BLUETOOTH_CHROMEOS_BLUETOOTH_UTILS_H_
...@@ -76,12 +76,6 @@ class BluetoothUtilsTest : public testing::Test { ...@@ -76,12 +76,6 @@ class BluetoothUtilsTest : public testing::Test {
chromeos::features::kBluetoothAggressiveAppearanceFilter); chromeos::features::kBluetoothAggressiveAppearanceFilter);
} }
void SetLongTermKeys(const std::string& keys) {
feature_list_.InitAndEnableFeatureWithParameters(
chromeos::features::kBlueZLongTermKeyBlocklist,
{{chromeos::features::kBlueZLongTermKeyBlocklistParamName, keys}});
}
private: private:
base::test::TaskEnvironment task_environment_; base::test::TaskEnvironment task_environment_;
scoped_refptr<MockBluetoothAdapter> adapter_ = scoped_refptr<MockBluetoothAdapter> adapter_ =
...@@ -256,82 +250,4 @@ TEST_F(BluetoothUtilsTest, ...@@ -256,82 +250,4 @@ TEST_F(BluetoothUtilsTest,
0u /* num_expected_remaining_devices */); 0u /* num_expected_remaining_devices */);
} }
TEST_F(BluetoothUtilsTest, TestGetBlockedLongTermKeys_ListIncludesBadLtks) {
// One nibble too long, one nibble too short, and one nibble just right.
std::string hex_key_1 = "000000000000000000000000000012345";
std::string hex_key_2 = "0000000000000000000000000000123";
std::string hex_key_3 = "00000000000000000000000000001234";
SetLongTermKeys(hex_key_1 + ',' + hex_key_2 + ',' + hex_key_3);
std::vector<std::vector<uint8_t>> expected_array;
std::vector<uint8_t> expected_key = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x12, 0x34};
expected_array.push_back(expected_key);
EXPECT_EQ(expected_array, device::GetBlockedLongTermKeys());
}
TEST_F(BluetoothUtilsTest, TestGetBlockedLongTermKeys_ListIncludesNonHexInput) {
std::string hex_key_1 = "bad00input00but00correct00length";
std::string hex_key_2 = "00000000000000000000000000001234";
SetLongTermKeys(hex_key_1 + ',' + hex_key_2);
std::vector<std::vector<uint8_t>> expected_array;
std::vector<uint8_t> expected_key = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x12, 0x34};
expected_array.push_back(expected_key);
EXPECT_EQ(expected_array, device::GetBlockedLongTermKeys());
}
TEST_F(BluetoothUtilsTest, TestEmptyList) {
SetLongTermKeys("");
std::vector<std::vector<uint8_t>> expected_array;
EXPECT_EQ(expected_array, device::GetBlockedLongTermKeys());
}
TEST_F(BluetoothUtilsTest, TestGetBlockedLongTermKeys_OneElementList) {
std::string hex_key_1 = "012300004567000089ab0000cdef0000";
std::vector<uint8_t> expected_key_1 = {0x01, 0x23, 0x00, 0x00, 0x45, 0x67,
0x00, 0x00, 0x89, 0xab, 0x00, 0x00,
0xcd, 0xef, 0x00, 0x00};
SetLongTermKeys(hex_key_1);
std::vector<std::vector<uint8_t>> expected_array;
expected_array.push_back(expected_key_1);
EXPECT_EQ(expected_array, device::GetBlockedLongTermKeys());
}
TEST_F(BluetoothUtilsTest, TestGetBlockedLongTermKeys_MultipleElementList) {
std::string hex_key_1 = "012300004567000089ab0000cdef0000";
std::vector<uint8_t> expected_key_1 = {0x01, 0x23, 0x00, 0x00, 0x45, 0x67,
0x00, 0x00, 0x89, 0xab, 0x00, 0x00,
0xcd, 0xef, 0x00, 0x00};
std::string hex_key_2 = "00001111222233334444555566667777";
std::vector<uint8_t> expected_key_2 = {0x00, 0x00, 0x11, 0x11, 0x22, 0x22,
0x33, 0x33, 0x44, 0x44, 0x55, 0x55,
0x66, 0x66, 0x77, 0x77};
std::string hex_key_3 = "88889999aaaabbbbccccddddeeeeffff";
std::vector<uint8_t> expected_key_3 = {0x88, 0x88, 0x99, 0x99, 0xaa, 0xaa,
0xbb, 0xbb, 0xcc, 0xcc, 0xdd, 0xdd,
0xee, 0xee, 0xff, 0xff};
SetLongTermKeys(hex_key_1 + ',' + hex_key_2 + ',' + hex_key_3);
std::vector<std::vector<uint8_t>> expected_array;
expected_array.push_back(expected_key_1);
expected_array.push_back(expected_key_2);
expected_array.push_back(expected_key_3);
EXPECT_EQ(expected_array, device::GetBlockedLongTermKeys());
}
} // namespace device } // namespace device
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment