<?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>nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64731/nrf52-data-encryption</link><description>Hello Nordic team 
 I am working on nRF52832 dev board and I have a requirements to encrypt and decrypt data using AES-128 ECB . Could you please provide the example code or documentation how to encrypt and decrypt the data? 
 Any help will be appreciated</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 07 Sep 2020 06:53:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64731/nrf52-data-encryption" /><item><title>RE: nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/thread/268188?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 06:53:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a642c3af-df39-4818-8644-66a98ed28438</guid><dc:creator>codebreaker176</dc:creator><description>&lt;p&gt;Thanks !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/thread/268186?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 06:51:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09ee1fed-24d3-4692-874a-4e06ae685f02</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I assume you are referring to the code in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/45470/encryption-and-decryption-of-advertising-data/181110#181110"&gt;this post&lt;/a&gt;? The reason is that the function only works on single blocks (which is 16 byte long), and he needs to decrypt two blocks. Therefor the function is called twice, with a 16 byte offset for the second call.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/thread/268120?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2020 17:39:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9f7c8ba-04dd-4ea1-b045-3ada4a0aa1dc</guid><dc:creator>codebreaker176</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;Can you tell why is ctr_decrypt() being called twice in the below code?&lt;/p&gt;
[quote userid="12833" url="~/f/nordic-q-a/64731/nrf52-data-encryption/266066"]ctr_decrypt(m_beacon_info);&lt;br /&gt; ctr_decrypt(&amp;amp;m_beacon_info[16]);[/quote]&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/thread/266147?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 09:02:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd9e8b10-1160-4d19-a9aa-bd2d1184528f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Based on the function names, I assume you are basing your code on &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/intro-to-application-level-security-using-the-ecb-"&gt;this tutorial&lt;/a&gt;. This function works on full blocks only, so you would have to pad and call multiple times to encrypt/decrypt more than 16 bytes. That is possible.&lt;/p&gt;
&lt;p&gt;Alternatively, you could use nrf_crypto to do the encryption/decryption as discussed before, which would give you are more complete API do the operations in one go, padding etc. as needed. This would not be in HW then, but that may not be a practical problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/thread/266066?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2020 18:57:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0581e052-98c4-44db-b3ff-59498c5b7bb3</guid><dc:creator>Rajneesh</dc:creator><description>&lt;p&gt;Thanks for the reply. This make sense to me. Can I use following APIs for encryption and decryption:&lt;/p&gt;
&lt;p&gt;nonce_generate(nonce);&lt;br /&gt; ctr_init(nonce,m_ecb_key);&lt;/p&gt;
&lt;p&gt;ctr_encrypt(m_beacon_info);&lt;br /&gt; ctr_encrypt(&amp;amp;m_beacon_info[16]);&lt;/p&gt;
&lt;p&gt;/******************************************/&lt;/p&gt;
&lt;p&gt;ctr_decrypt(m_beacon_info);&lt;br /&gt; ctr_decrypt(&amp;amp;m_beacon_info[16]);&lt;/p&gt;
&lt;p&gt;As this is working and I tested. But this is just encrypting 16 bytes and I have to encrypt 20 bytes of data. Can I pass 32 bytes of KEY and encrypt 20 bytes and ignore rest of the bytes?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/thread/265932?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2020 10:33:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d76aa5fe-116a-4bbc-8895-93675a5059f6</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Raj,&lt;/p&gt;
&lt;p&gt;There is no conflict between BLE and nrf_crypto. You can simply put your crypto code into the beacon and scanner example, and it should work. There is one tedious task that needs to be done, though, and that is to add all dependencies for nrf_crypto (include paths and .c files) and add needed sdk_config configuration macros. The easiest way to get this could be to use example projects that use pairing, as the peer manager has dependencies of nrf_crypto.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/thread/265850?ContentTypeID=1</link><pubDate>Sat, 22 Aug 2020 18:41:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f0fc2ab-3ad2-4814-b246-d7b8e31c5885</guid><dc:creator>Rajneesh</dc:creator><description>&lt;p&gt;Thanks Einar. I tried and tested aes_cbc_with_padding example and encryption and decryption both works well.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now, I have to use this encryption in ble_beacon example and decryption in decryption in central_scanner&amp;nbsp;example (any central example).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;can you please help me to figure out the way to use this&amp;nbsp;aes_cbc example with BLE project? Is there amy example available so that I can use it?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Raj&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/thread/264375?ContentTypeID=1</link><pubDate>Thu, 13 Aug 2020 07:55:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54df1f11-f9d7-4205-8130-cc3ca6f8b614</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The AES example doe snot demonstrate ECB, but the exact same approach can be used with other variants. I suggest you refer to &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/lib_crypto_aes.html"&gt;this part of the documentation&lt;/a&gt; for the details. Essentially you need to use &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__nrf__crypto__aes.html#gab6f46acd86a01f0458d9268920232d05"&gt;g_nrf_crypto_aes_ecb_128_info&lt;/a&gt;&amp;nbsp;to specify the algorithm. You can also refer to the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/lib_crypto_cli_example.html"&gt;CLI example&lt;/a&gt; which does use AES-ECB, but this is not as easy to understand as it is much bigger than the small AES examples.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/thread/264341?ContentTypeID=1</link><pubDate>Wed, 12 Aug 2020 22:04:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f77db8a-b368-49ea-9a01-fae7b86bea22</guid><dc:creator>Rajneesh</dc:creator><description>&lt;p&gt;Thanks Einar for response. The link you provided for AES example I didn&amp;#39;t find the AS-ECB example. Could you please provide the correct example for AES-ECG?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 data Encryption</title><link>https://devzone.nordicsemi.com/thread/264183?ContentTypeID=1</link><pubDate>Wed, 12 Aug 2020 08:37:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b150ab6-c521-4512-a398-914fa332be98</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hello Raj,&lt;/p&gt;
&lt;p&gt;You can use the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/lib_crypto.html"&gt;nrf_crypto&lt;/a&gt; library for this. The &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/nrf_crypto_aes_example.html"&gt;AES Example&lt;/a&gt;&amp;nbsp;demonstrates how it is used.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>