如何确定蓝牙连接是否已加密? [英] How to find out if Bluetooth connection is encrypted?

查看:744
本文介绍了如何确定蓝牙连接是否已加密?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立ble设备和移动设备之间的BLE连接.该连接首先是不安全的,但将更新为LESC,仅在设备端有效.

I am creating an BLE connection between a ble device and a mobile. the connection is first unsecured but will be updated to LESC just works from device side.

到目前为止,效果很好.

This works fine so far.

在Android(目标SDK 28)中,我想检查(更好地获得回调)蓝牙连接是否已加密.我正在使用BLE UART服务示例.

In Android (target SDK 28) I want to check (better getting an callback) if bluetooth connection is encrypted. I am using a BLE UART Service example.

我可以访问BluetoothGatt和BluetoothDevice对象.但是我发现的所有方法,变量都是private或@SystemApi.

I have access to an BluetoothGatt and BluetoothDevice object. But all methods, variables I found are either private or @SystemApi.

任何人都可以帮忙吗?

下面的类声明部分显示了可用的对象:

Following some part of class declaration showing the available objects:

public class UARTService extends Service {

private final static String TAG = UARTService.class.getSimpleName();

private BluetoothManager mBluetoothManager;
private BluetoothAdapter mBluetoothAdapter;
private String mBluetoothDeviceAddress;
private BluetoothGatt mBluetoothGatt;
...

}

推荐答案

对不起,但我认为您不能,这确实很糟糕.根据蓝牙规范,应该能够为每个GATT请求指定一个安全级别,例如,您可以使用Windows的BLE API来指定此安全级别.但是Android似乎没有该功能.没有该功能,它将破坏BLE安全的整个思想.您可以检查设备是否已绑定,但这不能保证连接被加密.

Sorry but I don't think you can, which really sucks. According to the Bluetooth specification one should be able to specify a security level for every GATT request, which you can do with for example Windows's BLE API. But Android doesn't seem to have that feature. Without that feature, it kind of destroys the whole idea of BLE security. You can check if the device is bonded but that is not a guarantee for the connection being encrypted.

https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createL2capChannel(int)但是,如果您使用L2CAP CoC,则可以用于强制使用MITM保护的链接,但是即使这样您也不能强制使用LESC(可能会使用传统MITM配对,但不会完全无法抵御MITM.

https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createL2capChannel(int) however can be used to force a MITM-secured link if you use L2CAP CoC, but you even then can't force LESC (Legacy MITM-pairing might be used which doesn't really protect from MITM at all).

这篇关于如何确定蓝牙连接是否已加密?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