<?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 decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6308/how-to-decrypt-aes-ecb-nopadding-data</link><description>Hi Team, 
 Can anyone help me on this? 
 How to decrypt AES-ECB-Nopadding Encrypted frame? 
 I am not getting desired output. In fact, I am not getting how to proceed in this case.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 03 Jun 2015 20:16:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6308/how-to-decrypt-aes-ecb-nopadding-data" /><item><title>RE: how to decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/thread/22018?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 20:16:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f09772e-4ca2-4ade-bd8d-0034d6d865dd</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi Dave, hitting limit for simple comment so I&amp;#39;m amending my answer above. Please read it. Cheers Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/thread/22017?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 18:16:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20e8db53-0f39-41ef-b60b-65cbe50f214b</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;So if I call nrf_ecb_crypt ( uint8_t * dst, const uint8_t * src )  with cleantext  it will encrypt.&lt;/p&gt;
&lt;p&gt;If I call this function again with the same Key and using the encrypted data, it should return the original cleantext data no?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/thread/22016?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 07:49:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6af42d15-4161-43fa-a244-92f6a9e30bca</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi both, I&amp;#39;ve thought it&amp;#39;s crystal clear in provided link but in case it&amp;#39;s not: NO, there is no AES decryption function in Nordic SDK (because there is no HW acceleration for it on nRF51 chip). The SDK documentation is confusing when mentioning word &amp;quot;decrypt&amp;quot; but if you go deeper you see that there is actually no way how call this decrypt functionality.&lt;/p&gt;
&lt;p&gt;Cheers Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/thread/22015?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2015 00:55:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd720a56-e4c4-481b-b1e9-30501c628f59</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;I second this question&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/thread/22011?ContentTypeID=1</link><pubDate>Thu, 16 Apr 2015 09:08:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:540bd7b4-eb03-4379-b5b2-cf42a1f3bc59</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Oh, it was definitely not clear that you are asking about decryption of packets captured by Nordic BLE Sniffer in Wireshark. Just quickly looking into &amp;quot;nRF_Sniffer_User_Guide_v1.1.pdf&amp;quot; and there is pretty clear how you should proceed in all 3 cases (&amp;quot;Just Works&amp;quot;, &amp;quot;Passkey&amp;quot; or &amp;quot;OOB&amp;quot; mode). Am I missing something? Or are you using some applicative AES encryption and you wish to have it decrypted on the fly in Wireshark?&lt;/p&gt;
&lt;p&gt;Cheers Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/thread/22019?ContentTypeID=1</link><pubDate>Thu, 16 Apr 2015 04:45:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5aa340ce-b7bb-4052-8f7d-23ec3bd3438f</guid><dc:creator>Milan</dc:creator><description>&lt;p&gt;I have captured data in wireshark. Data are encrypted using AES/ECB/NO-PADDING.
I know the key then how to decrypt them?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/thread/22012?ContentTypeID=1</link><pubDate>Tue, 31 Mar 2015 13:16:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66002c0f-9f01-4a51-9681-4c9d1d9f86c6</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Original post is not very clear from my point of view so let&amp;#39;s summarize it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&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;/li&gt;
&lt;li&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;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If I understand it correctly nRF51 HW and SD API supports encryption only. However (and this is I guess hinted in the quoted thread, but I do see it neither properly implemented nor explained) there are &amp;quot;modern&amp;quot; methods how to bypass such limitation and use another stream function which is basic XOR to make it working both ways. One example of this concept is called AES Counter (CTR) mode where you use AES encryption only to generate intermediate &amp;quot;stream&amp;quot; which is then applied with XOR (stream cipher) on clear data. And because inverse function to XOR is again XOR on the other side you do exactly the same on top of cipher text to get clear data.&lt;/p&gt;
&lt;p&gt;Please note that while this is elegant it does not necessary mean that it is immediately secure and that you cannot screw it up during implementation (e.g. if you do not apply also integrity check by independent key/method, if you cannot guarantee unique usage off each counter with given key etc.). For details see e.g. &lt;a href="http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Counter_.28CTR.29"&gt;en.wikipedia.org/.../Block_cipher_mode_of_operation&lt;/a&gt; or other specialized crypto articles.&lt;/p&gt;
&lt;p&gt;Cheers Jan&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 03-06-2015&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Reaction to repeated &lt;a href="https://devzone.nordicsemi.com/question/33513/how-to-decrypt-aes-ecb-nopadding-data/?comment=40082#comment-40082"&gt;question&lt;/a&gt; down this thread:&lt;/p&gt;
&lt;p&gt;Hi Dave, you are actually incorrect in the same way Milan was. See another post with very same question and another variant of &amp;quot;NO&amp;quot; answer here: &lt;a href="https://devzone.nordicsemi.com/question/36546/nrf_ecb_crypt/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt; .&lt;/p&gt;
&lt;p&gt;To make the allegory even simpler let&amp;#39;s imagine AES encryption as basic addition (&amp;quot;+&amp;quot;) mathematical function and decryption as subtraction (&amp;quot;-&amp;quot;):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If your plane text is 3 and key is 2 then 3 + 2 = 5 (this is cipher text) and on the other side you need to use inverse function with the same key so 5 - 2 = 3 (which is correctly decrypted clear text).&lt;/li&gt;
&lt;li&gt;Here on nRF51 chip you have only one of these functions (encryption) and trying to reverse the inputs will not help you (putting cipher text 5 to the encryption function will make 5 + 2 = 7 which is definitely not your clear text 3).&lt;/li&gt;
&lt;li&gt;Yes, documentation to the API might be misleading on the first look but after digesting this there is pretty much no way how to help you.&lt;/li&gt;
&lt;li&gt;And yes, there exists &amp;quot;cryptographic&amp;quot; functions where encryption and decryption are mathematically identical functions (e.g. XOR) but that&amp;#39;s very rare and definitely not the case of AES.&lt;/li&gt;
&lt;li&gt;Of course you can implement proper AES DEC function (there are plenty of open source examples - starting with reference code in the spec up to some optimized versions in ASM). However you will probably experience much slower processing then ENC which is in HW.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cheers Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/thread/22014?ContentTypeID=1</link><pubDate>Tue, 31 Mar 2015 12:38:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79404fc3-0f4c-4e37-bb5a-d9acc7ee81e5</guid><dc:creator>Milan</dc:creator><description>&lt;p&gt;I read following in the documentation:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;bool nrf_ecb_crypt 	( 	uint8_t *  	dst,
const uint8_t *  	src
)&lt;/strong&gt; 		&lt;/p&gt;
&lt;p&gt;Encrypt/decrypt 16-byte data using current key.&lt;/p&gt;
&lt;p&gt;The function avoids unnecessary copying of data if the point to the correct locations in the ECB data structure.&lt;/p&gt;
&lt;p&gt;Parameters
dst	Result of encryption/decryption. 16 bytes will be written.
src	Source with 16-byte data to be encrypted/decrypted.&lt;/p&gt;
&lt;p&gt;Return values
true	If the encryption operation completed.
false	If the encryption operation did not complete.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;if I set key using &amp;quot; nrf_ecb_set_key&amp;quot; function, provide AES ECB encrypted data in &amp;quot;src&amp;quot;, will
&amp;quot;nrf_ecb_crypt&amp;quot; function decrypt it in &amp;quot;dst&amp;quot;?&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/thread/22013?ContentTypeID=1</link><pubDate>Tue, 31 Mar 2015 07:41:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2a79cea-4d1e-4df6-956a-934ebfc72739</guid><dc:creator>Alex</dc:creator><description>&lt;p&gt;This should help you
&lt;a href="https://devzone.nordicsemi.com/question/31119/nrf51822-aes-hw-module-clarification/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to decrypt AES-ECB-Nopadding data?</title><link>https://devzone.nordicsemi.com/thread/22010?ContentTypeID=1</link><pubDate>Tue, 31 Mar 2015 07:35:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:547399dc-f2c4-48b7-87c0-8ba883764807</guid><dc:creator>Bouke</dc:creator><description>&lt;p&gt;Can you link to the question that you don&amp;#39;t understand? What did you try yourself? Where do you get stuck?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>