<?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>nrf_ecb_crypt() transmits waste chars</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29552/nrf_ecb_crypt-transmits-waste-chars</link><description>Hi, 
 I&amp;#39;m trying using AES ECB encryption of peripheral drivers on development board with nRF52832 and PCA10040. 
 I inserted the following code before main loop of ble_app_uart sample in nRF5 SDK version 12.2. 
 #define SRC ((uint8_t *)&amp;quot;sample 16B</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Jan 2018 09:02:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29552/nrf_ecb_crypt-transmits-waste-chars" /><item><title>RE: nrf_ecb_crypt() transmits waste chars</title><link>https://devzone.nordicsemi.com/thread/117484?ContentTypeID=1</link><pubDate>Tue, 23 Jan 2018 09:02:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e34ca48-7ec6-47e1-90cf-34ee1c72f587</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Great! Happy to help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_ecb_crypt() transmits waste chars</title><link>https://devzone.nordicsemi.com/thread/117483?ContentTypeID=1</link><pubDate>Tue, 23 Jan 2018 01:38:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48081f4a-cbd4-44c5-a158-a9bbaf8c962a</guid><dc:creator>Hase</dc:creator><description>&lt;p&gt;sd_ecb_block_encrypt() seems to work expectedly.
Thanks a lot!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_ecb_crypt() transmits waste chars</title><link>https://devzone.nordicsemi.com/thread/117482?ContentTypeID=1</link><pubDate>Fri, 19 Jan 2018 07:38:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb69b339-972d-4048-ba9a-fa26d1a38186</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Are you using a Softdevice while your are doing this? If you are using a Softdevice the ECB is a &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/sd_resource_reqs/hw_block_interrupt_vector.html?cp=2_3_1_0_6_0"&gt;restricted resource&lt;/a&gt;, and hence should use a &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html?cp=2_3_1_1_0_2_7_2_4#ga79280d697e7ba03810c6473b0c7dab87"&gt;sd_ecb_xx&lt;/a&gt; API calls if you want to use it. It is a bit strange though, that you would only get garbage data and not more serious problems if this was the cause.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_ecb_crypt() transmits waste chars</title><link>https://devzone.nordicsemi.com/thread/117481?ContentTypeID=1</link><pubDate>Fri, 19 Jan 2018 00:16:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7ff9fa5-289d-4baf-a35e-38539e8b1fd9</guid><dc:creator>Hase</dc:creator><description>&lt;p&gt;Thank you for your reply.
But replacing it with the following results the same.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    uint8_t crypt[17];
    crypt[16] = 0;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And I never transmit the result in crypt explicitly.&lt;/p&gt;
&lt;p&gt;I wonder why characters is transmitted.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_ecb_crypt() transmits waste chars</title><link>https://devzone.nordicsemi.com/thread/117480?ContentTypeID=1</link><pubDate>Thu, 18 Jan 2018 09:23:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:264b8f76-18bb-48ef-bce7-2bf70d231ede</guid><dc:creator>Andre</dc:creator><description>&lt;p&gt;The text you have in your string is 16 bytes long. This means the null terminator is the 17th byte. Thus this 17th byte is not in the encrypted string. If you decrypt it, you need to be aware the result is not null-terminated. So, you must only print 16 characters.
If you would like to just use a printf, you should have the string 15 characters, such that the 16th byte is the null terminator.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>