<?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 encryption link</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51290/ble-encryption-link</link><description>Hello, I&amp;#39;m developing application starting from blinky example extracted from nRF5_SDK_15.3.0_59ac345 SDK. I see (using nRF Connect) that the connection result as &amp;quot;unencrypted link&amp;quot; (image here below) How can I make the link secured with encryption? There</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 05 Sep 2019 12:44:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51290/ble-encryption-link" /><item><title>RE: BLE encryption link</title><link>https://devzone.nordicsemi.com/thread/208215?ContentTypeID=1</link><pubDate>Thu, 05 Sep 2019 12:44:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d622e027-4a31-4e97-b0f0-ef682112473d</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Abele,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Good to hear the success, and also thanks for sharing the experiences.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE encryption link</title><link>https://devzone.nordicsemi.com/thread/208211?ContentTypeID=1</link><pubDate>Thu, 05 Sep 2019 12:25:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69302cb0-4f7a-4ece-b7ae-2632307c9b55</guid><dc:creator>abe</dc:creator><description>&lt;p&gt;Hi Amanda,&lt;/p&gt;
&lt;p&gt;Using the macro BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM on characteristic configuration, GATT write is enabled ONLY with pairing (unauthenticated encrypted link).&lt;br /&gt;here my code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint32_t custom_value_char_add(ble_cusi_t * p_cusi, const ble_cusi_init_t * p_cusi_init)
{
    uint32_t            err_code;
    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;

    // Add Custom Value characteristic
    memset(&amp;amp;cccd_md, 0, sizeof(cccd_md));

    //  write operation on cccd should not be possible without authentication.
    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);
    
    cccd_md.write_perm = p_cusi_init-&amp;gt;custom_value_char_attr_md.write_perm;
    cccd_md.read_perm  = p_cusi_init-&amp;gt;custom_value_char_attr_md.read_perm;
    cccd_md.vloc       = BLE_GATTS_VLOC_STACK;

    memset(&amp;amp;char_md, 0, sizeof(char_md));

    char_md.char_props.read   = 1;
    char_md.char_props.write  = 1;
    char_md.char_props.notify = 0; 
    char_md.p_char_user_desc  = NULL;
    char_md.p_char_pf         = NULL;
    char_md.p_user_desc_md    = NULL;
    char_md.p_cccd_md         = &amp;amp;cccd_md; 
    char_md.p_sccd_md         = NULL;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I reached may goal, thanks for your help.&lt;br /&gt;Abele&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE encryption link</title><link>https://devzone.nordicsemi.com/thread/207689?ContentTypeID=1</link><pubDate>Tue, 03 Sep 2019 12:53:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01e2ee75-def4-4b0d-ba59-0e3fb0fdd28f</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Abele,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="Abele"]My goal is to enable data write ONLY if the device is paired. How can I make this? [/quote]
