<?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>Resolving random private address ... where is the IRKs array?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/47285/resolving-random-private-address-where-is-the-irks-array</link><description>Hi all, 
 I use nRF52832-QFAA, S132 2.0.0, SDK 11.0.0, IAR 7.5, Windows 
 Upon connection, I am trying to resolve the peer &amp;quot;random private resolvable&amp;quot; address (not for whitelisting, just to check who I am connected to). 
 I have most information needed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 May 2019 21:02:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/47285/resolving-random-private-address-where-is-the-irks-array" /><item><title>RE: Resolving random private address ... where is the IRKs array?</title><link>https://devzone.nordicsemi.com/thread/188041?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 21:02:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6f5c7e6-d4bf-435a-97b9-88c5d85f751b</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Final update:&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;After reading this post ...&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;a style="background-attachment:scroll;background-color:transparent;background-image:none;background-repeat:repeat;background-size:auto;color:#24b8cc;text-decoration:none;" href="https://devzone.nordicsemi.com/f/nordic-q-a/9612/reading-irk-and-gap_evt-params-connected-irk_match-issue"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/9612/reading-irk-and-gap_evt-params-connected-irk_match-issue&lt;/a&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&amp;hellip; I realized that I have to wait for&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;BLE_GAP_EVT_SEC_PARAMS_REQUEST&lt;/span&gt; and &lt;span style="background-color:#ffffff;"&gt;BLE_GAP_EVT_AUTH_STATUS in my&amp;nbsp;dm_ble_evt_handler() function in device_manager_peripheral_custom.c&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Now I know that the IRKs are in&amp;nbsp;&lt;strong&gt;&lt;span style="background-color:#ffffff;"&gt;m_peer_table[handle.device_id].peer_id.id_info.irk array&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;span style="background-color:#ffffff;"&gt;I have checked that auth_status is&amp;nbsp;BLE_GAP_SEC_STATUS_SUCCESS and addr_type really is&amp;nbsp;BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;span style="background-color:#ffffff;"&gt;Please notice that ...&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;span style="background-color:#ffffff;"&gt;p_ble_evt-&amp;gt;evt.gap_evt.params.connected.irk_match&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;span style="background-color:#ffffff;"&gt;and&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;span style="background-color:#ffffff;"&gt;p_ble_evt-&amp;gt;evt.gap_evt.params.connected.irk_match_idx&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;span style="background-color:#ffffff;"&gt;... may both be 0 ... if no whitelisting is used (which is my case).&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;margin:0px 0px 0.65em 0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;span style="background-color:#ffffff;"&gt;Thanks!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolving random private address ... where is the IRKs array?</title><link>https://devzone.nordicsemi.com/thread/188040?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 20:53:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5604be8-b512-463f-b0be-9df3337e1e0c</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;Hi Runar,&lt;/p&gt;
