I’m at the tail end of my project, and I’m turning my focus to the pairing/bonding issue.
The project includes a Central/Client device that connects to several Peripheral/Server devices. The Peripheral unit advertises its serial number and the Central initiates connection upon detecting a Peripheral with a serial number on an “approved device” list (“whitelist”). Once connected, they stay connected unless the user takes the serial number off the “approved device” list or the RF signal is temporarily lost, in which case the connection will be immediately reestablished upon detecting the restarted advertising.
The only security concern the customer has is that a hostile agent doesn’t advertise with an approved serial number, get connected, and provide bogus data. However, when a Peripheral is added to the “approved device” list, it is part of a process in which a human operator has installed the Peripheral with the known serial number in the vicinity, so the user knows the device is expected and verifies that it connects. If there were a hostile agent advertising with the same serial number, the user would be informed. The concern is that the hostile agent would substitute the false device for a real, already connected device.
Our thought is that using Resolvable Private Addresses gets us past this concern. Once connected under controlled, supervised conditions, a Peripheral must always be the same device with the IRK negotiated during the connection process. While the devices stay powered for their entire lifetime, it is possible that the mains-powered Central could be cycled, so storing the IRK in flash NVM is good. There won’t be much coming-and-going, so using the flash on both sides is not a concern.
I believe this approach does not require additional authentication. The data on the link is not interesting (room temperature, humidity), so there is no need for encryption. So, in terms of security, BT_SECURITY_L1.
I’ve got CONFIG_BT_SMP and CONFIG_BT_PRIVACY enabled on both sides. I verify with nRF Connect for Desktop that the Peripheral is advertising with a RPA (or “RandomPrivateResolvable”, as nRF Connect reports it). I would have expected some event about resolving the address, either by nRF Connect or by the Central reporting the occurrence of a identity_resolved() callback, but I don’t see that.
(In fact, after connecting to the Peripheral, at every point where nRF Connect refers to the Peripheral, it uses the same address it saw during advertising. Is resolution actually occurring? I figured it would be done automatically after sensing that the address was a RPA.)
I’m a bit fuzzy on connecting/pairing/bonding. Under nRF Connect I can pair the newly-connected Peripheral without clicking any of the boxes under authentication and pairing appears to succeed with the message “Security updated, mode: 1, level: 2” (why is it level 2?). If I reset the device and reconnect to it, I have to do the pairing again to get the message, so apparently pairing is just for the security update and not for remembering the IRK for resolving the address. I guess that’s the bonding part.
Following the pattern in the bluetooth/peripheral sample, I add the following to prj.conf:
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_NVS=y
CONFIG_SETTINGS=y
CONFIG_BT_SETTINGS=y
and put “settings_load()” after the bt_enable() call. I also put some code to display all the bond info at reset using “bt_foreach_bond()”. When I click the “Bond” box under “Pair” in nrf Connect, it says “Storing bond info for device <address>”.
(When I try to instrument the pair process using “bt_conn_auth_cb_register()” to set up a “pairing_complete()” callback, the device resets upon pairing. I’m guessing this authentication callback provision is only useful when doing authentication via a passkey or OOB or whatever, but I wasn’t expecting it to crash.)
At this point, I reset the device. After coming back up, it reports a stored bond with the nRF Connect device. I would expect that upon connecting, nRF Connect (the Central) would look through the bond info it has for an IRK that resolves the RPA of the device and pair automatically. No message about changing the security level. I proceed to pair anyways and get an error 4 (BT_SECURITY_ERR_AUTH_REQUIREMENT).
Using nRF Connect SDK 2.1.0. What am I missing?