&lt;p&gt;&amp;nbsp;&lt;span lang="en-US"&gt;&amp;nbsp;You can modify&amp;nbsp;&lt;/span&gt;&lt;span lang="nb-NO"&gt;the &amp;quot;Properties&amp;quot; field in the Characteristic Declaration has changed to &amp;quot;Write&amp;quot;. In this&amp;nbsp;&lt;/span&gt;&lt;a href="https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-characteristics-a-beginners-tutorial"&gt;&lt;span lang="nb-NO"&gt;Bluetooth low energy Characteristics, a beginner&amp;#39;s&lt;/span&gt;&lt;/a&gt;&lt;span lang="nb-NO"&gt;,&amp;nbsp;Step 2.F section shows how to add read/write properties to our characteristic value. You can disable the write p&lt;/span&gt;&lt;span lang="nb-NO"&gt;roperty&amp;nbsp;&lt;/span&gt;&lt;span lang="nb-NO"&gt;part.&lt;/span&gt;&lt;/p&gt;
[quote user="Abele"]Further, using nRF Connect for Android phone, how can I perform &amp;quot;pairing&amp;quot;??[/quote]
&lt;p&gt;&lt;span&gt;The BLE stack automatically pops up an alert view to prompt the user to confirm or cancel the pairing process. You can try&amp;nbsp;&lt;a title="HID Keyboard Application" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_hids_keyboard.html?cp=5_1_4_2_2_15"&gt;HID Keyboard Application&lt;/a&gt;&amp;nbsp;on nrf52840 DK with an Android phone.&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;-Amanda H.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE encryption link</title><link>https://devzone.nordicsemi.com/thread/207623?ContentTypeID=1</link><pubDate>Tue, 03 Sep 2019 09:41:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fc0b0f1-8a62-4db8-ae2a-3e26ac663344</guid><dc:creator>abe</dc:creator><description>&lt;p&gt;Hi Amanda,&lt;/p&gt;
&lt;p&gt;I tried some test with the macro you quote me. I&amp;#39;m using nRF Conncet v3.1.0 for desktop to check the results.&lt;br /&gt;Now I&amp;#39;m able to perform a &amp;quot;pairing&amp;quot; that result as &amp;quot;Unauthenticated encrypted link&amp;quot; (see image here below)&lt;br /&gt;My goal is to enable data write ONLY if the device is paired. How can I make this? &lt;br /&gt;Now only connection is enough to write data.&lt;br /&gt;Further, using nRF Connect for Android phone, how can I perform &amp;quot;pairing&amp;quot;?? &lt;/p&gt;
&lt;p&gt;Many thanks for your help.&lt;br /&gt;Regards&lt;/p&gt;
&lt;p&gt;Abele&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/PairEcr.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE encryption link</title><link>https://devzone.nordicsemi.com/thread/205897?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2019 12:47:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:169de309-fc3b-44b7-b881-a0bb8eef901f</guid><dc:creator>abe</dc:creator><description>&lt;p&gt;Ok Amanda, as soon as I can I will try to make changes on these macro and will report you the results.&lt;br /&gt;Hear you next week&lt;br /&gt;Thanks.&lt;br /&gt;Abele&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE encryption link</title><link>https://devzone.nordicsemi.com/thread/205892?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2019 12:36:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1b03585-bd34-4829-bdeb-dad0ab15bdd4</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Abele,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If I understand correctly, you are asking:&lt;/p&gt;
&lt;p&gt;What will happen if&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM replaces BLE_GAP_CONN_SEC_MODE_SET_OPEN in the gap_params_init()&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=&amp;gt;&amp;nbsp;&lt;span&gt;Set sec_mode pointed to by &amp;amp;sec_mode to require encryption, but no MITM protection.&amp;nbsp;You might see this&amp;nbsp;&lt;/span&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/36707/nrf52832-ble_gap_conn_sec_mode_set_enc_no_mitm-failed?ReplySortBy=CreatedDate&amp;amp;ReplySortOrder=Ascending"&gt;situation&lt;/a&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Modify the SEC_PARAM_MITM&amp;nbsp;definition from 0 to 1 for peer_manager_init&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=&amp;gt;&amp;nbsp;Man In The Middle protection is required. You might see the case in the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_pm_usage.html?resultof=%22%53%45%43%5f%50%41%52%41%4d%5f%4d%49%54%4d%22%20"&gt;nRF5 SDK v15.3.0: Usage&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE encryption link</title><link>https://devzone.nordicsemi.com/thread/205878?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2019 11:45:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2633a8ab-cbfd-44f1-add8-d48bd406b29e</guid><dc:creator>abe</dc:creator><description>&lt;p&gt;Thanks Amanda. I read the post you link above, but&amp;nbsp;if I well understand explain hot to set encryption one single gatt characteristic at time.&lt;br /&gt;&lt;br /&gt;I see&amp;nbsp;peer_manager_init, with some Security parameters macro&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Function for the Peer Manager initialization.
 */
