<?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>Ensuring 16 Byte of entropy in Security Mode 1v4</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55727/ensuring-16-byte-of-entropy-in-security-mode-1v4</link><description>Hello, 
 I&amp;#39;m currently trying to implement a setup of BLE devices (nRF52 DK and nRF52840 DK) which is potentially secure against the KNOB attack (and also other attacks) and uses the full 16 bytes of entropy for the encryption. I&amp;#39;ve found this thread</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Jan 2020 07:03:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55727/ensuring-16-byte-of-entropy-in-security-mode-1v4" /><item><title>RE: Ensuring 16 Byte of entropy in Security Mode 1v4</title><link>https://devzone.nordicsemi.com/thread/228931?ContentTypeID=1</link><pubDate>Tue, 14 Jan 2020 07:03:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:262c49a8-beed-4ef9-82c2-318f7f941d41</guid><dc:creator>TobiasM</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Bj&amp;oslash;rn,&lt;/p&gt;
&lt;p&gt;thank you for the additional information. Following your code example, I&amp;#39;ve noticed that setting &lt;em&gt;security_req_t&lt;/em&gt; to &lt;em&gt;SEC_SIGNED&lt;/em&gt; will call the macro&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;&lt;em&gt;BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr)&lt;/em&gt; which corresponds to setting security mode 2 level 1. In my case I would need to call&amp;nbsp;&lt;em&gt;BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM(ptr)&lt;/em&gt; which seems not to be part of the &lt;em&gt;set_security_req &lt;/em&gt;function and needs to be added.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Nevertheless, this will answer my question and I will move from using the nRF Connect BLE App to programming my server setup directly, as I&amp;#39;ll have better insight and control over the settings.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Tobias&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ensuring 16 Byte of entropy in Security Mode 1v4</title><link>https://devzone.nordicsemi.com/thread/228860?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2020 15:09:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c50e32ed-e413-4a2b-80f3-ad132a499819</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;HI Tobias,&lt;/p&gt;
&lt;p&gt;setting the security_req_t for reading or writing to characteristic value to&amp;nbsp;SEC_MITM, will set the security level to mode 1 level 3&lt;/p&gt;
&lt;p&gt;Lets take the Battery Level Characteristic as an example. In bas_init() we see that&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  // Require LESC with MITM (Numeric Comparison)
    bas_init_struct.bl_cccd_wr_sec   = SEC_MITM;
    bas_init_struct.bl_report_rd_sec = SEC_MITM;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and that the characteristic is added by calling battery_level_char_add(), which in turn calls characteristic_add(), which in turn calls set_security_req().&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static inline void set_security_req(security_req_t level, ble_gap_conn_sec_mode_t * p_perm)
{
    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(p_perm);
    switch (level)
    {
        case SEC_NO_ACCESS:
            BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(p_perm);
        break;
        case SEC_OPEN:
            BLE_GAP_CONN_SEC_MODE_SET_OPEN(p_perm);
        break;
        case SEC_JUST_WORKS:
            BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(p_perm);
        break;
        case SEC_MITM:
            BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(p_perm);
        break;
        case SEC_SIGNED:
            BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(p_perm);
        break;
        case SEC_SIGNED_MITM:
            BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(p_perm);
        break;
    }
    return;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The macros used in expands to the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters
 *
 * See @ref ble_gap_conn_sec_mode_t.
 * @{ */
/**@brief Set sec_mode pointed to by ptr to have no access rights.*/
#define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr)          do {(ptr)-&amp;gt;sm = 0; (ptr)-&amp;gt;lv = 0;} while(0)
/**@brief Set sec_mode pointed to by ptr to require no protection, open link.*/
#define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr)               do {(ptr)-&amp;gt;sm = 1; (ptr)-&amp;gt;lv = 1;} while(0)
/**@brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/
#define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr)        do {(ptr)-&amp;gt;sm = 1; (ptr)-&amp;gt;lv = 2;} while(0)
/**@brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/
#define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr)      do {(ptr)-&amp;gt;sm = 1; (ptr)-&amp;gt;lv = 3;} while(0)
/**@brief Set sec_mode pointed to by ptr to require LESC encryption and MITM protection.*/
#define BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM(ptr) do {(ptr)-&amp;gt;sm = 1; (ptr)-&amp;gt;lv = 4;} while(0)
/**@brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/
#define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr)     do {(ptr)-&amp;gt;sm = 2; (ptr)-&amp;gt;lv = 1;} while(0)
/**@brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/
#define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr)   do {(ptr)-&amp;gt;sm = 2; (ptr)-&amp;gt;lv = 2;} while(0)
/**@} */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So if you want the security of a characteristic set to mode 1 level 4, then you need to set the security_req_t to SEC_SIGNED&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ensuring 16 Byte of entropy in Security Mode 1v4</title><link>https://devzone.nordicsemi.com/thread/228264?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2020 07:35:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82bd1a86-8ebf-45ad-a887-b2e71e121f3a</guid><dc:creator>TobiasM</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Bj&amp;oslash;rn,&lt;/p&gt;
&lt;p&gt;I was using the app found in &amp;quot;SDK16.0.0 Folder&lt;span style="background-color:#ffffff;"&gt;&amp;quot;\examples\ble_central_and_peripheral\experimental\ble_app_interactive\ for the nRF52840DK (PCA10056). I&amp;#39;ve just made some minor changes, s.t. the security levels will be printed to check which levels are active and i&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;n sdk_config.h I&amp;#39;ve changed the&amp;nbsp;BLE_SEC_PARAM_MAX_KEY_SIZE value to 7, as the smallest number exchanged between both devices will be used as encryption key size according to the spec.&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;On server side I&amp;#39;ve used nRF Connect running on the nRF52DK. I&amp;#39;ve added a new service and a characteristic with read permission &amp;quot;LESC encryption with MITM required&amp;quot; which should be level 4 as I understand it. Therefore the first option is used.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;I did double check the exchange of the parameters using a sniffer. The Log file of the nRF Connect states &amp;quot;Security updated, mode: 1, level: 4&amp;quot; and I&amp;#39;m able to read the characteristic with the Interactive App which shows only security level 3 in that case.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;Best regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;Tobias&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ensuring 16 Byte of entropy in Security Mode 1v4</title><link>https://devzone.nordicsemi.com/thread/227935?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2020 14:37:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0cbea881-14e2-4266-8772-63d245a5cb17</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Tobias,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;which interactive application from SDK v16.0.0 did you use? Please provide the name of the example or the path inside the SDK v16.0.0 folder.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did this example set the security mode of the characteristic using&amp;nbsp;BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM or with&amp;nbsp;BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ensuring 16 Byte of entropy in Security Mode 1v4</title><link>https://devzone.nordicsemi.com/thread/226799?ContentTypeID=1</link><pubDate>Tue, 24 Dec 2019 11:01:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7de6891c-ca4c-4077-991c-4568a86f238f</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi Tobias,&lt;/p&gt;
&lt;p&gt;Just wanted to let you know that Bjørn is out on vacation until the 2nd week of January. He will come back to you then.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ensuring 16 Byte of entropy in Security Mode 1v4</title><link>https://devzone.nordicsemi.com/thread/226110?ContentTypeID=1</link><pubDate>Wed, 18 Dec 2019 10:54:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e5d26f4-e573-43ba-b147-a17435546079</guid><dc:creator>TobiasM</dc:creator><description>&lt;p&gt;Thank you for the&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;clarification&lt;/span&gt;. Unfortunately after testing my setup I ran into problems.&lt;/p&gt;
&lt;p&gt;In case of pairing both devices with lower encryption key size than 16 byte I shouldn&amp;#39;t be in security mode 1 level 4. After testing my nRF52840 DK and nRF52 DK with interactive app running on both devices I could confirm this &lt;span style="background-color:#ffffff;"&gt;behaviour by intentionally reducing the max encryption key size. After trying the same thing using nRF Connect on one device and the interactive app on the other, I encountered that nRF Connect assumes I have security mode 1 level 4 even if the key size was reduced. The interactive app shows security mode 1 level 3 in this case, which seems to be more reasonable to me.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;Therefore I was able to read characteristics from nRF Connect which should be only readable for security mode 1 level 4. Is this a bug? I was using nRF Connect v3.3.0 with BLE App v&lt;/span&gt;2.3.2 and the interactive app from the SDK16.0.0. I&amp;#39;ve used Numeric Comparison as pairing method.&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;Tobias&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ensuring 16 Byte of entropy in Security Mode 1v4</title><link>https://devzone.nordicsemi.com/thread/226041?ContentTypeID=1</link><pubDate>Wed, 18 Dec 2019 08:45:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0085e56e-4722-47cf-b34b-1019bccd7d90</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;My understanding is that the vulnerability is for the key negotiation process, i.e. pairing process. For Bluetooth Low Energy device and then both the central and peripheral device will store the negotiated key in internal memory and then use this key for all subsequent communication. So the&amp;nbsp;&lt;span&gt;&amp;quot;Keysize too small&amp;quot; error will be generated if the central device or an attacker tries to use a lower key size than SEC_PARAM_MIN_KEY_SIZE during the pairing process.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;So if you attempt to read or write to a characteristic that has a its security level requirement set to&amp;nbsp;&amp;nbsp;&lt;span&gt;Security Mode 1 level 4, but the link securit level is not high &lt;span style="font-size:12px;"&gt;enough, then you will get an error message stating&amp;nbsp;Insufficient Authorization, see&amp;nbsp;BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part F page 2335.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span style="font-size:12px;"&gt;Best regards&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span style="font-size:12px;"&gt;Bjørn&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ensuring 16 Byte of entropy in Security Mode 1v4</title><link>https://devzone.nordicsemi.com/thread/225974?ContentTypeID=1</link><pubDate>Tue, 17 Dec 2019 19:02:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cee67725-2382-4f33-bdcf-b28bd610fe5b</guid><dc:creator>TobiasM</dc:creator><description>&lt;p&gt;Hi Bj&amp;oslash;rn,&lt;/p&gt;
[quote userid="7571" url="~/f/nordic-q-a/55727/ensuring-16-byte-of-entropy-in-security-mode-1v4/225890"]Our SoftDevices for the nRF52 series will reject the pairing request if the key size is below the minimum set in the application, see&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.0.1/group___b_l_e___g_a_p___p_e_r_i_p_h___p_a_i_r_i_n_g___k_s___t_o_o___s_m_a_l_l___m_s_c.html"&gt;GAP Failed Pairing: Keysize too small&lt;/a&gt;.&amp;nbsp;[/quote]
&lt;p&gt;if I understand correctly, in case of trying to read a characteristic with Security Mode 1 level 4 in the setup of two paired devices which have been paired let&amp;#39;s say by Numeric Comparison, I would get a &amp;quot;Keysize too small&amp;quot; error if the entropy for the encryption key is lower than 16 bytes. Is this correct?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Tobias&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ensuring 16 Byte of entropy in Security Mode 1v4</title><link>https://devzone.nordicsemi.com/thread/225890?ContentTypeID=1</link><pubDate>Tue, 17 Dec 2019 13:14:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c9fa845-242d-4aad-a745-f0ff82be883d</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;HI Tobias,&amp;nbsp;&lt;/p&gt;
[quote user=""]I could set the min key length to 16 bytes for both devices, but I just want to use the full key length for specific services.[/quote]
&lt;p&gt;it is possible to set the security requirement for individual attributes in the GATT table, i.e. a characterisistic can only be read or written to if the Security level is high enough, e.g.&amp;nbsp;&lt;span&gt;&amp;nbsp;Security Mode 1 level 4&lt;/span&gt;&lt;/p&gt;
[quote user=""]In the paper &lt;a href="https://eprint.iacr.org/2019/933.pdf"&gt;eprint.iacr.org/.../933.pdf&lt;/a&gt; on page 11 it is specifically mentioned that &amp;quot;even if a device using security mode 1 with level 4, the LTK&amp;#39;s entropy can still be downgraded to 7 bytes&amp;quot;. Am I missing something or this a bug of the tested devices? Is it possible to downgrade the nRF52840 or nRF52832 to use 7 bytes of entropy in Security Mode 1v4?[/quote]
&lt;p&gt;Our SoftDevices for the nRF52 series will reject the pairing request if the key size is below the minimum set in the application, see&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.0.1/group___b_l_e___g_a_p___p_e_r_i_p_h___p_a_i_r_i_n_g___k_s___t_o_o___s_m_a_l_l___m_s_c.html"&gt;GAP Failed Pairing: Keysize too small&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>