Bluetooth mouse in dual boot of Windows 10 and Linux

I prefer the Bluetooth mouse to the wireless USB mouse because I feel USB mouses caused chattering when I used them for more than one year. I don’t see the problem with Bluetooth mouse.

However I had one critical problem to authenticate Bluetooth 4.0 mouse in the dual boot.

After I made a pairing between Bluetooth mouse and MS-Windows 10, rebooted the system, and launched Fedora 27, and made a pairing between the mouse and Fedora, the mouse worked fine.

But after rebooted the system again and launched Windows 10, the Bluetooth mouse didn’t work and I had to make a pairing by reboot.

It seems the Bluetooth authentication saves a unique key in the host and I got how to fix the problem.

0. Make a pairing in Fedora 27

1. Make a pairing in Windows 10

2. Get PsTools to read some secret regedit keys

3. Right click on MS-DOS prompt and launch it with an Administrator privilege

3. PsExec64.exe -s -i regedit

4. Save the “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys\${DEVICE}\${ADDRESS}

My data is:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys\001bdc0e3454\c4be84437bd0]
"LTK"=hex:57,30,62,7c,8d,e8,3b,a5,5c,d1,82,fa,bb,a0,e5,71
"KeyLength"=dword:00000000
"ERand"=hex(b):80,07,0b,e3,63,85,dd,2b
"EDIV"=dword:0000f548
"IRK"=hex:aa,fd,93,6f,05,c3,e7,08,47,70,43,f3,0a,06,df,1a
"Address"=hex(b):d0,6a,43,84,be,c4,00,00
"AddressType"=dword:00000000
"CSRK"=hex:a2,b3,df,00,25,5c,ff,4d,9c,4c,74,06,e2,cb,07,b7
"OutboundSignCounter"=dword:00000000
"AuthReq"=dword:00000001

5. Reboot the system and Launch Fedora 27

6. Modify /var/lib/bluetooth/${DEVICE}/${ADDRESS}/info with root

  • If $DEVICE or $ADDRESS is different, you have to move the directory. My path is /var/lib/bluetooth/00:1B:DC:0E:34:54/C4:BE:84:43:7B:D0/info and no problem.
  • Copy LTK in Windows to Key in LongTermKey in Linux with capital characters and no comma
  • Reverse ERand in Windows and convert the hexadecimal without comma to the decimal and paste it to Rand in LongTermKey in Linux. In my case, ERand is 80070be36385dd2b and the reverse is 2bdd8563e30b0780 and the decimal Rand is 3160829177541363584
  • Convert the hexadecimal of EDIV in Windows to the decimal and paste it to EDiv in LongTermKey in Linux. It’s no reverse. In my case, EDIV is f548 and the decimal EDiv is 62792
  • Copy IRK in Windows to Key in IdentifyResolvingKey in Linux with capital characters and no comma
  • Copy CSRK in Windows to Key in LocalSignatureKey in Linux with capital characters and no comma

7. Run systemctl restart bluetooth with root

My modified /var/lib/bluetooth/00:1B:DC:0E:34:54/C4:BE:84:43:7B:D0/info file is:
[General]
Name=ELECOM Laser Mouse
Appearance=0x03c2
AddressType=public
SupportedTechnologies=LE;
Trusted=true
Blocked=false
Services=00001800-0000-1000-8....
[IdentityResolvingKey]
Key=AAFD936F05C3E708477043F30A06DF1A
[RemoteSignatureKey]
Key=9437CEEC9FD5FEAA30410C1713C6D6CF
Counter=0
Authenticated=false
[LocalSignatureKey]
Key=A2B3DF00255CFF4D9C4C7406E2CB07B7
Counter=0
Authenticated=false
[LongTermKey]
Key=5730627C8DE83BA55CD182FABBA0E571
Authenticated=0
EncSize=16
EDiv=62792
Rand=3160829177541363584
[SlaveLongTermKey]
Key=DA36C669AB37846E1CA15C8A6055912D
Authenticated=0
EncSize=16
EDiv=22299
Rand=4757000163648466617

Then my Bluetooth mouse in dual boot envirinemnt works fine.

About fujiwara

I'm an open-sourced desktop i18n developer.
This entry was posted in RedHat and tagged , . Bookmark the permalink.

