首页 > 解决方案 > 在 iOS 上为 BLE 配对设置 IO 功能

问题描述

在我的用例中,BLE 外设没有任何真正的 IO 功能,但需要 MITM 保护。

作为一种解决方案,密码输入配对方法与通过其他通道交换的 6 位密码一起使用。与带外配对相同的理念,但 iOS 不支持 OOB,因此下一个最好的方法是以与 OOB 相同的方式使用密码输入 - 区别在于 6 位密码而不是 128 位密钥(总比没有好)。

问题是,要让这种情况按预期工作,Central 和 Peripheral 都需要将其 IO 上限设置为KeyboardOnly,这将导致PasskeyEntry: initiator and responder inputs配对方法。

可能的组合,复制自BT Core Specification [Vol 3] Part H, Section 2.3.5.1, Table 2.8: Mapping of IO capabilities to key generation method

                    /--------------------------------------------------------------------\  
   /-----------\   /                        Initiator (iOS/Android)                       \ 
  /  Responder  \ |-------------+--------------+---------------------+---------------------|
 /  (Peripheral) \| DisplayOnly | DisplayYesNo |     KeyboardOnly    |   KeyboardDisplay   |
|-----------------|-------------+--------------+---------------------+---------------------+
|   DisplayOnly   |             M1             |                     M3                    |
+-----------------+         Just Works         |               Passkey Entry:              |
|   DisplayYesNo  |                            |    Responder displays, initiator inputs   |
+-----------------+----------------------------+---------------------+---------------------+
|                 |                            |          M4         |                     |
|   KeyboardOnly  |                            |    Passkey Entry:   |                     |
|                 |             M2             |    initiator and    |          M2         |
|                 |       Passkey Entry:       |   responder inputs  |    Passkey Entry:   |
+-----------------+     Initiator displays,    +---------------------+ Initiator displays, |
|                 |      responder inputs      |          M3         |   responder inputs  |
| KeyboardDisplay |                            |    Passkey Entry:   |                     |
|                 |                            | Responder displays, |                     |
|                 |                            |   initiator inputs  |                     |
+-----------------+----------------------------+---------------------+---------------------+

M1:不适合,因为它不提供身份验证、不提供窃听保护、不提供 MITM 保护。
M2 : 不可能,因为Initiator 显示的密码是在 iOS/Android 堆栈中生成的随机数,无法手动设置。
M3:与M2相同,但理论上外围设备上的 BT 堆栈最终可能会被修补以生成“特定随机数”。
M4:可以在两个设备上输入自定义密码的唯一方法。

Android为此目的具有BluetoothConfigManager::setLeIoCapability方法

import com.google.android.things.bluetooth.BluetoothConfigManager

val manager = BluetoothConfigManager.getInstance()
// Report that this device can accept keyboard user input only
manager.leIoCapability = BluetoothConfigManager.IO_CAPABILITY_IN
// TODO: Adapter needs to be restarted using BluetoothAdapter::disable() and enable()!

是否可以在 iOS(核心蓝牙)上做到这一点?

感谢您提供任何想法的帮助!

标签: iosswiftbluetooth-lowenergycore-bluetooth

解决方案


你已经回答了你自己的问题。我认为 M3 尽你所能(在你的奴隶上生成一个随机数,然后使用 OOB 将其传输给用户,以便他/她可以在 iOS 设备上输入密码)。除此之外,您无法更改 iOS 行为。不幸的是,Apple 没有在 iOS 上提供任何配对/绑定/安全 API,这很糟糕,因此您永远无法知道 BLE 操作是否“安全”。

如果您真的想要 iOS/BLE 的安全性,那么您应该在 BLE 之上拥有自己的安全层(然后假定 BLE 不安全)。


推荐阅读