Questions about BLE security settings

Hello, I'm an engineer living in Japan.

【Development environment】
"PCA10040 (nRF52832)" x 2 (central/peripheral)
"SDK:17.1.0"
"IDE:Segger Embedded Studio for ARM7.10a"

This is a question regarding BLE security settings.

Below are the security measures I would like to implement on the peripheral side.

●Security settings that I want to set
1. When connecting for the first time, allow connections from any central device.

2. For the second and subsequent connections, only the central device connected the first time will be accepted.
 * It does not appear when searching from the central device.

3. Delete connection information only when a specific button is pressed, and accept only the central device when connecting for the first time.

I used "ble_app_hids_keyboard" stored in the SDK of Ver17.1.0 as a reference.
Set up security using “peer manager” + “whitelist”
I ported it to a program I created, but the connection refusal behavior did not work.

When you check the log output from the "ble_app_hids_keyboard" sample program,
I understand that if the following log is output, the connection will be refused from the second generation.

"<info> app: m_whitelist_peer_cnt 1, MAX_PEERS_WLIST 8"
In the program I created, even if I connect from central
The connection could not be refused because the status did not change from "m_whitelist_peer_cnt 0".
I have confirmed that the advertisement signal from the peripheral is received by the central and is working.

Question 1)
Please tell me the conditions under which "m_whitelist_peer_cnt" is counted up in the sample program "ble_app_hids_keyboard".

Question 2)
Please let me know if there is a way to deny connections from the second device onwards using peer manager.
 
Question 3)
It seems possible to make the whitelist work without using a peer manager.
Please tell me the disadvantages (risks) in that case.
*This is the code written in "nrf_dfu_ble.c".

Question 4)
Please tell me the recommended method for implementing the above "security settings that I want to set".
It would be helpful if you could tell me with sample code.

  • Hi 輝隆,

    It's not common way of handling BLE device using the Bluetooth setting. You may want to try using an app, for example nRF Connect app to connect and disconnect. 
    There could be some reason that the phone doesn't want to disconnect. From what I can see, it's most likely that the phone didn't send the disconnect command.

    You may want to capture a sniffer trace of the connection, so that we can check if the phone actually send the connection termination request or not. 

    But as I said the common way of handling BLE device is to use an app. 

    Regarding your whitelisting question, the whitelist when used on one side of the connection is independent/transparent to the other side of the the connection. This mean if you use whitelist on the advertiser, it simply filter out the connection request or scan request of other scanner/central. It only allow the connect request or scan request from the scanners/centrals that are in the list. 

    So the central doesn't need to know about if the advertiser is using whitelist or not. 

    If you want to implement whitelist on the central side it's fine. But you should have a reason for that. 

    Whitelisting doesn't provide much of security from my opinion. Any device can spoof the peer address and can pass through the whitelist. The actual security you can implement is to do pairing and bonding between the two device. 

  • Hello, Hung Bui

    Last weekend, I was able to develop a central side sample program using nRF52832.
    I can now connect the nRF52832 to the peripheral side program "25841.main.c" and build a product that takes into account the security behavior I expected.

    thank you very much.

    Security could not be achieved with "ble_app_hrs_c", which was originally used as a central program.
    After looking into it again, I thought that there might be some hints in the sample program "ble_app_multirole_lesc", and when I worked on it, I was able to create a central program that could execute all the specifications I had in mind.

    The sample "ble_app_multirole_lesc" was a sample program that operated the central function and peripheral function at the same time, so I focused on checking the operation of the central function only.

    I almost gave up, but I'm glad I succeeded.

    thank you.

Related