static void peer_manager_init(void)
{
    ble_gap_sec_params_t sec_param;
    ret_code_t           err_code;

    err_code = pm_init();
    APP_ERROR_CHECK(err_code);

    memset(&amp;amp;sec_param, 0, sizeof(ble_gap_sec_params_t));

    // Security parameters to be used for all security procedures.
    sec_param.bond           = SEC_PARAM_BOND;
    sec_param.mitm           = SEC_PARAM_MITM;
    sec_param.lesc           = SEC_PARAM_LESC;
    sec_param.keypress       = SEC_PARAM_KEYPRESS;
    sec_param.io_caps        = SEC_PARAM_IO_CAPABILITIES;
    sec_param.oob            = SEC_PARAM_OOB;
    sec_param.min_key_size   = SEC_PARAM_MIN_KEY_SIZE;
    sec_param.max_key_size   = SEC_PARAM_MAX_KEY_SIZE;
    sec_param.kdist_own.enc  = 1;
    sec_param.kdist_own.id   = 1;
    sec_param.kdist_peer.enc = 1;
    sec_param.kdist_peer.id  = 1;

    err_code = pm_sec_params_set(&amp;amp;sec_param);
    APP_ERROR_CHECK(err_code);

    err_code = pm_register(pm_evt_handler);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and gap_params_init, where is&amp;nbsp;used the macro&amp;nbsp;BLE_GAP_CONN_SEC_MODE_SET_OPEN.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Function for the GAP initialization.
 *
 * @details This function sets up all the necessary GAP (Generic Access Profile) parameters of the
 *          device including the device name, appearance, and the preferred connection parameters.
 */
static void gap_params_init(void)
{
    ret_code_t              err_code;
    ble_gap_conn_params_t   gap_conn_params;
    ble_gap_conn_sec_mode_t sec_mode;

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;sec_mode);

    err_code = sd_ble_gap_device_name_set(&amp;amp;sec_mode,
                                          (const uint8_t *)DEVICE_NAME,
                                          strlen(DEVICE_NAME));
    APP_ERROR_CHECK(err_code);

    /* YOUR_JOB: Use an appearance value matching the application&amp;#39;s use case.
       err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_);
       APP_ERROR_CHECK(err_code); */

    memset(&amp;amp;gap_conn_params, 0, sizeof(gap_conn_params));

    gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
    gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
    gap_conn_params.slave_latency     = SLAVE_LATENCY;
    gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;

    err_code = sd_ble_gap_ppcp_set(&amp;amp;gap_conn_params);
    APP_ERROR_CHECK(err_code);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;What happens if I change the macro inside this two functions?&lt;br /&gt;For example, using in&amp;nbsp;&lt;span&gt;gap_params_init the macro&amp;nbsp;BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM or in&amp;nbsp;peer_manager_init&amp;nbsp;changing the&amp;nbsp;SEC_PARAM_MITM macro define 0 to 1?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Many thanks for your help&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Abele&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE encryption link</title><link>https://devzone.nordicsemi.com/thread/205854?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2019 10:54:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5064fe3-a16e-49c7-9fe8-3a188fe6708a</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Abele,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You don&amp;#39;t have to bond to get an encrypted link. You will get an encrypted link if you pair, but if you don&amp;#39;t bond, you will have to pair every time you connect to get an encrypted link. Also, see my colleague explained in this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/45458/nrf52832-security-level-and-bonding?ReplySortBy=CreatedDate&amp;amp;ReplySortOrder=Ascending"&gt;post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The Peer manager implements pairing and has a bond field in the security parameters that you pass when it is initialized. By setting that to 0 you indicate that bonding is not supported. With this change, pairing will take place as before, but there will be no bonding (storing of bonding information such as keys)&lt;/p&gt;
&lt;p lang="nb-NO"&gt;&lt;/p&gt;
&lt;p lang="nb-NO"&gt;&amp;nbsp;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE encryption link</title><link>https://devzone.nordicsemi.com/thread/205556?ContentTypeID=1</link><pubDate>Thu, 22 Aug 2019 11:20:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9aa8d331-4ab9-40d6-8718-d05667bca1c6</guid><dc:creator>abe</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If I have good understand, the encryption is performed only with bonding??&lt;br /&gt;I&amp;#39;m developing a new board that have a BLE peripheral (starting from blinky example) and my goals is to encrypt the communication only with/during pairing, this custom project don&amp;#39;t wish bonding.&lt;br /&gt;There is any way to do encryption without bonding?&lt;br /&gt;Abele&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE encryption link</title><link>https://devzone.nordicsemi.com/thread/205542?ContentTypeID=1</link><pubDate>Thu, 22 Aug 2019 10:59:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ed87e9b-cce6-4ff6-bf8a-a0fb3e863b57</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There are some examples in the SDK that uses encryption (bonding).&amp;nbsp;&lt;/span&gt;&lt;span&gt;You can take a look at the &lt;a title="Bond Management Application" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_bms.html?cp=5_1_4_2_2_5"&gt;Bond Management Application&lt;/a&gt;&amp;nbsp;example or &lt;a title="Proximity Application" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_proximity.html?cp=5_1_4_2_2_21"&gt;Proximity Application&lt;/a&gt;&amp;nbsp;example.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-Amanda H.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>