forked from auracaster/bumble_mirror
fix legacy pairing with oob
This commit is contained in:
26
apps/pair.py
26
apps/pair.py
@@ -402,14 +402,19 @@ async def pair(
|
|||||||
# Create an OOB context if needed
|
# Create an OOB context if needed
|
||||||
if oob:
|
if oob:
|
||||||
our_oob_context = OobContext()
|
our_oob_context = OobContext()
|
||||||
shared_data = (
|
if oob == '-':
|
||||||
None
|
shared_data = None
|
||||||
if oob == '-'
|
legacy_context = OobLegacyContext()
|
||||||
else OobData.from_ad(
|
else:
|
||||||
|
oob_data = OobData.from_ad(
|
||||||
AdvertisingData.from_bytes(bytes.fromhex(oob))
|
AdvertisingData.from_bytes(bytes.fromhex(oob))
|
||||||
).shared_data
|
)
|
||||||
)
|
shared_data = oob_data.shared_data
|
||||||
legacy_context = OobLegacyContext()
|
legacy_context = oob_data.legacy_context
|
||||||
|
if legacy_context is None and not sc:
|
||||||
|
print(color('OOB pairing in legacy mode requires TK', 'red'))
|
||||||
|
return
|
||||||
|
|
||||||
oob_contexts = PairingConfig.OobConfig(
|
oob_contexts = PairingConfig.OobConfig(
|
||||||
our_context=our_oob_context,
|
our_context=our_oob_context,
|
||||||
peer_data=shared_data,
|
peer_data=shared_data,
|
||||||
@@ -419,7 +424,9 @@ async def pair(
|
|||||||
print(color('@@@ OOB Data:', 'yellow'))
|
print(color('@@@ OOB Data:', 'yellow'))
|
||||||
if shared_data is None:
|
if shared_data is None:
|
||||||
oob_data = OobData(
|
oob_data = OobData(
|
||||||
address=device.random_address, shared_data=our_oob_context.share()
|
address=device.random_address,
|
||||||
|
shared_data=our_oob_context.share(),
|
||||||
|
legacy_context=(None if sc else legacy_context),
|
||||||
)
|
)
|
||||||
print(
|
print(
|
||||||
color(
|
color(
|
||||||
@@ -427,7 +434,8 @@ async def pair(
|
|||||||
'yellow',
|
'yellow',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print(color(f'@@@ TK={legacy_context.tk.hex()}', 'yellow'))
|
if legacy_context:
|
||||||
|
print(color(f'@@@ TK={legacy_context.tk.hex()}', 'yellow'))
|
||||||
print(color('@@@-----------------------------------', 'yellow'))
|
print(color('@@@-----------------------------------', 'yellow'))
|
||||||
else:
|
else:
|
||||||
oob_contexts = None
|
oob_contexts = None
|
||||||
|
|||||||
@@ -762,7 +762,9 @@ class Session:
|
|||||||
|
|
||||||
# OOB
|
# OOB
|
||||||
self.oob_data_flag = (
|
self.oob_data_flag = (
|
||||||
1 if pairing_config.oob and pairing_config.oob.peer_data else 0
|
1
|
||||||
|
if pairing_config.oob and (not self.sc or pairing_config.oob.peer_data)
|
||||||
|
else 0
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set up addresses
|
# Set up addresses
|
||||||
|
|||||||
Reference in New Issue
Block a user