<?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>Update passkey after bonding</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/24051/update-passkey-after-bonding</link><description>Hello, 
 I would like to know the best practices to update a passkey for bonding. 
 For the moment, I have a static passkey that I set during ble initialization and I can bond to my device with the default password &amp;quot;123456&amp;quot;. I have a characteristic</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 06 Aug 2017 17:44:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/24051/update-passkey-after-bonding" /><item><title>RE: Update passkey after bonding</title><link>https://devzone.nordicsemi.com/thread/94692?ContentTypeID=1</link><pubDate>Sun, 06 Aug 2017 17:44:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a566ea98-966a-4292-9261-20e95cfce3c5</guid><dc:creator>Ulrich Myhre</dc:creator><description>&lt;p&gt;Create a custom characteristic, and when a write is sent to it, filter out that write event. Do some sanity checking (must be only numbers, in ASCII, 6 characters), then write it to a flash page. Whenever you are about to start to advertise/connect, read the value from flash and call &lt;code&gt;sd_ble_opt_set()&lt;/code&gt; just like you do now. To store to flash, you could just erase and write on your own through the flash API, or try to make use of the Pstorage module if you intend to store more data later.&lt;/p&gt;
&lt;p&gt;The other points about the security still stands though. A static passkey adds very little security over non-MITM protected connections.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update passkey after bonding</title><link>https://devzone.nordicsemi.com/thread/94690?ContentTypeID=1</link><pubDate>Fri, 04 Aug 2017 11:32:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a61cb97-f103-4797-8b6e-e6c73ab771e8</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Konova,&lt;/p&gt;
&lt;p&gt;I assume what you plan to do is to have a default static passkey of &amp;quot;123456&amp;quot; initially.
Then after the first bond, you have an option to change it to a new passkey, via a BLE command (a write from the phone to the device for example).&lt;/p&gt;
&lt;p&gt;After that the new bond to other centrals should use the new passkey.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t see why this shouldn&amp;#39;t work (but as Ulrich mentioned, this won&amp;#39;t bring much security).&lt;/p&gt;
&lt;p&gt;Note that there is nothing stored to flash when you call sd_ble_opt_set(). So you need to store the new passkey it in flash and then every time the chip boot up you should call sd_ble_opt_set() to set the passkey to the stored passkey.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update passkey after bonding</title><link>https://devzone.nordicsemi.com/thread/94694?ContentTypeID=1</link><pubDate>Thu, 03 Aug 2017 22:09:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a3d4160-7881-4672-a722-2165ae368cbd</guid><dc:creator>Corentin</dc:creator><description>&lt;p&gt;Hello,
Thank you for your reply. I have a device with no screen or keyboard so i set a défault static key &amp;quot;123456&amp;quot;. My question is how i can changed this passkey after bonding. I create a characteristic to save the new passkey but i don&amp;#39;t know how i can update with the new passkey for future bonding.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update passkey after bonding</title><link>https://devzone.nordicsemi.com/thread/94691?ContentTypeID=1</link><pubDate>Thu, 03 Aug 2017 20:17:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d35a257d-8af9-4d7c-846a-122290ca206a</guid><dc:creator>Ulrich Myhre</dc:creator><description>&lt;p&gt;Hi Konova,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m having trouble understanding what you really want to do. Why do you want to change the passkey? What are you actually trying to protect against? Depending on this, there are multiple answers to your question.&lt;/p&gt;
&lt;p&gt;First of all, once a bond has been established, you should not need the passkey again until the bond is considered lost. If you ever want to connect to only one device, you can simply disallow bonding altogether once a bond exists, and allow the user to delete the bond through a physical operation (e.g. keypress).&lt;/p&gt;
&lt;p&gt;Secondly, setting the passkey should be done before connection initiation. This can be solved by generating a random number and storing it in RAM or flash. You can also let the peer write to a special characteristic to change the default static passkey. To permanently store this, you need to store it in flash.&lt;/p&gt;
&lt;p&gt;But if your concern is to protect against sniffing, you should not use legacy pairing at all - unless you are using the OOB mode. Best practice is to use LE Secure Connections, and to have some way to exchange data, like keyboard/display/NFC. When you use legacy pairing with &amp;quot;Just Works&amp;quot;, the temporal key (used to derive the session key, which encrypts during bonding information exchange) is all zeros. If you use a passkey, it is all zeros except 6 ASCII codes at the end, all between 0-9. That doesn&amp;#39;t take much computer power to brute-force, so if someone sniffs the bonding procedure they can trivially sniff future connections too. But if the bonding happens in secret or in a secure way, the long-term key used has high enough entropy to be secure.&lt;/p&gt;
&lt;p&gt;To put it simple, adding a passkey makes little difference to a passive sniffer, when using legacy pairing. It does protect against accidental connections, if you make sure that all your devices have different passkeys. Best practice for security is to use LESC.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>