<?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>How to use AES128 ECB for decryption</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3125/how-to-use-aes128-ecb-for-decryption</link><description>Hi, 
 I am using nRF51822, and try to use the ECB block AES128 to do some data decryption.
From the SDK I found 2 API functions: 
 
 
 uint32_t sd_ecb_block_encrypt ( nrf_ecb_hal_data_t * p_ecb_data )
Seems this one is only usable for encrypt, can</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 Jan 2020 22:03:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3125/how-to-use-aes128-ecb-for-decryption" /><item><title>RE: How to use AES128 ECB for decryption</title><link>https://devzone.nordicsemi.com/thread/230952?ContentTypeID=1</link><pubDate>Fri, 24 Jan 2020 22:03:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b815fef9-8ac7-4b2c-a95b-ad0a1b726996</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;You are right!&amp;nbsp; Sorry, I did this with an nRF51 in 2013 and had forgotten the details.&amp;nbsp; The discussion you posted here has the correct solution.&amp;nbsp; In the end you call the same function to encrypt/decrypt, but those extra steps are required.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use AES128 ECB for decryption</title><link>https://devzone.nordicsemi.com/thread/227160?ContentTypeID=1</link><pubDate>Wed, 01 Jan 2020 16:29:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01ce9b50-b287-4f6c-b8d7-a2549693a8c8</guid><dc:creator>WrightLin.Avnet</dc:creator><description>&lt;p&gt;Hi &lt;/p&gt;
&lt;p&gt;I think it is not quite right that you could get the decrypt message just by change the location of cleartext and ciphertext.&lt;/p&gt;
&lt;p&gt;It was discussed in this thread:&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/6308/how-to-decrypt-aes-ecb-nopadding-data#comment-40082"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/6308/how-to-decrypt-aes-ecb-nopadding-data#comment-40082&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;AES is symmetric (block) cipher which means that there is 1 shared key which is used for both encryption (ENC) and decryption (DEC).&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;But ENC and DEC functions are inverse and in general these are mathematical completely different when it comes to actual computation. So NO, you cannot use the same function for going there and back unless it implements both encrypt and decrypt mode (e.g. with some flag in the call).&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;And the proper way to do encrypt and decrypt is described detailly in here:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/intro-to-application-level-security-using-the-ecb-"&gt;https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/intro-to-application-level-security-using-the-ecb-&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Wright&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use AES128 ECB for decryption</title><link>https://devzone.nordicsemi.com/thread/187387?ContentTypeID=1</link><pubDate>Thu, 16 May 2019 01:56:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48ededf1-e498-4154-957c-491567c07a62</guid><dc:creator>Guilherme de Paula</dc:creator><description>&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 key in .key, and the input data in .cleartext, then call the function, then the output data will be in .ciphertext&amp;nbsp;&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;You call the same function &lt;span style="background-color:#ffffff;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:italic;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;sd_ecb_block_encrypt&lt;/span&gt; whether you want to encrypt or decrypt.&amp;nbsp; The operation is symmetrical.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use AES128 ECB for decryption</title><link>https://devzone.nordicsemi.com/thread/187386?ContentTypeID=1</link><pubDate>Thu, 16 May 2019 01:54:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:686daa50-8524-428b-b803-429e9dc6fbb2</guid><dc:creator>Guilherme de Paula</dc:creator><description>&lt;p&gt;You put your encryption/decryption key in .key, and the data to be encrypted/decrypted in .cleartext (think of it as &amp;quot;input&amp;quot;) ... then you call&amp;nbsp;&lt;span style="background-color:#ffffff;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:italic;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;sd_ecb_block_encrypt&lt;/span&gt; and it will have the result in .ciphertext (think of it as &amp;quot;output&amp;quot;).&lt;/p&gt;
&lt;p&gt;You do the same thing whether you want to encrypt or decrypt.&amp;nbsp; The operation is symetrical.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use AES128 ECB for decryption</title><link>https://devzone.nordicsemi.com/thread/11575?ContentTypeID=1</link><pubDate>Tue, 15 Jul 2014 13:32:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:545e2ab7-de56-4579-88c3-9ff245a33939</guid><dc:creator>JW de Wit</dc:creator><description>&lt;p&gt;I was looking for the same, seems like the hardware only has enryption and no decryption. In ble connections this is sufficient while the counter mode is used. In countermode messages are both enrcypted and decripted using AES (ECB)encryption of a counter value, so ECB decription not needed for bluetooth and it seems Nordic made the hardware to fit BLE security and just BLE security .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use AES128 ECB for decryption</title><link>https://devzone.nordicsemi.com/thread/11574?ContentTypeID=1</link><pubDate>Tue, 15 Jul 2014 09:53:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:775223fb-0901-4651-a023-d00f3c29d946</guid><dc:creator>Ivan G&amp;#243;mez</dc:creator><description>&lt;p&gt;I am only able to post once so... I edit this one.&lt;/p&gt;
&lt;p&gt;Now I get no errors and warnings building my code but once I try to use AES in order to upload the app code to the nRF51822 BLUETOOTH SMART BEACON KIT, it stop working... The code I used is the following:&lt;/p&gt;
&lt;p&gt;nrf_ecb_hal_data_t *aestructura;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;	*(*aestructura).key=0x12;
	*(*aestructura).cleartext=16;
//Aplicacion de AES
sd_ecb_block_encrypt(aestructura);
	encriptado=*(*aestructura).ciphertext;
	printf(&amp;quot;Encrypted TEXT: %d&amp;quot;,encriptado);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Iván&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I am trying to encypt some data too. I
think the first one is the right way
in order to encrypt because you have
the struct nrf_ecb_hal_data_t which
defines the 3 parameters needed for
the encryptation. Anyway I don&amp;#39;t know
what to put in those parameters:&lt;/p&gt;
&lt;p&gt;nrf_ecb_hal_data_t aestructura; 	
aestructura.key=12345678;
aestructura.cleartext=&amp;quot;what should I
put here&amp;quot;;
aestructura.ciphertext=&amp;quot;what should I
put here&amp;quot;;&lt;/p&gt;
&lt;p&gt;After that I suppose we only should
use the function:
sd_ecb_block_encrypt(aestructura));&lt;/p&gt;
&lt;p&gt;And it should give back the encrypted
data? Don&amp;#39;t know yet.&lt;/p&gt;
&lt;p&gt;I hope some of this can help you a
bit, I have many questions though.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Iván&lt;/p&gt;
&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>