<?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>BLE Pairing and security stack implementation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80876/ble-pairing-and-security-stack-implementation</link><description>I am developing a product using the nRF51822 BLE, I was able to interface all my peripherals and setup the softdevice stack accordingly. 
 Now I am looking to add a pairing and security layer on the same to start the provisioning process and make the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 Oct 2021 10:05:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80876/ble-pairing-and-security-stack-implementation" /><item><title>RE: BLE Pairing and security stack implementation</title><link>https://devzone.nordicsemi.com/thread/335444?ContentTypeID=1</link><pubDate>Fri, 22 Oct 2021 10:05:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19b60134-08c7-4838-9460-24bc579f2420</guid><dc:creator>Einar Thorsrud</dc:creator><description>[quote user="shwetank vishnu"]Okay, so when you say scan response packets, you are talking about the pairing sequence?[/quote]
&lt;p&gt;No. The pairing has nothing to do with peer being able to see services. What I was referring to was the scan response packet, which is an &amp;quot;extra&amp;quot; advertising packet. The point was that it is optional which (if any) service UUIDs you include there. But other than that, any peer that connects and does service discovery can see all available services.&lt;/p&gt;
[quote user="shwetank vishnu"]UART_BLE example code which sets the nRF in peripheral mode and can be easily connected using the nRF connect app, what do I need to do to enable a pairing method?[/quote]
&lt;p&gt;The &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/ble_sdk_app_nus_eval.html"&gt;UART/Serial Port Emulation over BLE&lt;/a&gt;&amp;nbsp;example does not support pairing out of the box, so you need to add support for that. That involves adding the peer manager library to your code, as well as modules it depends on (like FDS). I suggest you refer to an example that allready has peering to see how this is done and which files you need to include etc, and the sdk_config.h configuration. A good such example is the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/ble_sdk_app_hrs.html"&gt;Heart Rate Application&lt;/a&gt;.&lt;/p&gt;
[quote user="shwetank vishnu"]The device is battery operated, so power cycle method is a bit out of picture.[/quote]
&lt;p&gt;Yes, unless you can remove and re-insert the battery.&lt;/p&gt;
[quote user="shwetank vishnu"]I can use make a sequence that enables the device to pair with a mobile and if the mobile unpairs it, then we can restart the whole pairing process.[/quote]
&lt;p&gt;You cannot know from the nRF side if the phone has deleted the bonding information or not, so this method will not work in practice. You either need to allow pairing all the time, or alternatively have a method which you use to make the device enter pairing mode.&lt;/p&gt;
[quote user="shwetank vishnu"]4. Then what can be the best implementation to avoid any such attacks?[/quote]
&lt;p&gt;There is no standard way to implement MITM protection without buttons or display. You can use a static passkey for instance which is unequal for each device, but this can be easily hacked, so it will only provide protection against someone accidentally connecting to your device. A&amp;nbsp;malicious attacker can easily circumvent this.&lt;/p&gt;
[quote user="shwetank vishnu"]I came across security modes and levels and I think I am looking for a security mode 1 level 4 communication.[/quote]
&lt;p&gt;As your device doe snot have I/O capabilities you can only achieve security mode 1 level 2 (though you can trick it by using a static pass key, but that does not give you any real protection as described above). Also, note that for level 4 you need to use LE Secure Connections.&lt;/p&gt;
[quote user="shwetank vishnu"]Firstly am I thinking this in a wrong way? what is the right approach here?[/quote]
&lt;p&gt;I am not sure. I think you need to establish what the required minimum security level is for your product. If you need proper MITM protection, then you need to modify your HW. This may also the case if you need to limit when the device can be in pairing mode.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Pairing and security stack implementation</title><link>https://devzone.nordicsemi.com/thread/335326?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 13:18:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0dbca1b8-25de-4f4b-9ee5-18e3e4d2dd4d</guid><dc:creator>shwetank vishnu</dc:creator><description>&lt;p&gt;1.&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/80876/ble-pairing-and-security-stack-implementation/335292#335292"]No, there is no way to &amp;quot;hide&amp;quot; services. Once a device connects it can discover all services. There is no need to include the service(s) in&amp;nbsp;advertising packets or scan response packets, though.[/quote]
&lt;p&gt;Okay, so when you say scan response packets, you are talking about the pairing sequence?&amp;nbsp;I am&amp;nbsp;using&amp;nbsp;a modified UART_BLE example code which sets the nRF in peripheral mode and can be easily connected using the nRF connect app, what do I need to do to enable a pairing method?&lt;/p&gt;
&lt;p&gt;2.&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/80876/ble-pairing-and-security-stack-implementation/335292#335292"]That is&amp;nbsp;entirely&amp;nbsp;application specific, and up to you. What fits your product? Is it possible to power cycle or reset it to put it in pairing mode, for instance?[/quote]
&lt;p&gt;The device is battery operated, so power cycle method is a bit out of picture. I can use make a sequence that enables the device to pair with a mobile and if the mobile unpairs it, then we can restart the whole pairing process.&lt;/p&gt;
&lt;p&gt;3.&lt;/p&gt;
&lt;p&gt;Okay will look into this&lt;/p&gt;
&lt;p&gt;4. Then what can be the best implementation to avoid any such attacks?&lt;/p&gt;
&lt;p&gt;I hope the application is somewhat clear. To reiterate below is the exact application I am implementing&lt;/p&gt;
&lt;p&gt;1. I have some sense data that will be communicated to the mobile application&lt;/p&gt;
&lt;p&gt;2. Mobile applications generate some triggers(not periodic, about 50 over 24Hours lets say) to operate a couple of peripherals that are part of a different characterstic&lt;/p&gt;
&lt;p&gt;3. Now as soon as the device boots up, currently it waits for any central (mobile connection), I am using the nRF-connect APP for demo purpose, and then I am able to see and control the characteristics as required.&lt;/p&gt;
&lt;p&gt;4. All I want to do is to add a provisioning/ pairing process in the same and make the overall communication secure. I came across security modes and levels and I think I am looking for a security mode 1 level 4 communication.&lt;/p&gt;
&lt;p&gt;Firstly am I thinking this in a wrong way? what is the right approach here?&lt;/p&gt;
&lt;p&gt;Thanks for the reply, much appreciated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Pairing and security stack implementation</title><link>https://devzone.nordicsemi.com/thread/335292?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 12:00:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d841c9ec-cfd0-49da-b22d-bab65a04c9b4</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]1. The BLE device at factory reset will be active to pair and send/ receive data via the services, These services are currently open and I used nrf connect APP to communicate, can I make then hidden so that no one else can see those?How?[/quote]
&lt;p&gt;No, there is no way to &amp;quot;hide&amp;quot; services. Once a device connects it can discover all services. There is no need to include the service(s) in&amp;nbsp;advertising packets or scan response packets, though.&lt;/p&gt;
[quote user=""]2. At the time when device is not bonded with any central, what should be the architecture to enable pairing. Note that the device is headless and does not have any HMI. Is there any application note or literature that I can follow to do the same?[/quote]
&lt;p&gt;That is&amp;nbsp;entirely&amp;nbsp;application specific, and up to you. What fits your product? Is it possible to power cycle or reset it to put it in pairing mode, for instance?&lt;/p&gt;
[quote user=""]3. Once the pairing is complete, I want the communication to be encrypted, I guess the nordic supports AES encryption, is there any example or literature I can follow?[/quote]
&lt;p&gt;The nRF SDKs support standard Bluetooth pairing, both legacy pairing and LE Secure Connections. Regardless of how you pair, a secured link is always encrypted with 128 bit&amp;nbsp;AES-CCM (according to the Bluetooth specification). I suggest you check out the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_peer_manager.html"&gt;peer manger library&lt;/a&gt; in nRF5 SDK 12.3.&lt;/p&gt;
[quote user=""]4. Also should the authorisation process involve a digital certifacate method to make sure the pairing is safe and avoids any MITM.&amp;nbsp;[/quote]
&lt;p&gt;There is no use of&amp;nbsp;certificates in the bluetooth specification. However, there are MITM protection features supported as defined in the Bluetooth specification, but all those depends on having a HMI of some sort. Without it,&amp;nbsp;Bluetooth does not provide any way to guarantee MITM protection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>