<?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>When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15674/when-do-encryption-keys-exchange</link><description>I have a problem with bonding with a static passkey. I have some sensors, which have a static passkey hardcoded in them. If I want to bond with them, I have to provide this passkey from my custom central app, which uses s120 and SDK 8.1.0. For the past</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Sep 2016 12:54:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15674/when-do-encryption-keys-exchange" /><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59870?ContentTypeID=1</link><pubDate>Mon, 19 Sep 2016 12:54:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddd64910-5ec3-4f2c-8c84-8f75c1419c69</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I converted this to an answer. Great that you figured out! And thanks for adding the solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59869?ContentTypeID=1</link><pubDate>Mon, 19 Sep 2016 12:22:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfa950bb-8832-4873-a4df-540fe19be39f</guid><dc:creator>MC</dc:creator><description>&lt;p&gt;Because my question is somewhat identical to &lt;a href="https://devzone.nordicsemi.com/question/94600/ble_gap_sec_status_auth_req-event_result-in-dm_evt_security_setup_complete/"&gt;this&lt;/a&gt; one, I&amp;#39;m replying in both questions. I think I solved this problem by changing the default address type to BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE. First I initialize the SD and immediately set the address by calling this sequence after sd_initialize function:&lt;/p&gt;
&lt;p&gt;ble_gap_addr_t local_address;
local_address.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;&lt;/p&gt;
&lt;p&gt;err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_AUTO, &amp;amp;local_address);
APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;Now I get the right responses when bonding and encrypting the link&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59865?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2016 14:22:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:974314cc-6410-43b6-aaa1-05fb46dbbebc</guid><dc:creator>MC</dc:creator><description>&lt;p&gt;That is correct, MCP sends request: &amp;quot;Bond, MITM, Initiator keys: 0, Responder keys LTK IRK...&amp;quot; As you said, there is no CSRK key involved. I will try to understand what the deal is, but it seems to me, I&amp;#39;m stuck in a dead end for now. If I come up with some kind of solution or breakthrough, I will post a comment or an answer. For the time being, if anyone has some kind of suggestion about this issue, I will appreciate it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59864?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2016 14:03:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3e9a3ee-4131-46ce-9796-7b5b5359140d</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;MCP will not use CSRK, so if you are able to MCP I guess that is not the issue. Strange. I&amp;#39;m not sure what it could be.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59861?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2016 11:13:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03af824c-9298-456f-ae1b-a6460b5f8123</guid><dc:creator>MC</dc:creator><description>&lt;p&gt;I tried to bond with MCP where I set IO caps to only_keyboard and none. In both cases I get successful bond with the peripheral. It bothers me that MCP works and my code with identical settings fails everytime.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59866?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2016 07:38:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afb78374-71bd-4a8f-9004-0ca19f7524c1</guid><dc:creator>MC</dc:creator><description>&lt;p&gt;I&amp;#39;ve managed to get android sniffer trace with old version of wireshark and added it to my main question. I can see, that android also uses CSRK keys for bonding, therefore, I&amp;#39;m back at the beginning. I don&amp;#39;t think I will be able to do MCP sniffer trace, as I only have one development kit available, and I need it to run both the MCP and sniffer. If you look at the attached MCP log file (line number 165), MCP sends pairing request without CSRK and still succeeds. My pairing request is identical to MCP, but my fails. I still can&amp;#39;t figure it out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59859?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 14:34:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f5a4542-c08d-4f1f-b4c7-ca313696c3ae</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;You are correct, sorry. Please try. I don&amp;#39;t know what version you are using, but it is recommended to use Wireshark v1.10 with the nRF Sniffer. It is the latest version that have been tested.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59858?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 14:20:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5acc15b0-dd99-4f4a-ac09-f2d443bea0a5</guid><dc:creator>MC</dc:creator><description>&lt;p&gt;Sniffer trace with MITM and s120 is already added to my main question :) It has a name s120_central_pairing. I will try to get android trace if I can, because wireshark crashes often or doesn&amp;#39;t parse events correctly while sniffing connection between android phone and my sensor. If I succeed, I will upload it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59860?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 13:55:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73a75266-ab51-4f8a-9eff-879c1f3a7f9a</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;nRF Connect for PC uses an ordinary SoftDevice. MCP does not, but the ordinary SoftDevice should be capable of anything MCP can. Please try to to get a sniffer trace with MCP/nRF Connect for PC and/or Android. A sniffer trace with S120 with MITM set would also be nice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59863?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 13:08:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf49a1ee-00ba-4949-847f-0d55828e3463</guid><dc:creator>MC</dc:creator><description>&lt;p&gt;Does MCP for PC use ordinary softdevice? Because, with MCP I can bond just as well as with windows phone or Android. I wil try to get a sniffer trace of pairing with an Android, but I have a feeling it will be the same.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59862?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 12:23:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:225ba35d-404e-433a-abfc-ad99b6e7cd31</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;CSRK is used in security mode 2, which is not supported by our SoftDevices. It could be that&amp;#39;s why the TI rejects the pairing request, but I don&amp;#39;t know. Maybe you can test with another central device? You can try with nRF Connect for Android for example?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59868?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2016 07:37:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba798491-7691-4239-81d2-47b478338ccf</guid><dc:creator>MC</dc:creator><description>&lt;p&gt;I&amp;#39;ve added a trace of phone pairing with advertising and connection establishment. I noticed one important thing, that I somehow missed last time I was pairing. Windows phone seems to have CSRK keys implemented, so it requests pairing with initiator keys: CSRK. If my understanding is correct, SDK 8 doesn&amp;#39;t have this kind of keys implemented. Is my assumption correct? Is there no way of implementing CSRKs in SDK 8 and s120?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59867?ContentTypeID=1</link><pubDate>Mon, 15 Aug 2016 07:25:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff3c07c5-e39e-4ff7-83af-03becb18c79c</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;The sniffer trace for the windows phone seems to start when already in a connection. Could you do a sniffer trace where advertising and connecting is included as well?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59854?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2016 12:54:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ded7a556-e536-4d57-a34e-bf929a72a037</guid><dc:creator>MC</dc:creator><description>&lt;p&gt;Sorry for confusing you, now I&amp;#39;ve added sniffer traces for windows phone, s120 and MCP log file to my question. Please ignore multiple pairing attempts by s120, it&amp;#39;s a known feature (bug) in my code :) The main question still exists, what are MCP and windows phone doing differently, so their pairing is successful, as opposed to Device manager and s120 with SDK 8.1 which always fails?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59857?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2016 11:02:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8407ad67-06b8-4e82-b4d1-2f7514d924a6</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I&amp;#39;m confused. I thought the lower picture was S120? The pairing request is sent in that picture. What do you mean by sending pairing request prior to authentication? The authentication is part of the pairing process, it is not done before the pairing request is sent. Please upload the sniffer files instead of pictures, and mark clearly what trace is from what device. You send a pairing request by calling sd_ble_gap_authenticate(). You can do this directly, or you can let device manager handle this for you, then you should call dm_security_setup_req(). If you call this, the central will request to pair/bond if the peer is not bonded, if it is bonded, the link will be re-encrypted using existing bond information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59856?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2016 10:22:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd59907b-6c25-498f-8423-1338d4f21baf</guid><dc:creator>MC</dc:creator><description>&lt;p&gt;I thought that it doesn&amp;#39;t matter if it is from TI, as BLE responses and protocols should be standardised :) As for the pairing request, this is the main difference I was talking about, device manager in SDK 8 doesn&amp;#39;t include sending the pairing request prior to authentication, or I don&amp;#39;t know how to do it.&lt;/p&gt;
&lt;p&gt;Both files I included were done at roughly the same time, after connection was established. In my attemt, no pairing request is ever sent, even if I set MITM. I tried all the combinations with and without MITM/bonding, the response is the same. If you could tell me how to initiate pairing request from s120, I think, it will solve my problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59855?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2016 09:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20148b8d-e020-4407-83d8-ebd568940256</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;You could have mentioned that your peripheral was from TI :) Then it may be difficult for me to reproduce it. From your pictures I can&amp;#39;t really see what the difference is, you haven&amp;#39;t included the Pairing Request in both. Maybe you can just upload the files? Does it change anything if you set MITM? I suspect that the TI chip rejects the pairing request because the central says it doesn&amp;#39;t support MITM.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59853?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2016 14:04:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b67c746-1e61-45df-8e94-920091174327</guid><dc:creator>MC</dc:creator><description>&lt;p&gt;First, you will need a peripheral, which has a static passkey hardcoded in the code. In my case, I have &amp;quot;000000&amp;quot;. The sensors I have, require this passkey at bonding (pairing) procedure. Second, use some example code, lets say s120 multilink central example. Please use SDK 8.1.0. Then, connect to the peripheral and inside the &lt;code&gt;client_handling_create&lt;/code&gt; function, call the function &lt;code&gt;dm_security_setup_req&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;After that, you should get an event from DM &lt;code&gt;DM_EVT_SECURITY_SETUP_COMPLETE&lt;/code&gt; in main() with event_result 0x83. This comes from the fact, that &lt;code&gt;dm_security_setup_req&lt;/code&gt; function forces authentication for unbonded devices by calling &lt;code&gt;initiate_security_request&lt;/code&gt;. Because authentication function requires encryption keys to be available, it will always fail, given the fact that link hasn&amp;#39;t been encrypted. Edit: added PNGs to my main question for clarification of the problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When do encryption keys exchange?</title><link>https://devzone.nordicsemi.com/thread/59852?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2016 12:32:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c48c2fa2-9255-4907-9303-187e11b52801</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I&amp;#39;m not familiar with that event. Could you provide some more information so I can try to reproduce it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>