<?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 provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/18757/how-to-provide-authorization-of-app-before-connection</link><description>Hello,
I am using secure_dfu_secure_dfu_ble_s132_pca10040 project. Now I want that the user who has specific key can only access the nrf my device and then can send the zip package for dfu. How should I implement this?
I am using nrf52 amd sdk12.
I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Jan 2017 06:06:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/18757/how-to-provide-authorization-of-app-before-connection" /><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72445?ContentTypeID=1</link><pubDate>Thu, 26 Jan 2017 06:06:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd94152c-f6ef-47b5-9746-2bbdeddc5b7d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;ol&gt;
&lt;li&gt;How did you get that &amp;quot;demo&amp;quot; keys ? As far as I know the private key for demo is not available.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To generate your own key, please follow the instruction &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.tools/dita/tools/nrfutil/nrfutil_intro.html?cp=5_4"&gt;here&lt;/a&gt; on how to generate cryptography keys.&lt;/p&gt;
&lt;ol start="2"&gt;
&lt;li&gt;You would need to modify the bootloader code. What was designed is only for 1 pair of key. If you want 2 pairs, there should be 2 check, one for each key. (two check before throwing the
Your plan is to make the 2nd keys dynamic, how do you plan to update the 2nd key ? You may need to update the bootloader so that it has an extra command to receive a new key, store it into flash. The bootloader then read the flash to get the key next time it starts.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72444?ContentTypeID=1</link><pubDate>Thu, 19 Jan 2017 04:26:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58dde792-5882-4d0f-b056-e8987d6ab6ad</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hello Hung,
I have few question.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The public and private key that I have is only for demo purpose. So if I want to go for production then how should I generate those keys?&lt;/li&gt;
&lt;li&gt;Can I use 2 keys in firmware? One key will be common for our company and other key will be different for different users.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We want to send common updated firmware to all user so one key will be same and generated by our company. At the user end we want to add other key so that will be different for different users.&lt;/p&gt;
&lt;p&gt;Now my concern is how to update key at run time without compiling it?&lt;/p&gt;
&lt;p&gt;At present I need to manually add keys in dfu_public_keys.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72441?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 15:17:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:679396e5-69b0-498c-8357-830b29747fa8</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Once bonded or paired, the link is encrypted with AES128 bit.
The most vulnerable part is when the bonding process is performed and it&amp;#39;s where MITM avoidance taken place (Phase 2). It could be passkey, numeric comparison or OOB.&lt;/p&gt;
&lt;p&gt;You may want to read more about BLE security, for example from &lt;a href="https://eewiki.net/display/Wireless/A+Basic+Introduction+to+BLE+Security#ABasicIntroductiontoBLESecurity-PairingMethodsforLESecureConnections(4.2devicesonly):"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72440?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 09:22:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5526c86b-8513-45db-9115-95a6b27785ee</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hello Hung,
Once the link is established between app and nrf device even then mitm attacks are possible. Does the data transfers takes place as normal plain text or aes encryption technique is used to transfer the data?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72442?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 08:45:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6f5f6cc-dde6-42d6-a565-d7e5d8239de9</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;The passkey you mentioned is part of BLE bonding process. You can try to bond your device with the phone either in both your application and your bootloader (share bond information) or separately if you found sharing bond information is difficult.&lt;/p&gt;
&lt;p&gt;If your device doesn&amp;#39;t have screen or keyboard, you can think of using static passkey. It&amp;#39;s a passkey you printed and only the owner of the device know it. It&amp;#39;s less secure than normal random dynamic passkey.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72443?ContentTypeID=1</link><pubDate>Mon, 16 Jan 2017 09:42:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec1fd47f-d2f1-4f52-8835-4c2714fee0ef</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hello Hung,
I have few questions. With dfu secure project I can now upload securely to my nordic device but when the connection is established how can I stop man in the middle attacks?
Is there any encryption technique provided by nordic to ensure that my mobile and nordic communicates securely?
I have read the dynamic passkey code. In that random passkey is generated to stop mitm attack but with devices having io facilities only.
I just have nordic app and nrf52  so should I try this in my firmare?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72439?ContentTypeID=1</link><pubDate>Wed, 11 Jan 2017 09:07:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1030723c-2824-4b96-a82b-631386bd334f</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;No, BLE whitelist can only be used with BLE address.&lt;/p&gt;
&lt;p&gt;If you want to use IMEI, please implement your own mechanism. For example device won&amp;#39;t do any activity, until the phone write its own IMEI to the device. You can put a timing requirement, say after 5 seconds if no valid IMEI is written device will disconnect.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72438?ContentTypeID=1</link><pubDate>Wed, 11 Jan 2017 08:50:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9feded4-74c1-4638-8738-5341dce7f6ec</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hello Hung,
Instead of Device address can I use imei of my cell phone and implement whitelist?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72437?ContentTypeID=1</link><pubDate>Wed, 11 Jan 2017 08:41:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7de9bae6-873d-4caa-accc-987fe10a99c0</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Are you talking about using peer manager ? If you don&amp;#39;t use peer manager,  you need to handle all of that on your own.
With peer manager, it will handle that for you. But you need to know how to use peer manager. Please have a look at our examples in the SDK, the ble_hid_keyboard for example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72436?ContentTypeID=1</link><pubDate>Wed, 11 Jan 2017 05:05:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2afe110f-a793-4d70-ac4d-fbeb6a5632e1</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Do I need to add the address of my phone in firmware or it will first bond with the device and will afterwards it will only connect with that specific device which was bonded first?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72434?ContentTypeID=1</link><pubDate>Tue, 10 Jan 2017 12:09:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09fd6c5c-4603-4d6a-9041-a556140f88de</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;You don&amp;#39;t have to add it if you don&amp;#39;t want to. It&amp;#39;s simply a library as a guidance. You can use the API directly.
If you simply want a hardcoded whitelist with public address, you can go with what you are trying to do.
What I suggested was to study the id_manager.c to know how we set the whitelist, inside im_whitelist_set().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72435?ContentTypeID=1</link><pubDate>Tue, 10 Jan 2017 11:20:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3093dfd-d904-4a10-a3f2-1c08ad917d85</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hello Hung,
The peer libraries are not added in the code of dfu_secure project. So do I need to add it or is there any other way?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72432?ContentTypeID=1</link><pubDate>Tue, 10 Jan 2017 10:27:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74c1be96-0ef4-4ed7-af62-236549bd2173</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi, my code is for S110v8.0 and S130 v1.0 as I mentioned in the blog &lt;code&gt;&amp;quot;The following code (for S110v8.0/S130v1.0)&amp;quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If you are using with S132 v3.0 you need to use sd_ble_gap_whitelist_set() to set the whitelist. Please have a look &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v3.0.0/group___b_l_e___g_a_p___w_l___s_h_a_r_e___m_s_c.html?cp=2_3_0_1_1_2_1_3_13"&gt;here&lt;/a&gt;. Please study the id_manager.c in the peer manager library.&lt;/p&gt;
&lt;p&gt;You can&amp;#39;t simply change the structure defined in the API header files. The structure is fixed, as it&amp;#39;s hardcoded in the softdevice, you shouldn&amp;#39;t change them.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72433?ContentTypeID=1</link><pubDate>Tue, 10 Jan 2017 06:29:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09ccc79f-989a-435c-a1ca-25b906b6d9e2</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hello Hung,
I have figured out the problem. Please refer to my text document as when I paste code here it gets mess .
Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72428?ContentTypeID=1</link><pubDate>Mon, 09 Jan 2017 15:10:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55e0ec45-4847-4fe5-b1dd-422d14858487</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Have you checked all the return code and it returns NRF_SUCCESS?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72431?ContentTypeID=1</link><pubDate>Mon, 09 Jan 2017 14:17:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd193dc0-3ec6-4afc-a1b6-a4af5f55f70b</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hello Hung,
Its not advertising at all. I changed the addr to my phone&amp;#39;s address but it doesn&amp;#39;t connect.
Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72430?ContentTypeID=1</link><pubDate>Mon, 09 Jan 2017 13:43:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be1e7531-02fc-4935-b7a6-7e9749c79e72</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;You need to tell me what is the outcome of the code, what is the issue you have now? Please answer the question I asked in the previous message.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72429?ContentTypeID=1</link><pubDate>Mon, 09 Jan 2017 13:37:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb595df0-b42e-44ce-a12a-c9f23da98ba3</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hello Hung,
As suggessted by you have edited the code and I am attaching my code in the file above. Now do I need to add anything to the cases?
Can you try this modification at your end tell me what changes should I make to make it work?
Thanks,
Shailav&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72423?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 14:24:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f77c2ec0-44c0-4acc-93f9-44b65942c44a</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;It&amp;#39;s simple to add whitelist. But the question is how you can get the address of the device, how do you deal with device that have Resolvable Random Address (iPhone). Also simply use only whitelist won&amp;#39;t guarantee security, anyone can spoof your address.&lt;/p&gt;
&lt;p&gt;Regarding the code, you would need to check return err_code of each of the API call.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72420?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 13:59:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3197bd4e-4da1-444e-ba16-b32fc2be744b</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;I think its more complex to implement whitelist by referring this code. I need to add more peer related files to this.Can you suggest me easy way like the one mentioned in your blog. Can you edit the code that I attached previously by referring your blog?
Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72426?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 11:58:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20f1ad9f-c5ad-479c-9e36-084784a9a297</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Then you need to implement whitelisting and bonding with your application. Please study the example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72425?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 11:56:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3060dd4d-668e-43a7-a28c-1ae224cb0ba2</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;yes I want my phone to be only phone to connect and access the device.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72424?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 11:43:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfad50ef-8b2b-41a1-a062-b06e851200f1</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;You can have a look at the ble_app_hid_keyboard, advertising_start() function to see how whitelist is used. It&amp;#39;s the combination between peer manager (where device address, IRK, and bond information is collected) and ble_advertising module (where whitelist is used in advertising packet).&lt;/p&gt;
&lt;p&gt;You may want to describe what exactly you want to achieve and how you plan to do it. Please answer my question :&lt;/p&gt;
&lt;p&gt;&lt;em&gt;You want to limit the phone to be the only phone that can authenticate the DFU action or also the only phone can connect and access the device ?&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72422?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 11:07:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e4f197f-8ae4-447f-ae39-0100b217f2ec</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hello Hung,
Is there any peer code in the sdk? I didnt find any in example. Which code should I refer to generate whitelist and ?
I am using sdk12 as mentioned before.
Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to provide authorization of app before connection?</title><link>https://devzone.nordicsemi.com/thread/72421?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 10:00:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64611976-06b4-466b-8191-43f8b5092b38</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Shailav,&lt;/p&gt;
&lt;p&gt;I would suggest you to get familiar with how whitelist work, how you can get the address, the IRK (when the peer device using random resolvable address, like the iPhone) and try to test using normal application first, before you implement on the bootloader. You also need to deal with how to store bonding information how to restore it. All this is already implemented in our peer manager. But it&amp;#39;s not used in the bootloader.&lt;/p&gt;
&lt;p&gt;I can see in your code you didn&amp;#39;t check for the return err_code back. Always check the err_code is NRF_SUCCESS, if not, it won&amp;#39;t work. Removing code check won&amp;#39;t help.&lt;/p&gt;
&lt;p&gt;I mentioned it in my blog:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;To make the code short and simple, the check of the return code (err_code) of the API call is not added here. When you implement your code, make sure the return code of each API is checked and it should return NRF_SUCCESS (0x00).&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>