Skip to content

Commit 7383354

Browse files
jwrdegoedeJiri Kosina
authored andcommitted
HID: logitech-dj/hidpp: Add info/warn/err messages about 27 MHz keyboard encryption
By default 27 MHz Logitech keyboards send the keypresses to the receiver in plain text. Logitech's Windows "Keyboard and Mouse settings" tool allows configuring encryption for the keyboard wireless link. Now there also is a Linux tool for setting this up: https://gitlab.freedesktop.org/jwrdegoede/logitech-27mhz-keyboard-encryption-setup Once a keyboard is paired in encrypted mode, it will no longer work with any receiver other then the receiver it was paired with. If a user accidentally tries to pair another keyboard with the receiver with which a keyboard has been paired in encrypted mode, then the receiver looses the encryption key and the originally paired keyboard will no longer work with either that receiver, or another receiver until the keyboard's encryption key is rewritten by another encrypted mode pairing using the tool. Or until it is reset by following a special reset procedure. This commit adds 3 new log messages related to 27 MHz keyboard link encryption to the Logitech dj / hidpp drivers: 1. An info level message when keyboard encryption is being used 2. A warning message when keyboard encryption is not used 3. An error message when the encryption key has been lost and the keyboard will not work because of this Messages 2. and 3. contain a link to the userspace tool to setup the encryption. The linked page also contains instructions to clear the key (without needing the tool) to help a user recover from the keyboard not working in case 3. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent efd8929 commit 7383354

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

drivers/hid/hid-logitech-dj.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
#define HIDPP_DEVICE_TYPE_MASK GENMASK(3, 0)
101101
#define HIDPP_LINK_STATUS_MASK BIT(6)
102102
#define HIDPP_MANUFACTURER_MASK BIT(7)
103+
#define HIDPP_27MHZ_SECURE_MASK BIT(7)
103104

104105
#define HIDPP_DEVICE_TYPE_KEYBOARD 1
105106
#define HIDPP_DEVICE_TYPE_MOUSE 2
@@ -984,6 +985,13 @@ static void logi_hidpp_dev_conn_notif_27mhz(struct hid_device *hdev,
984985
workitem->reports_supported |= STD_MOUSE | HIDPP;
985986
break;
986987
case 3: /* Index 3 is always the keyboard */
988+
if (hidpp_report->params[HIDPP_PARAM_DEVICE_INFO] & HIDPP_27MHZ_SECURE_MASK) {
989+
hid_info(hdev, "Keyboard connection is encrypted\n");
990+
} else {
991+
hid_warn(hdev, "Keyboard events are send over the air in plain-text / unencrypted\n");
992+
hid_warn(hdev, "See: https://gitlab.freedesktop.org/jwrdegoede/logitech-27mhz-keyboard-encryption-setup/\n");
993+
}
994+
fallthrough;
987995
case 4: /* Index 4 is used for an optional separate numpad */
988996
workitem->device_type = HIDPP_DEVICE_TYPE_KEYBOARD;
989997
workitem->reports_supported |= STD_KEYBOARD | MULTIMEDIA |

drivers/hid/hid-logitech-hidpp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ MODULE_PARM_DESC(disable_tap_to_click,
5656
#define HIDPP_SUB_ID_CONSUMER_VENDOR_KEYS 0x03
5757
#define HIDPP_SUB_ID_ROLLER 0x05
5858
#define HIDPP_SUB_ID_MOUSE_EXTRA_BTNS 0x06
59+
#define HIDPP_SUB_ID_USER_IFACE_EVENT 0x08
60+
#define HIDPP_USER_IFACE_EVENT_ENCRYPTION_KEY_LOST BIT(5)
5961

6062
#define HIDPP_QUIRK_CLASS_WTP BIT(0)
6163
#define HIDPP_QUIRK_CLASS_M560 BIT(1)
@@ -3528,6 +3530,16 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
35283530
return 1;
35293531
}
35303532

3533+
if (hidpp->hid_dev->group == HID_GROUP_LOGITECH_27MHZ_DEVICE &&
3534+
data[0] == REPORT_ID_HIDPP_SHORT &&
3535+
data[2] == HIDPP_SUB_ID_USER_IFACE_EVENT &&
3536+
(data[3] & HIDPP_USER_IFACE_EVENT_ENCRYPTION_KEY_LOST)) {
3537+
dev_err_ratelimited(&hidpp->hid_dev->dev,
3538+
"Error the keyboard's wireless encryption key has been lost, your keyboard will not work unless you re-configure encryption.\n");
3539+
dev_err_ratelimited(&hidpp->hid_dev->dev,
3540+
"See: https://gitlab.freedesktop.org/jwrdegoede/logitech-27mhz-keyboard-encryption-setup/\n");
3541+
}
3542+
35313543
if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) {
35323544
ret = hidpp20_battery_event_1000(hidpp, data, size);
35333545
if (ret != 0)

0 commit comments

Comments
 (0)