<?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>Resolved &amp;quot;private resolvable address&amp;quot; does not match Android tablet (central) MAC address</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/47542/resolved-private-resolvable-address-does-not-match-android-tablet-central-mac-address</link><description>Hi all, 
 I use nRF52832-QFAA, S132 2.0.0, SDK 11.0.0, IAR 7.5 under 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</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 23 May 2019 16:13:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/47542/resolved-private-resolvable-address-does-not-match-android-tablet-central-mac-address" /><item><title>RE: Resolved "private resolvable address" does not match Android tablet (central) MAC address</title><link>https://devzone.nordicsemi.com/thread/188904?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 16:13:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4826ebc2-58b2-4794-aed0-26ade07c25c8</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;Cool.&amp;nbsp; Thanks!&amp;nbsp; I understand the whole process now.&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: Resolved "private resolvable address" does not match Android tablet (central) MAC address</title><link>https://devzone.nordicsemi.com/thread/188753?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 08:49:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f99bfd2b-ee38-4979-9c2d-923229a9f96f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Yes, the IRK is unique and won&amp;#39;t change. So the peripheral do an address resolve calculation for any peer that try to connect (when whitelist is enabled) to&amp;nbsp;identify if the peer should be allowed to connect or not. This is handled by the softdevice typically by supplying a list of IRK when advertisement is started from the application.&lt;/p&gt;