23 Responses to Bluetooth mouse in dual boot of Windows 10 and Linux

  1. pablo says:

    I have a Logitech MX master, which I bought for two reasons, one of them being bluetooth. But I see myself forced to use the USB adapter because if I use it through bluetooh my Wifi connection starts lagging more and more until it just does not reach the host (packet loss 100%).

    I see that behaviour in an Asus UX31A and a Dell Latitude E7470, both with Fedora 26 and now 27. Do you know why could that be or where to report it?

  2. I’m using Ubuntu 17.10 and this procedure doesn’t work for me.

    • fujiwara says:

      Probably I can check if you send me Windows 10 registory file and Linux info files.
      Also probably I think you need to reboot the system after you modify the info file.

  3. Ary Kleinerman says:

    I am using Archlinux and you don’t have to reverse ERand from Windows. You just only have to convert from HEX to decimal. Thx

    • James says:

      Ubuntu 18.04 here.
      Erand does not have to be reversed but only converted to decimal.

      • Anyoneelse says:

        Does this procedure worked for you?
        Using ubunto 18 and tried the exact procedure above and also with erand not reversed but nothing worked for me.
        Thanks

      • fujiwara says:

        Yes, I use this in Fedora.

      • Michał says:

        Ubuntu 18.04 – Mx Anywhere 2 mouse works well, but:
        – ERand have to be reversed.
        – /var/lib/bluetooth/… path have to be slightly modified to be in accordance with Windows registry value: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys\…

  4. Mat Lilly says:

    echo $(( 16#$(echo “1C EE 99 08 74 B9 F5 77 7E CA C4 CC 08 37 08 C5” | sed ‘s/ //g’|rev) ))
    … but I am seeing some people say don’t reverse it

  5. Lee Seng says:

    i noticed that my bluetooth mac was E2:20:C9:ED:5B:F5 in ubuntu, after pairing with windows 10, it becomes E2:20:C9:ED:5B:F6. Need to rename folder name, E2:20:C9:ED:5B:F5 to E2:20:C9:ED:5B:F6 in ubuntu 18.04, so that the pairing works. my mouse is logitech M590

  6. 4tmelDriver says:

    Manjaro / Arch linux here.

    Some people noticed, that it is not necessary to reverse ERand.
    At first I reversed it, but this didn’t seem to work.
    Then I tried without reversing: then it worked.

  7. Sampson Fung says:

    I have Microsoft Mouse 3600.
    Latest Windows 10 updateded as of 2020Jan05 and Fedora 31.
    I followed exactly your guide and my Mouse3600 works in both Windows and Fedora without re-pairing now.

    Thank you very much!
    ps. The critical part is the ERand and Ediv editings. Which is not mentioned in other “solutions” in the Internet.

  8. Boris says:

    Thanks for your guide!
    But it’s not working for me.
    Keyboard: “Microsoft Surface keyboard”
    OS: Windows 10 and Ubuntu 19.10
    I followed exactly your guide and tried reversing and without reversing ERand.

  9. omdaddi says:

    Brilliant, thank you. Followed it exactly in Debian Buster and it worked immediately.

  10. David C. says:

    Thanks!!!!!!!! I tried in Ubuntu Mate 18.04 and it runs perfectly. Now I will fight with the Headphones.

  11. Pingback: Bluetooth mouse in dual boot of Windows 10 and Linux #2 | DesktopI18N's Blog

  12. fujiwara says:

    FYI. I tried another laptop and got the different format.

    Bluetooth mouse in dual boot of Windows 10 and Linux #2

  13. The MXAnywhere mouse allows one to click the “switch” button at the bottom and switch to a different “OS”.

  14. Bernhard S. says:

    Hi, with both the newest Win10 and Ubuntu20.10 your recept works. Thank you!

  15. Gordon Wells says:

    This procedure works for me for my Logitech G604 mouse in Manjaro, with and without reversing Erand. But profile switching in G HUB stops working upon rebooting back to Windows. The default button assignments remain, but G HUB doesn’t see the mouse and let me edit profiles unless I pair again.

  16. 刘润 says:

    thanks it works in ubuntu 20.04 & windows 11 with bluetooth 5.0

Leave a comment