<?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>Related to BLE Advertising Encryption and Decryption</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38329/related-to-ble-advertising-encryption-and-decryption</link><description>Dear Nordic, 
 I am using nRF52840 chip for BLE Advertising I want to encrypt this Advertising 
 I Read a CCM-AES encryption in BLE is it right way to this 31 bytes advertising packet encrypting or any other method to encrypt and also i Want to decrypt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 11 Sep 2018 12:53:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38329/related-to-ble-advertising-encryption-and-decryption" /><item><title>RE: Related to BLE Advertising Encryption and Decryption</title><link>https://devzone.nordicsemi.com/thread/148205?ContentTypeID=1</link><pubDate>Tue, 11 Sep 2018 12:53:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41690925-6965-4f74-816a-2ee083ab2b0d</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Alan&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t think of any easier way to do this without compromising the security.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For a general introduction to AES encryption I find &lt;a href="https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation"&gt;this Wiki article&lt;/a&gt; to be very helpful, in particular the section called Counter (CTR) which is very similar to how encryption is done in BLE.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Basically you encrypt the nonce&amp;nbsp;and counter with your AES key, and XOR the result with your data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then all the receiver has to do is encrypt the same nonce and counter with the same AES key, and XOR the&amp;nbsp;incoming cipher-text to get back the original data (if you XOR something with the same number twice you get back the original result).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The critical aspect is how you distribute the nonce and AES key to the two devices.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In many connected systems the counter will be updated automatically in the transmitter and receiver end, but since you are using advertising you can not guarantee that the receiver will pick up all the packets.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For this reason you would probably have to include the counter in clear text in each advertising packet.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This might sound risky, but as long as the receiver never accepts two packets with the same counter value it is safe (a simple way to do this is to require the counter to increment for each new packet).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The difference between CCM and counter mode encryption (CTR) is that CCM adds an authentication stage to the encryption phase which ensures that the receiver can validate that incoming packets are from the intended&amp;nbsp;target. This allows you to detect if packets have been tampered with, or if someone is simply sending you random data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The result of the CCM stage is&amp;nbsp;a 4 byte MIC (message integrity check) which needs to be embedded to your payload to verify it&amp;#39;s authenticity.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In total then you will&amp;nbsp;need to factor in room in your payload for both the 4 byte MIC and the 4+ byte counter for each transmitted payload.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Related to BLE Advertising Encryption and Decryption</title><link>https://devzone.nordicsemi.com/thread/148121?ContentTypeID=1</link><pubDate>Tue, 11 Sep 2018 05:19:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e47dc1e-76be-4c19-9274-9c31791574a8</guid><dc:creator>Alan Ajit</dc:creator><description>&lt;p&gt;Thank you Torbjorn&lt;/p&gt;
&lt;p&gt;Actually&amp;nbsp;I have one reader and several advertiser&lt;/p&gt;
&lt;p&gt;I want to this one reader to decrypt packets that coming from several Advertiser&lt;/p&gt;
&lt;p&gt;I read some AES methode that describes its work with nonce,counters and result of past encrypt or decrypt etc...&lt;/p&gt;
&lt;p&gt;can you suggest a better way to solve this problem (using nRF52840)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Related to BLE Advertising Encryption and Decryption</title><link>https://devzone.nordicsemi.com/thread/148028?ContentTypeID=1</link><pubDate>Mon, 10 Sep 2018 12:57:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3be8857-3047-4e02-abe3-4e05775882f9</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Alan&lt;/p&gt;
&lt;p&gt;I assume you are using a BLE SoftDevice to set up the advertising?&lt;/p&gt;
&lt;p&gt;There are many ways to encrypt and advertise packet, but using CCM-AES is definitely an option. If you take a look at the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.1.0/lib_crypto.html?cp=4_0_0_3_11"&gt;nrf_crypto library&lt;/a&gt; in the nRF5 SDK, there are functions included for doing AES operations using a multitude of algorithms.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On the nRF52840 these algorithms will utilize the Cryptocell module, to accelerate the operations and reduce overall energy consumption.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The main challenge when using AES is how to safely exchange the encryption key. Ideally you want unique keys in every device, and have some way to configure the receiver with keys for the advertiser it is allowed to read (then you can map the key to the BLE address, in case you want to be able to receive packets from multiple advertisers).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You could also have a look at the &lt;a href="https://developers.google.com/beacons/eddystone-eid"&gt;Eddystone EID&lt;/a&gt; beacon standard, but this might be a bit overkill for your application.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>