From: Archie Pusaka Date: Wed, 22 Jul 2020 16:20:33 +0000 (+0800) Subject: input: encrypt on receive conn req if classic_bonded_only X-Git-Tag: submit/tizen/20210606.232858~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d26409a78c1a29b3fbb2eb95471c38aab9c44d4a;p=platform%2Fupstream%2Fbluez.git input: encrypt on receive conn req if classic_bonded_only According to bluetooth HID1.1 spec, section 5.4.3.5.3: If the Bluetooth HID Host is bonded to a Bluetooth HID device: If encryption is not already enabled, the Bluetooth HID Host shall enable encryption with the Bluetooth HID device before sending an L2CAP Connect Response with a result code of “Connection Successful” (0x0000) after an L2CAP Connect Request is received. This patch raises the security level to medium when listening for incoming connection if the flag classic_bonded_only is set, effectively starting encryption. Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- diff --git a/profiles/input/device.c b/profiles/input/device.c index fc02b645..2870beaf 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -111,6 +111,11 @@ void input_set_classic_bonded_only(bool state) classic_bonded_only = state; } +bool input_get_classic_bonded_only(void) +{ + return classic_bonded_only; +} + static void input_device_enter_reconnect_mode(struct input_device *idev); static int connection_disconnect(struct input_device *idev, uint32_t flags); diff --git a/profiles/input/device.h b/profiles/input/device.h index 31740277..e3dcbce9 100755 --- a/profiles/input/device.h +++ b/profiles/input/device.h @@ -30,6 +30,7 @@ struct input_conn; void input_set_idle_timeout(int timeout); void input_enable_userspace_hid(bool state); void input_set_classic_bonded_only(bool state); +bool input_get_classic_bonded_only(void); #ifndef TIZEN_FEATURE_BLUEZ_MODIFY void input_set_auto_sec(bool state); diff --git a/profiles/input/server.c b/profiles/input/server.c index 279694c5..974b6153 100755 --- a/profiles/input/server.c +++ b/profiles/input/server.c @@ -308,6 +308,10 @@ int server_start(const bdaddr_t *src) struct input_server *server; GError *err = NULL; +#ifndef TIZEN_FEATURE_BLUEZ_MODIFY + BtIOSecLevel sec_level = input_get_classic_bonded_only() ? + BT_IO_SEC_MEDIUM : BT_IO_SEC_LOW; +#endif server = g_new0(struct input_server, 1); bacpy(&server->src, src); @@ -318,7 +322,7 @@ int server_start(const bdaddr_t *src) #ifdef TIZEN_BT_HID_DEVICE_ENABLE BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM, #else - BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, + BT_IO_OPT_SEC_LEVEL, sec_level, #endif BT_IO_OPT_INVALID); if (!server->ctrl) { @@ -335,7 +339,7 @@ int server_start(const bdaddr_t *src) #ifdef TIZEN_BT_HID_DEVICE_ENABLE BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM, #else - BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, + BT_IO_OPT_SEC_LEVEL, sec_level, #endif BT_IO_OPT_INVALID); if (!server->intr) {