&lt;p&gt;I have decided to close this issue and open a new one about &amp;quot;not getting the expected resolved address&amp;quot;.&amp;nbsp; The initial intent of this post was to find the IRKs and that has been achieved.&amp;nbsp; Thanks!&lt;/p&gt;
&lt;p&gt;Gil&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolving random private address ... where is the IRKs array?</title><link>https://devzone.nordicsemi.com/thread/187593?ContentTypeID=1</link><pubDate>Thu, 16 May 2019 17:54:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3ee3449-f2dd-4416-b811-5eb28c93fa70</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;I guess it&amp;#39;s just ignoring the 3 bytes of the manufacturer&amp;#39;s ID? Is that right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolving random private address ... where is the IRKs array?</title><link>https://devzone.nordicsemi.com/thread/187590?ContentTypeID=1</link><pubDate>Thu, 16 May 2019 17:33:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06612b8e-475b-414f-a323-7c821fe9497d</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;Hi Runar,&lt;/p&gt;
&lt;p&gt;I looked at that function and it&amp;#39;s similar to the decypher_address that I use.&amp;nbsp; I also started with an example that compares the decrypted highest 3 bytes of the address with the lower 3 bytes.&amp;nbsp; I don&amp;#39;t understand that.&amp;nbsp; The result is not what I expected, i.e. a decrypted 6-byte address.&amp;nbsp; Why does it do that?&amp;nbsp; Why doesn&amp;#39;t it provide a full 6-byte decrypted address?&amp;nbsp; I&amp;#39;m confused. Thanks!&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Gil&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolving random private address ... where is the IRKs array?</title><link>https://devzone.nordicsemi.com/thread/187583?ContentTypeID=1</link><pubDate>Thu, 16 May 2019 16:28:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c054bae-942b-4eed-a9e1-e388e8a1bd22</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;Hi Runar&lt;/p&gt;
&lt;p style="color:#000000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;margin-top:0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;The Android tablet&amp;#39;s Bluetooth MAC address is 80 4E 70 0F 05 9C&lt;/p&gt;
&lt;p style="color:#000000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;The passed structure:&lt;/p&gt;
&lt;p style="color:#000000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;The received randomized address is (ten 00 then) 7E 82 66 88 8F D8&lt;/p&gt;
&lt;p style="color:#000000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;The received key is 25 29 EF 50 0B 2C 45 66 85 16 95 65 0C D3 AE 1C&lt;/p&gt;
&lt;p style="color:#000000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;The result is (ten &amp;quot;don&amp;#39;t care&amp;quot; then) 00 8B D1 34 EA BF .. which does not match the MAC &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#000000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;I will try the im_address_resolve() that you suggested and will let you know... Thanks!&lt;/p&gt;
&lt;p style="color:#000000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Cheers,&lt;/p&gt;
&lt;p style="color:#000000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Gil&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolving random private address ... where is the IRKs array?</title><link>https://devzone.nordicsemi.com/thread/187563?ContentTypeID=1</link><pubDate>Thu, 16 May 2019 14:04:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d1c37d7-bfc0-4391-a053-a912157df99c</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is a function called im_address_resolve in id_manager.c (belongs to the peer manager in sdk 11) that you might be able to check against to see if you get the correct address.&lt;/p&gt;
&lt;p&gt;You will only get an IRK match on the connected event if you are using the whitelist and the address matches the whitelist. So enabling the whitelist would also be a way to identify the peer.&lt;/p&gt;
&lt;p&gt;Which address are you checking against by the way? have you stored the identity address?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolving random private address ... where is the IRKs array?</title><link>https://devzone.nordicsemi.com/thread/187371?ContentTypeID=1</link><pubDate>Wed, 15 May 2019 22:08:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7de18119-e102-4dc1-ab68-2eab7704781b</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;Update:&lt;/p&gt;
&lt;p&gt;After reading this post ...&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/9612/reading-irk-and-gap_evt-params-connected-irk_match-issue"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/9612/reading-irk-and-gap_evt-params-connected-irk_match-issue&lt;/a&gt;&lt;/span&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;hellip; I realized that I have to wait for&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;BLE_GAP_EVT_SEC_PARAMS_REQUEST&lt;/span&gt; and &lt;span style="background-color:#ffffff;"&gt;BLE_GAP_EVT_AUTH_STATUS in my&amp;nbsp;dm_ble_evt_handler() function.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;So I moved my code there, and modified it:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
void decypher_address(uint8_t * p_random, uint8_t * p_real, uint8_t * p_irk_array)
{
  nrf_ecb_hal_data_t encryption_data = {0};
  uint32_t errcode;
  uint8_t i;

  /* Reverse the array as the ECB expect it in big endian format */
  for (i=0; i&amp;lt;sizeof(encryption_data.key); i++)
  {
    encryption_data.key[i] = p_irk_array[sizeof(encryption_data.key)-1-i];
    if (i &amp;lt; 6)
    {
      encryption_data.cleartext[15-i] = p_random[i];
    }
  }

  errcode = sd_ecb_block_encrypt(&amp;amp;encryption_data);
  if(errcode)
  {
    ASSERT(false);
  }
  
  for (i=0; i&amp;lt;6; i++)
  {
    p_real[i] = encryption_data.ciphertext[15-i];
  }
}

void dm_ble_evt_handler(ble_evt_t * p_ble_evt)
{

...

        case BLE_GAP_EVT_AUTH_STATUS:

...

      ble_gap_addr_t tmp_addr;
      uint8_t idx = p_ble_evt-&amp;gt;evt.gap_evt.params.connected.irk_match_idx;

//      if (p_ble_evt-&amp;gt;evt.gap_evt.params.connected.irk_match)
      {
          decypher_address((uint8_t *)m_connection_table[idx].peer_addr.addr,
                                     tmp_addr.addr, 
                                     m_peer_table[handle.device_id].peer_id.id_info.irk);

          g_ble_conn_stats.central_mac0  = tmp_addr.addr[5];
          g_ble_conn_stats.central_mac1  = tmp_addr.addr[4];
          g_ble_conn_stats.central_mac2  = tmp_addr.addr[3];
          g_ble_conn_stats.central_mac3  = tmp_addr.addr[2];
          g_ble_conn_stats.central_mac4  = tmp_addr.addr[1];
          g_ble_conn_stats.central_mac5  = tmp_addr.addr[0];
      }
/*
      else
      {
          g_ble_conn_stats.central_mac0  = 0;
          g_ble_conn_stats.central_mac1  = 0;
          g_ble_conn_stats.central_mac2  = 0;
          g_ble_conn_stats.central_mac3  = 0;
          g_ble_conn_stats.central_mac4  = 0;
          g_ble_conn_stats.central_mac5  = 0;
      }
*/

...

}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Now I know that the IRKs are in&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;m_peer_table[handle.device_id].peer_id.id_info.irk array&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;but the resolved MAC address does not match the Android tablet&amp;#39;s MAC address.&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;I have checked that auth_status is&amp;nbsp;BLE_GAP_SEC_STATUS_SUCCESS and addr_type really is&amp;nbsp;BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;Please notice that ...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;span style="background-color:#ffffff;"&gt;p_ble_evt-&amp;gt;evt.gap_evt.params.connected.irk_match&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;span style="background-color:#ffffff;"&gt;and&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;span style="background-color:#ffffff;"&gt;p_ble_evt-&amp;gt;evt.gap_evt.params.connected.irk_match_idx&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;span style="background-color:#ffffff;"&gt;... are both 0 ... I don&amp;#39;t know if that is a problem.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;span style="background-color:#ffffff;"&gt;Thanks!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>