<?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_aes_crypto output buffer size</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72250/nrf_aes_crypto-output-buffer-size</link><description>I am using NRF52840 with SDK15 
 
 I am using AES 128 Encryption and am confused on the documentation: 
 
 During the encryption operation with nrf_crypto_aes_crypt or nrf_crypto_aes_finalize , if padding mode is selected, the size of p_data_out buffer</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 06 Aug 2021 08:25:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72250/nrf_aes_crypto-output-buffer-size" /><item><title>RE: nrf_aes_crypto output buffer size</title><link>https://devzone.nordicsemi.com/thread/323660?ContentTypeID=1</link><pubDate>Fri, 06 Aug 2021 08:25:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4ac516d-57d3-4bf9-810c-3db58d63ada7</guid><dc:creator>Kaja</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;has your problem been solved?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Kaja&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_aes_crypto output buffer size</title><link>https://devzone.nordicsemi.com/thread/299887?ContentTypeID=1</link><pubDate>Mon, 15 Mar 2021 15:43:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc209459-fb0a-44d2-86a2-2358703697d1</guid><dc:creator>Bloq</dc:creator><description>&lt;p&gt;Here is the AES Encryption Documentation.&amp;nbsp; Can you confirm that I am incorrect in my assumption below.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;ECB output:&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Encrypted or decrypted text.&lt;/li&gt;
&lt;li&gt;When padding mode is selected, the last encrypted block is always padded, even if plain text is a multiple of 16 bytes.&lt;/li&gt;
&lt;li&gt;Upon a finished decryption operation, when padding mode is selected, &lt;code&gt;p_data_out_size&lt;/code&gt; is decreased by the number of padded bytes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I am using padding so I interpreted this as:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;During encryption of a uint8_t value, I must size my output buffer to to the nearest multiple of 16 bytes of my input value.&amp;nbsp; aka 16 bytes.&lt;/p&gt;
&lt;p&gt;During decryption, I must size my output buffer to the nearest 16 bytes on top of my input buffer.&amp;nbsp; aka 32 bytes&lt;/p&gt;
&lt;p&gt;I seemed to have an instance of corruption if I did not do this.&amp;nbsp; Does the aes encryption library allocate its own space to handle the cipher block operations.&lt;/p&gt;
&lt;p&gt;If this is incorrect I would propose to change the wording of the documentation to be slightly more specific during decryption.&amp;nbsp; To something like:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;ECB output:&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Encrypted text
&lt;ul&gt;
&lt;li&gt;When padding mode is selected, the last encrypted block is always padded, even if plain text is a multiple of 16 bytes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Decrypted text
&lt;ul&gt;
&lt;li&gt;Buffer size must be size of the expected decrypted value.&lt;/li&gt;
&lt;li&gt;Upon a finished decryption operation, when padding mode is selected, &lt;code&gt;p_data_out_size&lt;/code&gt; is decreased by the number of padded bytes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_aes_crypto output buffer size</title><link>https://devzone.nordicsemi.com/thread/298586?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 08:42:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbc54bbd-36cb-4cf4-8b26-7e9bc53bd92a</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;For those and similar functions, the p_data_out buffer holds the outputted data from the function, and must be large enough to fit that output.&lt;/p&gt;
&lt;p&gt;When encrypting, it means big enough for holding the encrypted value.&lt;/p&gt;
&lt;p&gt;When decrypting, it means big enough for holding the decrypted value.&lt;/p&gt;
&lt;p&gt;For both, include padding if needed.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>