<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to bond devices using the Android BLE library</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65102/how-to-bond-devices-using-the-android-ble-library</link><description>Hi there, 
 This is actually a question re. the Android BLE library ( https://github.com/NordicSemiconductor/Android-BLE-Library ), so please re-direct me if necessary. 
 My question is in relation to bonding. I use the BLE library to connect to another</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 10 Sep 2024 04:51:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65102/how-to-bond-devices-using-the-android-ble-library" /><item><title>RE: How to bond devices using the Android BLE library</title><link>https://devzone.nordicsemi.com/thread/501824?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2024 04:51:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c795dc13-68d1-4925-ad84-5723e7931820</guid><dc:creator>r0n9</dc:creator><description>&lt;p&gt;It is been a while, I just read this thread today and am worried about the bug that Aleksander described. But based on the reference&amp;nbsp;&lt;a id="" href="https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-5-bluetooth-le-security-fundamentals/topic/security-models/"&gt;https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-5-bluetooth-le-security-fundamentals/topic/security-models/&lt;/a&gt;&amp;nbsp;The `bug` is kinda an expected behavior, since `Just Work` upgrade the connection to security lv. 2, and lv2 security does not protect against MITM. And Authenticated pairing with encryption brings the connection to Lv.3 which should protect the connection from MITM.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to bond devices using the Android BLE library</title><link>https://devzone.nordicsemi.com/thread/266327?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 19:38:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe4b4e36-b8ba-4297-8759-d2760e7762ed</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;ensureBond() can be used after connection. However, I would recommend using createBondInsecure() and using MITM in bonding (not Just Works). With MITM (e.g. bonding using PIN), the Android seems to request security on each connection. If an intruder pretends to be your device, the connection will time out and will not be successful. Also, seams like this also prevents from connecting to your device after bond info was removed from it, until you remove bonding the m from the phone as well.&lt;/p&gt;
&lt;p&gt;Ensure bond method will remove bonding in each connection and request new one each time, so your device needs a) allow that b) must remove all data every time new device bonds, as anyone would be able to connect and bond and read data.&lt;/p&gt;
&lt;p&gt;With createBondInsecure you may allow only one pairing on the device. Make sure you set right permissions on your characteristics so no one can read anything without being bonded.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to bond devices using the Android BLE library</title><link>https://devzone.nordicsemi.com/thread/266324?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 19:18:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b42de81-235c-41b6-8816-4c946f1c3392</guid><dc:creator>Christopher Hunt</dc:creator><description>&lt;p&gt;Thanks Emil. So, given bonding is required for reconnecting over a long period, how do most go about bonding using the BLE library? Do they use the ensureBonding call (which I&amp;rsquo;m still unsure of how/where it should be used) or do they rely on the user navigating to the system settings and doing it there?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to bond devices using the Android BLE library</title><link>https://devzone.nordicsemi.com/thread/266161?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 09:33:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d582d2a0-958c-4011-9385-a8f91dfeb0f2</guid><dc:creator>Christopher Hunt</dc:creator><description>&lt;p&gt;Thanks again Aleksander.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m really just trying to determine whether bonding is required for auto-connect to work over a long period of time. If yes, then what&amp;#39;s the best approach to bonding on Android with the BLE library.&lt;/p&gt;
&lt;p&gt;Apologies if I&amp;#39;ve not been clear.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to bond devices using the Android BLE library</title><link>https://devzone.nordicsemi.com/thread/266098?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 06:56:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f0d8c6f-727a-4e12-9c2c-508e8b270617</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;Bonded devices may use private resolvable address, which seems random and changes in time, but the central can assume that it&amp;#39;s the bonded device that advertises, as its generated based on the shared keys. It may be that some random device would use an address that matches, but that&amp;#39;s not very likely and still resuming bonding would fail if it wasn&amp;#39;t the one. However, as I wrote above, in my opinion Android would not disconnect in such case, but would remain connected with unencrypted link giving no hint that it is not the same device that was bonded. I would really like someone corrected me here. I&amp;#39;ll try to replicate and verify that today.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to bond devices using the Android BLE library</title><link>https://devzone.nordicsemi.com/thread/265983?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2020 12:37:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1487e8d-0bd4-4c32-933d-203cc31654fc</guid><dc:creator>Christopher Hunt</dc:creator><description>&lt;p&gt;Thanks Aleksander for the comprehensive reply.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I should add that I understand that devices must be bonded to be able to successfully reconnect given the presence then of a stable MAC address. Do I have this correct?&lt;/p&gt;
&lt;p&gt;If so then I&amp;rsquo;m still interested to learn how most central Android devices should go about bonding. Thanks.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to bond devices using the Android BLE library</title><link>https://devzone.nordicsemi.com/thread/265927?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2020 10:21:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35a7d467-8995-4f51-9a97-e34e1583709e</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;Hello &lt;a href="https://devzone.nordicsemi.com/members/christopher-hunt"&gt;Christopher Hunt&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Let me answer your question, at least from the&amp;nbsp;mobile apps developer perspective.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s start with iOS. The only way to bond on iOS is by trying to read or write protected characteristic of descriptor, so if you ever plan to support that OS, your device and pairing procedure should support it.&lt;/p&gt;
&lt;p&gt;On all versions of Android, as far as I know, there&amp;#39;s a bug related to bonding. The issue is, that Android allows unencrypted link despite having valid bond information. Moreover, the only API to check bond state returns only whether this information is present, not if it&amp;#39;s used. So you may be connected to a device, the app may say that you&amp;#39;re bonded (getBondState()), but link is completely insecure.&lt;/p&gt;
&lt;p&gt;Then, you have to imagine an intruder and what he/she can do.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s say you bonded to a device, which has some protected characteristics. You can read and write, as the link is secure. Then you disconnect, and the intruder starts advertising with the same packet as your device does. So them, when you connect, instead of connecting to the read device, you connect to the specially prepared intruder&amp;#39;s one. You app has no clue about it. It says that the bond state is bonded, MAC address is ok. You have no idea whether the connected device is the right one, unless the device has some LEDs or makes a sound and the user noticed that the LEDs are now turned off. With no such blinking flashlights, you may send some sensitive information to the intruder using completely unsecured link, and your app will tell you that everything is OK.&lt;/p&gt;
&lt;p&gt;In the BLE Library there&amp;#39;s &amp;quot;ensureBond&amp;quot; method, which removes bond information from the phone and bonds again, to make sure the link is encrypted. However, even if you use the &amp;quot;ensureBond&amp;quot; request from BLE Library, it would just remove the bond information, and recreate bonding with intruder. Again, if user won&amp;#39;t notice lack of blinking LEDs, or won&amp;#39;t read the info on the phone to check if the device behaves in some way, your phone will bond to intruder&amp;#39;s device.&lt;/p&gt;
&lt;p&gt;If your device is e.g. a lock, and you make it work with &amp;quot;ensureBond&amp;quot; (so you will remove bond info when an unbonded device connects), then any intruder can just connect and bond and unlock anything. If you&amp;nbsp;allow only a single bonding, and do not allow unpaired device to connect, intruder won&amp;#39;t be able to connect and unlock, but intruder will be able to &amp;quot;emulate&amp;quot; the lock (with no encryption), or, I think can be able to replace your bonding information with some other, when the intruder&amp;#39;s device would advertise as the real lock, and would trigger another bonding procedure, e.g. by setting protection level on its characteristics. With &amp;quot;just works&amp;quot; that would be invisible for the user on many phones, as there&amp;#39;s no any pairing dialog.&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t try to replicate all off the above, but I&amp;#39;m able to reconnect to HRM sample from nRF5 SDK after removing bond information from it, with the phone saying bond state is bonded. The rest has been deducted from this fact.&lt;/p&gt;
&lt;p&gt;The only reliable way of ensuring trust when connecting to Android is by building application-level security, where you build the encryption on both sides in your apps. Assuming no keys can be obtained from your app or your db on the phone.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>