<?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 do I encrypt a string?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78713/how-do-i-encrypt-a-string</link><description>Hello. We are developing using nrf52832 (S132 v7.0.1, SDK v17.0.0). 
 I&amp;#39;m looking at how to encrypt a string with AES CBC. Below is the code we are considering. 
 
 Currently, it works, but the strings are not encrypted and are all &amp;quot;0x00&amp;quot;. How can I solve</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 30 Aug 2021 10:27:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78713/how-do-i-encrypt-a-string" /><item><title>RE: How do I encrypt a string?</title><link>https://devzone.nordicsemi.com/thread/327164?ContentTypeID=1</link><pubDate>Mon, 30 Aug 2021 10:27:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e384f397-e685-4e5e-99f6-1de36c53866a</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hello again!&lt;br /&gt;&lt;br /&gt;Good to hear. You must pad any input data shorter than 16 bytes. I.e, add empty bytes at the end of the array.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I encrypt a string?</title><link>https://devzone.nordicsemi.com/thread/326875?ContentTypeID=1</link><pubDate>Fri, 27 Aug 2021 05:34:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66379a91-02e6-4af6-a358-a830bce2a140</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;I changed the backend from CC310 to mbed TLS and now I can encrypt and decrypt!&lt;br /&gt;Thank you!&lt;/p&gt;
&lt;p&gt;One question is that m_plain_text must be a multiple of 16 bytes. Is there a way to encrypt 15 byte characters?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I encrypt a string?</title><link>https://devzone.nordicsemi.com/thread/326114?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 07:49:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e8da802-0e20-4fde-b18b-8ba2f2f4e213</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hello!&lt;br /&gt;&lt;br /&gt;You must use a different backend, as the CryptoCell peripheral (CC310) isn&amp;#39;t available on the nRF52832.&amp;nbsp;Please check out the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_crypto_config.html"&gt;documentation for configuring nrf_crypto backends.&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I encrypt a string?</title><link>https://devzone.nordicsemi.com/thread/326075?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 04:36:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:146e6fea-ed0e-47b2-814b-a004d656709c</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;&lt;span&gt;Hello,&lt;/span&gt;&lt;span&gt;Carl Richard!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;When I checked the location of the PC, it was in SaSi_AesFinish on line 495 of cc310_backend_aes.c.&lt;/p&gt;
&lt;p&gt;Best regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I encrypt a string?</title><link>https://devzone.nordicsemi.com/thread/326008?ContentTypeID=1</link><pubDate>Fri, 20 Aug 2021 15:02:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ff3efe3-4f22-4928-add2-e5ecd43434b7</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hello again!&lt;br /&gt;&lt;br /&gt;This means that the program crashed somehow. Are you able to check where in the code Program Counter (PC) stopped?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I encrypt a string?</title><link>https://devzone.nordicsemi.com/thread/325826?ContentTypeID=1</link><pubDate>Fri, 20 Aug 2021 05:40:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a815a51-c60d-4d42-9d00-8b84f9416883</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello,&lt;span&gt;Carl Richard!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thank you for teaching.&lt;br /&gt;When I changed the character length of m_plain_text to 64, the 0x8511 error disappeared.&lt;/p&gt;
&lt;p&gt;However, HardFault_Handler started to occur.&lt;br /&gt;The condition that occurs is when you call nrf_crypto_aes_finalize.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The debugger shows &amp;quot;Exception occurred at PC = 0x39602, LR = 0x395d3&amp;quot;.&lt;/span&gt;&lt;br /&gt;How can I solve it?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best Regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I encrypt a string?</title><link>https://devzone.nordicsemi.com/thread/325763?ContentTypeID=1</link><pubDate>Thu, 19 Aug 2021 13:31:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:620f629b-e172-4150-a0ad-d68298ed37ea</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hello, sdi_kei!&lt;br /&gt;&lt;br /&gt;There seems to be an issue with the input length of your plain text string. With nrf_crypto_aes the input must be a multiple of 16 bytes, so you must pad the input data.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I encrypt a string?</title><link>https://devzone.nordicsemi.com/thread/325712?ContentTypeID=1</link><pubDate>Thu, 19 Aug 2021 11:45:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c57b62ec-a4c3-41ad-b000-2dbb463a098e</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;I got a 0x8511 error when calling nrf_crypto_aes_finalize. I don&amp;#39;t know which part is wrong. I would like you to tell me.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best Regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>