<?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>Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55422/static-passkey-using-and-testing</link><description>Hi, 
 I am using nRF51822, S130, SDK12. 
 Now trying to add a level of security with a static passkey, I have done the following adaptation to my code - 
 Added to void gap_params_init(void) 
 uint8_t passkey[] = STATIC_PASSKEY; m_static_pin_option.gap_opt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Jan 2020 10:26:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55422/static-passkey-using-and-testing" /><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/227213?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2020 10:26:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acfdf7db-826f-44c8-b5f7-3026ba7e57ff</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/226701?ContentTypeID=1</link><pubDate>Mon, 23 Dec 2019 07:31:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2237e542-84b3-406d-9c9e-0cf78026caa5</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The slow advertiser will not start because you have disabled the advertiser timeout while using the &amp;quot;limited discovery mode&amp;quot;. The max. advertisement duration for this mode is 180 seconds (BLE_GAP_ADV_TIMEOUT_LIMITED_MAX).&lt;/p&gt;
&lt;p&gt;It should work if you change the BLE_GAP_ADV_FLAGS_LE&lt;strong&gt;_ONLY_LIMITED_DISC_&lt;/strong&gt;MODE flag to&amp;nbsp;BLE_GAP_ADV_FLAGS_LE_ONLY&lt;strong&gt;_GENERAL_DISC_&lt;/strong&gt;MODE.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/226634?ContentTypeID=1</link><pubDate>Fri, 20 Dec 2019 17:09:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:248ed3ed-81b6-48d0-bf11-3369fc28043c</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Hi Vidar,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;do you mean that&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        case BLE_ADV_EVT_IDLE:
            sleep_mode_enter();
            break; // BLE_ADV_EVT_IDLE&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I changed the entire routine to&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
    switch (ble_adv_evt)
    {
        case BLE_ADV_EVT_FAST:

            break;
        case BLE_ADV_EVT_SLOW:

            break;                
        default:
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;as for the&amp;nbsp;advertising_init() I think I added a slow advertisement configuraiton&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void advertising_init(void)
{
    uint32_t               err_code;
    ble_advdata_t          advdata;
    ble_adv_modes_config_t options;

    // Build and set advertising data.
    memset(&amp;amp;advdata, 0, sizeof(advdata));

    advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance      = true;
    advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;;
    advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    advdata.uuids_complete.p_uuids  = m_adv_uuids;

    memset(&amp;amp;options, 0, sizeof(options));
    options.ble_adv_fast_enabled  = true;
    options.ble_adv_fast_interval = APP_ADV_INTERVAL;
    options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;

    options.ble_adv_slow_enabled = true; //BLE_ADV_SLOW_ENABLED; 
    options.ble_adv_slow_interval = MSEC_TO_UNITS(1475, UNIT_0_625_MS);
    options.ble_adv_slow_timeout = 0;	
	
    err_code = ble_advertising_init(&amp;amp;advdata, NULL, &amp;amp;options, on_adv_evt, NULL);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Still the effect is the same, after timeout advertisement stops.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any more directions?&lt;/p&gt;
&lt;p&gt;Thanks again&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/226595?ContentTypeID=1</link><pubDate>Fri, 20 Dec 2019 14:08:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cee96789-4e16-43ec-8329-e4dd1442ac33</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This example does not implement slow advertising. Instead, it attempts to enter System OFF mode (deep sleep) when the fast advertising times out, see&amp;nbsp;&amp;nbsp;BLE_ADV_EVT_IDLE event in&amp;nbsp;on_adv_evt(). I say attempt because it can&amp;#39;t enter deep sleep if you are debugging the app while it times out.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/226571?ContentTypeID=1</link><pubDate>Fri, 20 Dec 2019 13:26:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:474daa73-eae2-4fc6-8c89-36d68c938f84</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Thanks Vidar&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Do you have any idea why would advertising stop after the fast advertising timeout, it never goes into slow advertising in the GLS example, it just stops.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks again for your help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/226060?ContentTypeID=1</link><pubDate>Wed, 18 Dec 2019 09:29:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:674ac5db-fdb3-4675-a316-2cb5f3d6e5af</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, it&amp;#39;s used to protect against man in the middle attacks.&amp;nbsp;However, legacy passkey pairing does not protect against passive eavesdropping as opposed to the LE secure pairing procedure, which was discussed in the other thread. A high-end BT sniffer will easily brute force the passkey on the fly and retrieve the encryption keys.&amp;nbsp;Also, note that LE secure pairing is not fully supported on the&amp;nbsp;nRF51 series.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/225759?ContentTypeID=1</link><pubDate>Mon, 16 Dec 2019 19:35:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b190cca0-0506-4df9-87b6-bb46d34891a9</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Hey&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Isn&amp;#39;t the passkey (including static passkey) used to protect encryption key exchange as well?&lt;/p&gt;
&lt;p&gt;in this thread -&amp;nbsp;&lt;a title="LE Secure Connections" href="https://devzone.nordicsemi.com/f/nordic-q-a/35856/questions-about-lesc-mitm-and-passkey"&gt;Questions about LESC, MITM and passkey&lt;/a&gt;&amp;nbsp;it states that&amp;nbsp;&lt;span&gt;&amp;quot;In LESC passkey pairing, the pairing is safe from MITM attacks, as long as the MITM doesn&amp;#39;t know the passkey&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I understand that using a &lt;strong&gt;static passkey&lt;/strong&gt; the MITM eventually will guess the correct key, the author there suggest using a password, and says that &amp;quot;(they won&amp;#39;t be able to decrypt the data and they will not learn the password)&amp;quot;, I did not understand why wouldn&amp;#39;t a eavesdropper&amp;nbsp;attacker be able to able to learn this password if it can learn my passkey.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;I would appreciate if you would share what to you opinion will be the best way to protect my data given&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks again!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/225747?ContentTypeID=1</link><pubDate>Mon, 16 Dec 2019 17:33:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbd00a41-a5f4-4d81-9c56-297a9e70a474</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;the devices agree on a common encryption key during the pairing/bonding procedure, but that key is not derived or based on the passkey in any way. If you just need encryption you can use the &amp;quot;just works&amp;quot; procedure.&lt;/p&gt;
&lt;p&gt;Relevant message sequence charts:&lt;/p&gt;
&lt;p&gt;&lt;a title="Bonding: Just Works" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.1/group___b_l_e___g_a_p___p_e_r_i_p_h___b_o_n_d_i_n_g___j_w___m_s_c.html?cp=5_7_2_2_2_1_3_8_7_0"&gt;Bonding: Just Works&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="active" title="Bonding: Passkey Entry with static passkey" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.1/group___b_l_e___g_a_p___p_e_r_i_p_h___b_o_n_d_i_n_g___s_t_a_t_i_c___p_k___m_s_c.html?cp=5_7_2_2_2_1_3_8_7_1"&gt;Bonding: Passkey Entry with static passkey&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Edit: it may be helpful to take a look at other forum threads that discuss the security aspects of pairing and bonding. This one for instance:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/35856/questions-about-lesc-mitm-and-passkey/138175"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/35856/questions-about-lesc-mitm-and-passkey/138175&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/225745?ContentTypeID=1</link><pubDate>Mon, 16 Dec 2019 17:27:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db5b8728-daa5-483c-b1c3-f1f85ef8e74f</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Hey Vidar&lt;/p&gt;
&lt;p&gt;you said&amp;nbsp;&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/55422/static-passkey-using-and-testing/224927"]The passkey is not used for encryption, but to protect against man-in-the-middle (MITM) attacks[/quote]
&lt;p&gt;Is implementing encryption conditioned&amp;nbsp;by&amp;nbsp;pairing and bonding? Does that not requiring passing keys earlier? what key does the encryption use? is there an additional key?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/225662?ContentTypeID=1</link><pubDate>Mon, 16 Dec 2019 13:36:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c4ab622-becf-496d-b35a-4e24ffeba70c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I suggest we continue the discussion in the other thread you posted here:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/55668/sd_ble_gap_authenticate-causes-hardfault"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/55668/sd_ble_gap_authenticate-causes-hardfault&lt;/a&gt;. When you get a hardfault on a SD call it usually means that you&amp;#39;re using the wrong interrupt priority levels.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/225463?ContentTypeID=1</link><pubDate>Fri, 13 Dec 2019 18:05:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63d604b2-c5ce-43c8-8827-9c724a48375e</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Thank you Vidar&lt;/p&gt;
&lt;p&gt;So far I have change the GLS to static passkey and connected successfully.&lt;/p&gt;
&lt;p&gt;Since than I have tried to migrate that code into a thin version of my existing application and encountered a hardfault after the&amp;nbsp;&lt;strong&gt;sd_ble_gap_authenticate&lt;/strong&gt; command&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static ret_code_t link_secure_peripheral(uint16_t conn_handle, ble_gap_sec_params_t * p_sec_params)
{
    // This should never happen for a peripheral.
    NRF_PM_DEBUG_CHECK(p_sec_params != NULL);

    // VERIFY_PARAM_NOT_NULL(p_sec_params);

    ret_code_t err_code = sd_ble_gap_authenticate(conn_handle, p_sec_params);

    return err_code;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Have no idea what causes this and how to fix it.&lt;/p&gt;
&lt;p&gt;Would appreciate your help on that issue as well&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/224927?ContentTypeID=1</link><pubDate>Wed, 11 Dec 2019 13:16:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1592348e-edb0-42ca-8388-f7eea35f3604</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I should have pointed out that the glucose app uses a dynamic passkey, not a static one. That is why the BLE_GAP_OPT_PASSKEY isn&amp;#39;t used. But the configuration should be similar apart from that.&lt;/p&gt;
[quote user="EranR"]I don&amp;#39;t have display capabilities or keyboard on the peripheral I am developing for, I am connecting a peripheral to a mobile device (first as I said will try to use nRF Connect).[/quote]
&lt;p&gt;The device must either have a display or a keyboard option to support passkey pairing. The central will not initiate passkey pairing otherwise. But since you&amp;#39;re using static passkey the key could be displayed in other ways. It could be printed on a sticker for instance.&amp;nbsp; &lt;/p&gt;
[quote user="EranR"]Will a static passkey not ensure encryption for all characteristics?[/quote]
&lt;p&gt;&amp;nbsp;You need to change the security level in your service initialization to limit access to characteristics. Code snippet below show how the gls measurement characteristic is set to require encryption for write access.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint32_t glucose_measurement_char_add(ble_gls_t * p_gls)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_md_t cccd_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;
    ble_gls_rec_t       initial_gls_rec_value;
    uint8_t             encoded_gls_meas[MAX_GLM_LEN];
    uint8_t             num_recs;
    memset(&amp;amp;cccd_md, 0, sizeof(cccd_md));

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&amp;amp;cccd_md.write_perm); &amp;lt;---- Notifications can&amp;#39;t be enabled unless the link is secured &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The passkey is not used for encryption, but to protect against man-in-the-middle (MITM) attacks while performing the pairing procedure. And the MITM protection isn&amp;#39;t particularly effective when you use a static key and legacy pairing, unfortunately. &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;These message sequence charts may help illustrate the different security procedures. It&amp;#39;s from the Application&amp;#39;s point of view&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a title="Peripheral Security Procedures" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.1/group___b_l_e___g_a_p___p_e_r_i_p_h___s_e_c___m_s_c.html?cp=5_7_2_2_2_1_3_8"&gt;Peripheral Security Procedures&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/224785?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2019 16:16:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0fdd1b3-2a8f-4b3d-bd3c-c732789071c4</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Thank you Vidar for your answer&lt;/p&gt;
&lt;p&gt;As far as I understood from the code, Glucose Application uses&amp;nbsp;BLE_GAP_OPT_PRIVACY, not&amp;nbsp;BLE_GAP_OPT_PASSKEY, Is that example relevant to using static passkey?&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t have display capabilities or keyboard on the peripheral I am developing for, I am connecting a peripheral to a mobile device (first as I said will try to use nRF Connect).&lt;/p&gt;
&lt;p&gt;Will a static passkey not ensure encryption for all characteristics?&lt;/p&gt;
&lt;p&gt;Thanks !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Passkey, using and testing</title><link>https://devzone.nordicsemi.com/thread/224755?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2019 13:37:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b6b5dc6-48f7-4210-a640-aaf644c44dfc</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I suggest that you try with this with the&amp;nbsp;&lt;a title="Glucose Application" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.3.0/ble_sdk_app_gls.html?cp=6_5_8_4_2_2_7"&gt;Glucose Application&lt;/a&gt;&amp;nbsp;example first, then use that as a reference on what settings to use. &lt;span&gt;SEC_PARAM_MITM must be set to &amp;#39;1&amp;#39; and&amp;nbsp; SEC_PARAM_IO_CAPABILITIES&amp;nbsp;&amp;nbsp;must say you have display capabilities.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Note that these security parameters define the security capabilities of the device and not the security requirements/level which is set individually for each characteristic.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>