<?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>nRF52840 SDK16 sd140 - Pairing and Bonding general questions</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87254/nrf52840-sdk16-sd140---pairing-and-bonding-general-questions</link><description>Hi, I want to include the pairing and bonding features in my application. 
 I want to use the LE secure connection method. For both initiator and responded the IO capabilities are no input / no output and hence it will be used the Just Works pairing mode</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 Apr 2022 12:26:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87254/nrf52840-sdk16-sd140---pairing-and-bonding-general-questions" /><item><title>RE: nRF52840 SDK16 sd140 - Pairing and Bonding general questions</title><link>https://devzone.nordicsemi.com/thread/364948?ContentTypeID=1</link><pubDate>Tue, 26 Apr 2022 12:26:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10e2a6ea-64d6-4b3f-b7bb-d6ff439493d8</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Nikos&lt;/p&gt;
[quote user="Nikosant03"]I suppose this is how most of the commercial products work, right?[/quote]
&lt;p&gt;Correct. I believe Apple describe something similar in their guidelines, in order to make Bluetooth devices that integrate well with iOS devices.&amp;nbsp;&lt;/p&gt;
[quote user="Nikosant03"]Is there any example in SDK16 implementing these steps with&amp;nbsp;&lt;strong&gt;Just Works pairing mode?&lt;/strong&gt;[/quote]
&lt;p&gt;Any example using the peer_manager should support this procedure.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As an example you can use the ble_app_hrs sample, which by default is set up to use LESC and not use authentication (which means you revert to just works):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Excerpt from the main.c file of the ble_app_hrs example:

#define SEC_PARAM_BOND 1 /**&amp;lt; Perform bonding. */
#define SEC_PARAM_MITM 0 /**&amp;lt; Man In The Middle protection not required. */
#define SEC_PARAM_LESC 1 /**&amp;lt; LE Secure Connections enabled. */
#define SEC_PARAM_KEYPRESS 0 /**&amp;lt; Keypress notifications not enabled. */
#define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE /**&amp;lt; No I/O capabilities. */
#define SEC_PARAM_OOB 0 /**&amp;lt; Out Of Band data not available. */
#define SEC_PARAM_MIN_KEY_SIZE 7 /**&amp;lt; Minimum encryption key size. */
#define SEC_PARAM_MAX_KEY_SIZE 16 /**&amp;lt; Maximum encryption key size. */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 SDK16 sd140 - Pairing and Bonding general questions</title><link>https://devzone.nordicsemi.com/thread/364772?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2022 16:36:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97130ebb-2dd0-45f6-a60e-bfb3c2328b71</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;Thank you for your detailed answer &lt;a href="https://devzone.nordicsemi.com/members/ovrebekk"&gt;ovrebekk&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
[quote userid="2116" url="~/f/nordic-q-a/87254/nrf52840-sdk16-sd140---pairing-and-bonding-general-questions/364704#364704"]The normal procedure for a client to access a protected characteristic is as follows[/quote]
&lt;p&gt;I suppose this is how most of the commercial products work, right?&lt;/p&gt;
&lt;p&gt;Is there any example in SDK16 implementing these steps with&amp;nbsp;&lt;strong&gt;Just Works pairing mode?&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 SDK16 sd140 - Pairing and Bonding general questions</title><link>https://devzone.nordicsemi.com/thread/364704?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2022 12:04:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f438569a-0e85-4a75-98ae-1968f4d64d05</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Nikos&lt;/p&gt;
[quote user=""]A secure communication link provides data encryption through&amp;nbsp;AES-CCM cryptography, right?[/quote]
&lt;p&gt;That is correct.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BLE encryption is based on a traditional symmetric AES-CCM encryption algorithm, with a standard key size of 128 bits.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The AES key used for the AES-CCM cipher (also referred to as the Long Term Key) is exchanged during the pairing phase, which&amp;nbsp;in the case of LE secure pairing is&amp;nbsp;using an asymmetric ECDH scheme to avoid someone sniffing the pairing procedure to be able to get hold of the AES key.&amp;nbsp;&lt;/p&gt;
[quote user=""]Does this mean that all the data exchanged after pairing through characteristics are encrypted? e.g the value of the sensors, battery level, etc?[/quote]
&lt;p&gt;Correct, encryption in BLE is all or nothing. Once encryption is enabled all the attribute data will be encrypted, even for attributes that don&amp;#39;t require it.&amp;nbsp;&lt;/p&gt;
[quote user=""]&lt;p&gt;Also, after testing the heart rate example, I see that I&amp;nbsp;have access to all characteristics without previously having paired the devices. This doesn&amp;#39;t make sense to me. I mean it would make sense for the central to have access to the GATT server after the pairing process. For example, when I connect my wireless headphones with the smartphone, I have to pair the device before start hear music.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;So this is something that should but doesn&amp;#39;t be demonstrated in the hrs example or do I miss something?&lt;/strong&gt;&lt;/p&gt;[/quote]
&lt;p&gt;The Bluetooth specification doesn&amp;#39;t require you to pair and enable encryption before you do service discovery, and normally the initial service discovery is done without encryption enabled.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Still,&amp;nbsp;you can configure a characteristic to require encryption enabled in order for the client to read and/or write to it, which means you will not be able to access the characteristic data before pairing is done.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is why you can see all the services and characteristics from the nRF Connect app, even if some of them might require encryption to be accessed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The normal procedure for a client to access a protected characteristic is as follows:&lt;/p&gt;
&lt;p&gt;1) The two devices connect.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2) The client performs service discovery, and gets a list of all the services and characteristics in the server.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;3) The client tries to access the protected characteristic&lt;/p&gt;
&lt;p&gt;4) The server responds with an &amp;#39;insufficient authentication&amp;#39; error, letting the client know that this characteristic requires encryption in order to be accessed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;5) The client start the pairing procedure.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;6) Once pairing is completed, the client can access the characteristic.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>