<?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>AES Encryption with SD</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13429/aes-encryption-with-sd</link><description>Hi there, 
 I&amp;#39;m using the softdevice sd_ecb_block_encrypt to encrypt my 16byte block data as follows: 
 When my data buffer is filled, it called aes_encrypt(), 
 void aes_encrypt(void)
{
int error = 0;
uint8_t clear_text[16] = {Data[0], Data[1]</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Aug 2020 06:24:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13429/aes-encryption-with-sd" /><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/266619?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 06:24:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f0d5c1a-2fa2-4a62-814a-07a22e445053</guid><dc:creator>codebreaker176</dc:creator><description>&lt;p&gt;Alright thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/266512?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 13:11:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1ceb584-17b7-437b-b828-9d4cd2377039</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;I think that&amp;#39;s already described in the code example in this thread. Just need to replace p_data with whatever date you want to encrypt. once that is done you add the encrypted data to manufacturer specific data in the advertisement packet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/266034?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2020 14:39:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef04f1db-0238-4e8d-abd5-f3f102f8e602</guid><dc:creator>codebreaker176</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you give an example how to use the security key in the code?&lt;/p&gt;
&lt;p&gt;Like how and where is the security key supposed to be used.&lt;/p&gt;
&lt;p&gt;And how to automatically generate a security key?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/265469?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2020 08:03:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bd2220f-9b38-4121-983e-56d4e2bb6945</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can use the same procedure as described earlier to encrypt the data before placing it in the advertisement data as manufacturer specific data. However you also need a good (secure) way to exchange the secure key, if that is in place and you use counter mode it should be quite secure.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/265461?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2020 07:24:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ea78e7c-0d81-40c3-8a9b-70a8e58479a4</guid><dc:creator>codebreaker176</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did you get what to do for this&amp;nbsp;&lt;/p&gt;
[quote userid="76983" url="~/f/nordic-q-a/13429/aes-encryption-with-sd/180655"]i need encrypt the advertising data like uuid,major&amp;amp;minor of my beacon so that it cannot be visible to other app or nrf connect it should be visible only to self designed app[/quote]
&lt;p&gt;If so can you please share&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/180655?ContentTypeID=1</link><pubDate>Mon, 08 Apr 2019 08:08:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9e28aa3-6c88-450c-91e6-21a46226f714</guid><dc:creator>Naralasetty Praneeth</dc:creator><description>&lt;p&gt;hi @&lt;a href="https://devzone.nordicsemi.com/members/run_5f00_ar"&gt;run_ar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;i need encrypt the advertising data like uuid,major&amp;amp;minor of my beacon so that it cannot be visible to other app or nrf connect it should be visible only to self designed app&lt;/p&gt;
&lt;p&gt;for this which code i should use&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/51262?ContentTypeID=1</link><pubDate>Wed, 01 Feb 2017 13:04:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd9d6c48-0ddd-4798-9ff9-d692888757bf</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Compared to the &amp;quot;block cipher mode of operation&amp;quot; article on wikipedia: p_data is the actuall data you want to encrypt (plaintext). aes_struct.ciphertext is the same as the &amp;quot;block chiper encryption&amp;quot; block output. So when aes_struct.ciphertext is xor&amp;#39;ed with p_data you get what is named ciphertext in the counter mode overview in the wikipedia article (encrypted data ready to send). Obviously it&amp;#39;s a bit confusion since there are two chipertexts... But the AES block supports encryption, not decryption which is why it&amp;#39;s done like this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/51261?ContentTypeID=1</link><pubDate>Mon, 30 Jan 2017 08:12:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:185f9aec-4bca-470d-b1af-a2101818cbac</guid><dc:creator>cherrycherry1</dc:creator><description>&lt;p&gt;Hi! Thanks for this example of AES XOR, but I was wondering if  you could help me out a bit. I&amp;#39;m not a crypto pro but I got the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You init all variables and memset them to 0&lt;/li&gt;
&lt;li&gt;you make a key, which is now just simply 0x00010203040506070809....&lt;/li&gt;
&lt;li&gt;you set the whole plain text (clear text/text you want to encrypt) to 0xaa......&lt;/li&gt;
&lt;li&gt;Enctypt it all&lt;/li&gt;
&lt;li&gt;XOR p_data with the ciphertext. (1)&lt;/li&gt;
&lt;li&gt;to decode to XOR the received enctypted aes_data with a ciphertext (2)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What I dont get is for point (1) What is p_data and what is where does the ciphertext come from? Is p data the raw data (so p_data = cleartext). Wikipedia stated that &amp;quot; he key size used for an AES cipher specifies the number of repetitions of transformation rounds that convert the input, called the plaintext, into the final output, called the ciphertext.&amp;quot;
If so, then (2) states that the ciphertext is known on the dec side&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/51264?ContentTypeID=1</link><pubDate>Thu, 08 Dec 2016 14:23:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32cfe4e7-8e78-4c8a-b370-40f11e2a2ef7</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;It&amp;#39;s been a while, but it probably means &amp;quot;pointer to data, refering to the data you wish to encrypt&amp;quot; or something like that...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/51263?ContentTypeID=1</link><pubDate>Thu, 08 Dec 2016 13:25:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0bd075e-6fd4-4df4-82b5-a00f72eacd43</guid><dc:creator>gjk</dc:creator><description>&lt;p&gt;p_data ???&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/51260?ContentTypeID=1</link><pubDate>Tue, 10 May 2016 09:07:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc27ec91-28bb-41d6-a210-2df9447efd89</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;The AES block is used to create a chippertext, this can be used to encrypt/decrypt data as shown below:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_ecb_hal_data_t aes_struct;

uint8_t aes_data[16];

uint8_t aes_data_decrypted[16];



//Initializing arrays

memset (&amp;amp;aes_struct, 0, sizeof(aes_struct));

memset (aes_data, 0, sizeof(aes_data));

memset (aes_data_decrypted, 0, sizeof(aes_data_decrypted));



//Initializing key

for (int i = 0; i &amp;lt; 16; i++)

{

    aes_struct.key [i] = i;

}



//Initializing nouncence

memset (aes_struct.cleartext, 0xaa, sizeof(aes_struct.cleartext)); //todo: use more random data and add counter



//Creating chipertext

sd_ecb_block_encrypt(&amp;amp;aes_struct);  



//Encrypt -&amp;gt; XOR chipertext with p_data:

for (int i = 0; i &amp;lt; length; i++)

{  

    aes_data[i] = p_data [i] ^ aes_struct.ciphertext[i];

}



//decrypt -&amp;gt; XOR chipertext with Encrypted data:

for (int i = 0; i &amp;lt; length; i++)

{  

    aes_data_decrypted[i] = aes_data [i] ^ aes_struct.ciphertext[i];

}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/51257?ContentTypeID=1</link><pubDate>Wed, 04 May 2016 18:10:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b3e8c30-c9d8-4113-8e5f-70d55f9a8955</guid><dc:creator>leehong</dc:creator><description>&lt;p&gt;Yes, new data comes in every 10s. I&amp;#39;m using the S110 sd.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/51258?ContentTypeID=1</link><pubDate>Wed, 04 May 2016 12:36:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7e1f8ac-63e1-4423-bf44-99a23831b55a</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;I haven&amp;#39;t seen this before. Can you confirm that the data coming in from the other chip is actually changing? And which Softdevice version are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/51256?ContentTypeID=1</link><pubDate>Wed, 27 Apr 2016 18:58:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96ea5480-9a02-46f4-8944-242a909a1a4b</guid><dc:creator>leehong</dc:creator><description>&lt;p&gt;The value doesn&amp;#39;t change. data in (clear_text) is data coming in from another chip at 10sec intervals. It seems the softdevice is too busy to process encryption?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AES Encryption with SD</title><link>https://devzone.nordicsemi.com/thread/51259?ContentTypeID=1</link><pubDate>Wed, 27 Apr 2016 11:42:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:273e775a-0966-4bd2-b90c-ed85d5132322</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;What do you mean when you say that you are not getting any new values from cipher text? Do you mean you are not getting a value at all or that the value don&amp;#39;t change? What data are you putting in, static or do you have a counter (ref &lt;a href="https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation"&gt;counter mode&lt;/a&gt;)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>