ios - 在 iOS 上为 BLE 配对设置 IO 功能

标签 ios swift bluetooth-lowenergy core-bluetooth

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

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

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

可能的组合,复制自 BT Core Specification [第 3 卷] H 部分,第 2.3.5.1 节,表 2.8:IO 能力到 key 生成方法的映射:

                    /--------------------------------------------------------------------\  
   /-----------\   /                        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 :可以在两个设备上输入自定义密码的唯一方法。

安卓有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(核心蓝牙)上做到这一点?

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

最佳答案

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

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

关于ios - 在 iOS 上为 BLE 配对设置 IO 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61342299/

相关文章:

ios - 在 gamescene.sks 中创建带边界的空节点

ios - 将 WKInterfaceController 滚动回顶部

swift - 核心蓝牙状态恢复只触发一次

xcode - SKEmitterNode 不显示粒子

ios - 使用 Playground 在模拟器中闪烁 UIView

ios - 在iOS中如何在不使用硬件地址扫描的情况下连接到外设

python-3.x - 无法连接到套接字/opt/local/var/run/dbus/system_bus_socket : No such file or directory

objective-c - 如何在 Objective-C 中引用协议(protocol)?

iphone - mp3 文件的 http 直播

ios - 我如何快速出列一个单元格?