6

I'm trying to pair two bluetooth devices, a mouse and a keyboard on fedora 26. I also have Windows 10 installed. What I did was: pair them on linux then on Windows, but when I tried to insert the key that I get from windows, I didn't find the entry [LinkKey] that was mentioned on the guide I followed

This is what I have on the info file for one of the devices:

[General]
Name=Designer Mouse
Appearance=0x03c2
AddressType=static
SupportedTechnologies=LE;
Trusted=true
Blocked=false
Services=00001800-0000-1000-8000-00805f9b34fb;00001801-0000-1000-8000-00805f9b34fb;0000180a-0000-1000-8000-00805f9b34fb;0000180f-0000-1000-8000-00805f9b34fb;00001812-0000-1000-8000-00805f9b34fb;

[IdentityResolvingKey]
Key=D8F3A0A146FEB991BF2ECD9756C8BDFA

[LocalSignatureKey]
Key=23AB7AF05C5AC930F9322CF44114856B
Counter=0
Authenticated=false

[LongTermKey]
Key=D2681BEA8B2C177B1AB8786F22C89DBB
Authenticated=0
EncSize=16
EDiv=48309
Rand=10283782112900107958

[DeviceID]
Source=2
Vendor=1118
Product=2053
Version=272

[ConnectionParameters]
MinInterval=6
MaxInterval=6
Latency=60
Timeout=300

According to the guide, it should be [LinkKey] entry, but there is none.

I already have the key from windows and also tried the method mentioned on this question

10

The problem is that your device is a Bluetooth LE (Low Energy) device and they are handled differently. I've found the following two solutions that helped me set up my Microsoft 3600 mouse for dual boot.

Check here for a tutorial on how to do it manually with Bluetooth LE devices: http://console.systems/2014/09/how-to-pair-low-energy-le-bluetooth.html

The key steps are:

  • First pair in Linux
  • Reboot
  • Pair in Windows
  • Get the key values from HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\BTHPORT\Parameters\Keys\{computer-bluetooth-mac}\{device-bluetooth-id}
    • It may be ControlSet001 or ControlSet002 which one cane be found in SYSTEM\Select but it's usually ControlSet001
  • This can be done e.g. using chntpw (from linux)
    cd {PATH_TO_WINDOWS_PARTITION}/Windows/System32/config/
    chntpw -e SYSTEM
  • Go to /var/lib/bluetooth/{computer-bluetooth-mac}
  • Check for a directory that closely resembles the device bluetooth id (they are usually a bit off because they may change whenever you pair again)
  • Rename that directory to match the device id
  • Edit the info file in the renamed directory
  • Copy the value of:
    • IRK into Key in IdentityResolvingKey
    • CSRK into Key in LocalSignatureKey
    • LTK into Key in LongTermKey
    • ERand into Rand: Take the hex value ab cd ef, byte reverse it (ef cd ab) and convert it into decimal (e.g. using the Programming mode of the calculator application)
    • EDIV into EDiv: Just take the hex value and convert it normally or use the decimal value directly if it is displayed (chntpw displays it)
  • Reboot

Alternatively
Use this python script by Mygod that does these steps for you: https://gist.github.com/Mygod/f390aabf53cf1406fc71166a47236ebf

I've used the script and just copied the Key entries for the groups LongTermKey, LocalSignatureKey and IdentityResolvingKey, and the EDiv and Rand entries in the LongTermKey group.

Notes for the linked manual route
It didn't really work for me which is why I didn't use it but these are common fixes if it didn't work that worked for other people:

  • The tutorial doesn't mention it but if you have an IRK entry, copy the value to the IdentityResolvingKey Key.
  • Don't copy the KeyLength to EncSize. Just leave it at what it is (in my case 16)
  • Don't forget to move the directory if the device names aren't exactly equal.
    • In my case the 5th group was counting up with every pairing.

