Search code examples
androidbluetooth-lowenergy

Android How to Use "Diffie Hellman Key Exchange" Method in Secure BLE Connection?


I'm designing a circuit including the RF-BM-BG22A1 BLE 5.2 module and writing the embedded software myself. At the same time, I am writing an Android application that will connect and communicate with this module over BLE.

I am using the following project's classes(SerialListener,SerialService,SerialSocket...) on Android side. (https://github.com/kai-morich/SimpleBluetoothLeTerminal)

For now, I can pair & bond with BLE module using pin(entered from phone) and communicate with it without any problem.

Not sure how safe this is.

I want to use "LE Secure Connections" with "Diffie Hellman Key Exchange".

Which side decides which security method to use and how?

Is there anything extra that needs to be done on the Android side?


Solution

  • Both sides advertise their I/O capabilites and if LE Secure Connections are supported or not. The protocol then picks the highest possible security level based on these properties.

    Android supports LESC (at least in recent versions) and all I/O capabilities, so the security level will depend on what the remote device is capable of.

    If you simply configure your BLE module to support LESC, then that feature will hence always be used when pairing with an Android device.

    Unfortunately, Android's Bluetooth API does not, currently, include any functionality to check or enforce that LE Secure Connections is used or not. This means that MITM attacks, that for example downgrades to non-LESC, when phone acts as central, are still possible without anyone noticing (see https://www.usenix.org/conference/usenixsecurity20/presentation/zhang-yue).