&lt;p&gt;The IRK is received during bonding phase.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolved "private resolvable address" does not match Android tablet (central) MAC address</title><link>https://devzone.nordicsemi.com/thread/188642?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 16:24:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fb6ed3c-798d-44c7-be72-662ae9eb052e</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;Thanks Kenneth.&amp;nbsp; It&amp;#39;s BLE. Ok, so the MAC address is not transferred, and I would have to possibly get it via a custom characteristic that I can set up. No problem.&lt;/p&gt;
&lt;p&gt;But that brings up one more question:&lt;/p&gt;
&lt;p&gt;Since the peer address changes every 15 minutes, what is unique about a peer that makes it possible to bond/pass whitelist at connection time?&amp;nbsp; Is it the IRK?&amp;nbsp; The peer has to have a unique number to be identified during that process, right?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolved "private resolvable address" does not match Android tablet (central) MAC address</title><link>https://devzone.nordicsemi.com/thread/188432?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 07:41:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c506327-de7f-42fe-8f4f-64b956679e93</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Not sure what the address you refer to is (maybe it&amp;#39;s Bluetooth&amp;nbsp;classic or other legacy reasons)&amp;nbsp;, but for BLE typically all android devices use private resolvable address (e.g. for privacy reason to ensure no one can track them in real life, the address change every &amp;lt;15 minutes). I assume you may create an app that expose or write the address you refer to in a custom characteristic, however such an address you refer to is not transferred/exposed in any way by itself no.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolved "private resolvable address" does not match Android tablet (central) MAC address</title><link>https://devzone.nordicsemi.com/thread/188356?ContentTypeID=1</link><pubDate>Tue, 21 May 2019 16:16:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ecc2ee7-1768-43c6-9885-0d8fd4985e70</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;p&gt;Thanks for the reply.&amp;nbsp; I previously had not quite understood the 24-bit/24-bit prand/hash, so thanks for the detailed explanation. I understand it now.&lt;/p&gt;
&lt;p&gt;But that only shows me that the peer/central generated a valid prand and hash, and sent me the correct IRK, which are not my real goals.&lt;/p&gt;
&lt;p&gt;My real goal is to verify if the peer/central is a device&lt;span style="background-color:#ffffff;color:#000000;float:none;font-family:arial,helvetica,sans-serif;font-size:inherit;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; with Bluetooth MAC address of 80 4E 70 0F 05 9C (which happens to be an Android tablet).&amp;nbsp; How can I do that?&amp;nbsp; How can I get that address?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;Is it&lt;span style="background-color:#ffffff;color:#000000;float:none;font-family:arial,helvetica,sans-serif;font-size:inherit;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; not possible to know the peer&amp;#39;s real address if the peer/central is using &amp;quot;random resolved private address&amp;quot;?&amp;nbsp; The actual address is not sent at all, not even in encrypted/hashed form?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;&lt;span style="background-color:#ffffff;color:#000000;float:none;font-family:arial,helvetica,sans-serif;font-size:inherit;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 still don&amp;#39;t understand that.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;color:#000000;float:none;font-family:arial,helvetica,sans-serif;font-size:inherit;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;Thanks.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;color:#000000;float:none;font-family:arial,helvetica,sans-serif;font-size:inherit;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;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolved "private resolvable address" does not match Android tablet (central) MAC address</title><link>https://devzone.nordicsemi.com/thread/188221?ContentTypeID=1</link><pubDate>Tue, 21 May 2019 11:39:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebf3b9ec-5b21-4bbc-9426-9c0566f0f3a8</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;So looking at the connection request packet:&lt;br /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-d854a3e13b644667928dda62bcde8397/pastedimage1558437969076v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;The Access Address is randomly generated on each connection. The&amp;nbsp;initiator (peer) and advertiser (own)&amp;nbsp;address can be read out on connected event (note that if the peer use random r&lt;span&gt;esolvable address it will change at least every 15 minutes)&lt;/span&gt;:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case BLE_GAP_EVT_CONNECTED:
{
ble_gap_addr_t peer_addr = p_ble_evt-&amp;gt;evt.gap_evt.params.connected.peer_addr;
ble_gap_addr_t own_addr = p_ble_evt-&amp;gt;evt.gap_evt.params.connected.own_addr;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If the peer use a random resolvable address it will be&amp;nbsp;generated to this&amp;nbsp;format according to the BLE core spec:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-d854a3e13b644667928dda62bcde8397/pastedimage1558438576950v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Then&amp;nbsp;to the resolve the address:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-d854a3e13b644667928dda62bcde8397/pastedimage1558438721201v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;So this explains why &amp;quot;&lt;span&gt;It successfully decrypts the higher 3 bytes of the address and compares it with the original lower 3 bytes.&lt;/span&gt;&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolved "private resolvable address" does not match Android tablet (central) MAC address</title><link>https://devzone.nordicsemi.com/thread/188044?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 21:11:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8534ca92-9e95-4689-ad02-e01633bc9e42</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;&lt;strong&gt;Th&lt;span style="background-color:#ffffff;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;is compares the decrypted higher 3 bytes with the original lower 3 bytes:&lt;/span&gt;&lt;/strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define IM_ADDR_CLEARTEXT_LENGTH    3
#define IM_ADDR_CIPHERTEXT_LENGTH   3
#define SOC_ECB_KEY_LENGTH          16

void ah(uint8_t const * p_k, uint8_t const * p_r, uint8_t * p_local_hash)
{
    ret_code_t err_code;
    nrf_ecb_hal_data_t ecb_hal_data;
    for (uint32_t i = 0; i &amp;lt; SOC_ECB_KEY_LENGTH; i++)
    {
        ecb_hal_data.key[i] = p_k[SOC_ECB_KEY_LENGTH - 1 - i];
    }
    memset(ecb_hal_data.cleartext, 0, SOC_ECB_KEY_LENGTH - IM_ADDR_CLEARTEXT_LENGTH);

    for (uint32_t i = 0; i &amp;lt; IM_ADDR_CLEARTEXT_LENGTH; i++)
    {
        ecb_hal_data.cleartext[SOC_ECB_KEY_LENGTH - 1 - i] = p_r[i];
    }

    err_code = sd_ecb_block_encrypt(&amp;amp;ecb_hal_data); // Can only return NRF_SUCCESS.
    UNUSED_VARIABLE(err_code);

    for (uint32_t i = 0; i &amp;lt; IM_ADDR_CIPHERTEXT_LENGTH; i++)
    {
        p_local_hash[i] = ecb_hal_data.ciphertext[SOC_ECB_KEY_LENGTH - 1 - i];
    }
}

bool im_address_resolve(ble_gap_addr_t const * p_addr, uint8_t * p_real, ble_gap_irk_t const * p_irk)
{
    if (p_addr-&amp;gt;addr_type != BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE)
    {
        return false;
    }
    uint8_t hash[IM_ADDR_CIPHERTEXT_LENGTH];
    uint8_t local_hash[IM_ADDR_CIPHERTEXT_LENGTH];
    uint8_t prand[IM_ADDR_CLEARTEXT_LENGTH];
    memcpy(hash, p_addr-&amp;gt;addr, IM_ADDR_CIPHERTEXT_LENGTH);
    memcpy(prand, &amp;amp;p_addr-&amp;gt;addr[IM_ADDR_CIPHERTEXT_LENGTH], IM_ADDR_CLEARTEXT_LENGTH);
    ah(p_irk-&amp;gt;irk, prand, local_hash);

    memcpy(&amp;amp;p_real[IM_ADDR_CIPHERTEXT_LENGTH], local_hash, IM_ADDR_CIPHERTEXT_LENGTH);
    
    return (memcmp(hash, local_hash, IM_ADDR_CIPHERTEXT_LENGTH) == 0);
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resolved "private resolvable address" does not match Android tablet (central) MAC address</title><link>https://devzone.nordicsemi.com/thread/188043?ContentTypeID=1</link><pubDate>Mon, 20 May 2019 21:08:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:431c5faa-9adb-41cd-8065-8efab4dc1798</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;This does the whole 6-byte decryption and returns the address at p_real:&lt;/p&gt;
&lt;p&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];
  }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>