Some additional help for the script:

  • It's run in linux.
  • The Windows partition has to be mounted.
  • The command should look like this:
    ./export-ble-infos.py -s {PATH_TO_WINDOWS_PARTITION}/Windows/System32/config/SYSTEM
    • You can also copy the SYSTEM file somewhere else and pass the path with -s {PATH}
  • It crashes if there are other bluetooth devices that windows knows which aren't LE or at least not in this format.
  • Magic! This worked for my bluetooth keyboard. I was a bit frustrated when this didn't work for me your answer showed me the light at the end of the tunnel :) – Frederick Zhang May 20 '18 at 11:38
  • Works great with MS 3600. To convert hex in bash try: echo $((16#efcdab)). – sZpak Jun 14 '18 at 18:27
  • @Stefan Fabian I'm sorry its been so long. I tried with the methods you mentioned but it didn't work. I'm guessing it has something to do with Fedora... Thanks anyway :) – Gonzalo Castillo Sep 7 '18 at 23:52
0

I have tried the method described in the previous answer (i.e. following the tutorial in http://console.systems/2014/09/how-to-pair-low-energy-le-bluetooth.html) to set up a Surface Keyboard to work seamlessly on a Surface Book 2 with a dual-boot configuration with Windows 10 and Ubuntu 18.04m LTS. I did not work.

First, to get the most of your Surface on Ubuntu 18.04 you need to install the Jakeday kernel (https://github.com/jakeday/linux-surface). Secondly, to use the Microsoft Surface Keyboard (bluetooth) you need to get the last version of bluez (https://medium.com/@overcode/fixing-bluetooth-in-ubuntu-pop-os-18-04-d4b8dbf7ddd6).

The idea is to reverse the order of pairing, disable authentication in Ubuntu and then copy the keys to the Windows 10 registry:

  1. Pair your Surface Keyboard in Windows 10. This will create the registry entries for the device.

  2. Reboot in Ubuntu.

  3. Pair the keyboard in Ubuntu and get the keyboard Bluetooth address from Settings>Bluetooth, click on the connected Surface Keyboard to copy the Address (in my system it’s at CE:2E:25:B9:D1:0C, keep this in mind!).
  4. Open a Terminal console and enter root: sudo -i.
  5. Edit the info Bluetooth configuration file to remove authentication. Go to the keyboard configuration directory: cd /var/lib. Get the Bluetooth MAC address by listing the content of this directory ls, then cd into the keyboard's configuration folder. In my system its cd /var/lib/bluetooth/B8:31:B5:9A:5D:15/CE:2E:25:B9:D1:0C, with the last bit being the keyboard Bluetooth address from step 3). Use your favorite editor to open the info file on this directory to change the [LocalSignatureKey] Authenticated field to false and the [LongTermKey] Authenticated field to 0. This is how the info file looks on my machine:
[General]
Name=Surface Keyboard
Appearance=0x03c1
AddressType=static
SupportedTechnologies=LE;
Trusted=true
Blocked=false
Services=00001800-0000-1000-8000-00805f9b34fb;00001801-0000-1000-8000-00805f9b34fb;0000180a-0000-1000-8000-00805f9b34fb;0000180f-0000-1000-8000-00805f9b34fb;00001812-0000-1000-8000-00805f9b34fb;[ConnectionParameters]
MinInterval=12
MaxInterval=12
Latency=20
Timeout=200

[DeviceID]
Source=2
Vendor=1118
Product=2327
Version=304

[IdentityResolvingKey]
Key=BAC8FF051F3EB6014D0B66678C725435

[LocalSignatureKey]
Key=C7E1BDA700A3213E12463D801F4B4496
Counter=0
Authenticated=false

[LongTermKey]
Key=721CEF56A21CFD5CB0BEF8F565F7F5A6
Authenticated=0
EncSize=16
EDiv=44718
Rand=14981484917123435222
  1. Turn off your Surface Keyboard (extract the batteries) and reboot Ubuntu.
  2. In Settings>Bluetooth>Surface Keyboard turn on the connection and re-insert the batteries. Your keyboard should connect and work properly. Reboot again (without extracting the batteries) to check that the keyboard is working properly.
  3. Save/Print the info file to access the keys to update the Windows 10 registry entries for the keyboard. In my case I have saved the file to a disk which is mounted on both Windows 10 and Ubuntu (to be able to copy/type data into the Windows 10 registry).
  4. Turn off your Surface Keyboard (extract the batteries) and reboot into Windows 10. Use PSTools's psexec to edit the registry. First, download PSTools from http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx . Extract the zip file and open a terminal console with administrator privileges, change directory to the extracted files and run psexec -s -i regedit.exe, this allows access to the privileged registry entries where the pairing keys are stored.
  5. Copy the keys from the info file to the Windows registry entries for the Surface Keyboard. First, you need to rename the two entries for the keyboard. Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters. Rename the entries in under Devices and Keys which correspond to the Surface Keyboard. Each time you pair the keyboard, the address changes slightly to differentiate from prior pairings. In my case the initial Windows 10 pairing was on ce2e25b810c while the subsequent Ubuntu pairing was on CE:2E:25:B9:D1:0C (almost same address, excluding the : and with letters in lower case, but notice the increase in b8 to B9). Right-click on the registry names which correspond to the original Windows 10 pairing address to rename to the Ubuntu address .

After renaming the registry entries it looked like this on my system: enter image description here

  1. Copy the keys from the info file to the Keys/{MAC Address}/{Bluetooth Address} registry entry (\Keys\b831b59a5d15\ce2e25b9d10c in my example). First, Modify the Address field by right-clicking on it and updating the Bluetooth address to the one used to pair in Ubuntu (in HEX from 'ce2e25b810c' in the original Windows 10 pairing to 'ce2e25b910c' in Ubuntu in my example).

enter image description here

Similarly, Modify each of the following registry fields copying/typing the data from the Ubuntu info file to the corresponding Windows 10 registry field:

  • IdentityResolvingKey Key value goes into the IRK registry field. When modifying, erase the HEX entries and type the Key from the info file saved on step 8) in HEXADECIMAL format.

  • LocalSignatureKey Key value goes into CSRK

  • LongTermKey Key goes into LTK

  • Rand goes into ERand: enter the data from the info file in DECIMAL format

  • EDiv goes into EDiv: enter the data in DECIMAL format.

12.Copy the Interval, Latency and Timeout values from the info file to the Device registry entry (all in DECIMAL format):

  • MaxInterval goes into LERemoteConnParamsIntervalMax

  • MinInterval goes into LERemoteConnParamsIntervalMin

  • Latency goes into LERemoteConnParamsLatency

  • Timeout goes into LERemoteConnParamsLSTO

enter image description here

  1. Reboot Windows and re-insert the batteries into the Surface Keyboard, which should connect to the Windows Bluetooth service. You should be able to boot seamlessly from Windows 10 to Ubuntu 18.04 and vice versa without having to re-pair your keyboard.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.