2023-06-16 14:02:34

by Christian Eggers

[permalink] [raw]
Subject: Just-Works re-pairing doesn't work

Kernel: 5.15.113
Bluez: 5.65
Peer: iPad with i.OS 15.7
Application:
- Embedded L2CAP application with own agent.
- Agent has been registered with "NoInputNoOutput".
- BT_SECURITY for L2CAP socket has been set to 2.

Problem:
Re-pairing (pairing again after "removing"/"ignoring" the Linux device in the system
settings of the iOS device) doesn't work. In order to successfully pair
again, I first have also to "remove" the iOS device on the Linux system using
bluetoothctl.

See also (looks equal to my problem):
https://stackoverflow.com/questions/75362887/linuxbluezbluetooth-failed-to-re-connect-after-forgetting-while-using-noin

I tried the following patch:
https://patches.linaro.org/project/linux-bluetooth/patch/[email protected]/

After applying this patch, re-pairing works fine on my system.

I don't have the oversight to tell whether the patch above is correct.
Additionally I am unsure whether the "JustWorksRepairing" setting has
any meaning on my system (as I have implemented an own agent within my application).


regards,
Christian



/etc/bluetooth/main.conf:
------------------------8<------------------------
AlwaysPairable = true
JustWorksRepairing = always
------------------------>8------------------------


Log:
> ACL Data RX: Handle 25 flags 0x02 dlen 11 #16 [hci0] 2.807328
SMP: Pairing Request (0x01) len 6
IO capability: KeyboardDisplay (0x04)
OOB data: Authentication data not present (0x00)
Authentication requirement: Bonding, MITM, SC, No Keypresses, CT2 (0x2d)
Max encryption key size: 16
Initiator key distribution: EncKey IdKey LinkKey (0x0b)
Responder key distribution: EncKey IdKey LinkKey (0x0b)
> ACL Data RX: Handle 25 flags 0x02 dlen 11 #17 [hci0] 2.807436
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Primary Service (0x2800)
< ACL Data TX: Handle 25 flags 0x00 dlen 11 #18 [hci0] 2.807514
SMP: Pairing Response (0x02) len 6
IO capability: NoInputNoOutput (0x03)
OOB data: Authentication data not present (0x00)
Authentication requirement: Bonding, MITM, SC, No Keypresses, CT2 (0x2d)
Max encryption key size: 16
Initiator key distribution: EncKey IdKey (0x03)
Responder key distribution: EncKey (0x01)
...

> ACL Data RX: Handle 25 flags 0x02 dlen 69 #46 [hci0] 8.507352
SMP: Pairing Public Key (0x0c) len 64
X: 8b6f72774ab48d0246be000d4555e2f99f9799518be4bccc3e3e509a31b2ae03
Y: bf3f03e9f08c67b1e843be1ca7a0522686216828becefa40f6622e3322e4db5e
< ACL Data TX: Handle 25 flags 0x00 dlen 69 #47 [hci0] 8.545335
SMP: Pairing Public Key (0x0c) len 64
X: 1975cc04c4ef4444a202898c0ad006e01d1ff5fb64b6648fdb585004987c6c28
Y: fbe9d105bd2d0c134618e87ad850443021d3c30d03e452c9be3a67bc071b548e
< ACL Data TX: Handle 25 flags 0x00 dlen 21 #48 [hci0] 8.545395
SMP: Pairing Confirm (0x03) len 16
Confim value: 89353a66cb49c378698c73bbb91ed203
> HCI Event: Number of Completed Packets (0x13) plen 5 #49 [hci0] 8.568106
Num handles: 1
Handle: 25 Address: 7F:C0:E4:47:71:5A (Resolvable)
Count: 1
> ACL Data RX: Handle 25 flags 0x02 dlen 21 #50 [hci0] 8.597228
SMP: Pairing Random (0x04) len 16
Random value: e31d5e3904a034178b59ee6215691095
@ MGMT Event: User Confirmation Request (0x000f) plen 12 {0x0001} [hci0] 8.597365
LE Address: 54:62:E2:37:6A:A9 (OUI 54-62-E2)
Confirm hint: 0x01
Value: 0x00000000
< ACL Data TX: Handle 25 flags 0x00 dlen 21 #51 [hci0] 8.597400
SMP: Pairing Random (0x04) len 16
Random value: 484ff14d26537f86dfbefd924fbd8eb9
@ MGMT Command: User Confirmation Reply (0x001c) plen 7 {0x0001} [hci0] 8.597845
LE Address: 54:62:E2:37:6A:A9 (OUI 54-62-E2)
@ MGMT Event: Command Complete (0x0001) plen 10 {0x0001} [hci0] 8.597876
User Confirmation Reply (0x001c) plen 7
Status: Success (0x00)
LE Address: 54:62:E2:37:6A:A9 (OUI 54-62-E2)
> HCI Event: Number of Completed Packets (0x13) plen 5 #52 [hci0] 8.598099
Num handles: 1
Handle: 25 Address: 7F:C0:E4:47:71:5A (Resolvable)
Count: 1
> ACL Data RX: Handle 25 flags 0x02 dlen 21 #53 [hci0] 8.657238
SMP: Pairing DHKey Check (0x0d) len 16
E: 1ffb663bb5033f7127b4fb43fb0e5c00
@ MGMT Event: Authentication Failed (0x0011) plen 8 {0x0001} [hci0] 8.657418
LE Address: 54:62:E2:37:6A:A9 (OUI 54-62-E2)
Status: Authentication Failed (0x05)
< ACL Data TX: Handle 25 flags 0x00 dlen 6 #54 [hci0] 8.657466
SMP: Pairing Failed (0x05) len 1
Reason: DHKey check failed (0x0b)