<?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_crypto asynchronous operations</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84400/nrf_crypto-asynchronous-operations</link><description>Hello ! 
 If I understand right and nrf_crypto is the main Crypto API in nRF SDK. They can be mapped to cc310 or to mbedtls sw routines. 
 
 Does exists nrf_crypto asynchronous APIs ? At list for some algos. When I can schedule AES CCM/CTR ( for example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 11 Feb 2022 10:58:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84400/nrf_crypto-asynchronous-operations" /><item><title>RE: nrf_crypto asynchronous operations</title><link>https://devzone.nordicsemi.com/thread/352560?ContentTypeID=1</link><pubDate>Fri, 11 Feb 2022 10:58:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a39bd0d9-8f57-4a04-928b-a2d93f53a494</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="Hiihtaja"]Do I understand right and highlighted lib is the one what I should use with noint and gcc ?[/quote]
&lt;p&gt;Yes, that&amp;#39;s correct.&lt;/p&gt;
[quote user="Hiihtaja"]But what is short-wchar versions are ?[/quote]
&lt;p&gt;Those are for IAR v7, see the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/index.html"&gt;SDK release notes&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;Libraries for IAR 8 require wchar_t to be of size 32 bits while IAR 7 requires 16 bits.
  
To run a project using IAR 8, follow these instructions:
 1. Open the IAR project in IAR 8. The IAR workbench will automatically generate an IAR 8 compatible project file.
 2. If the project contains one of the precompiled libraries listed below, replace it
    with the IAR 8 compatible alternative (there are no projects targeting nRF51 in this SDK).
 3. Save the project.
 4. When building the project, you might get the warning: &amp;quot;The header file &amp;#39;cmsis_iar.h&amp;#39; is obsolete and should not be used. [...]&amp;quot;.
    - The problem is described in DevZone post: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/31123/iar-ewarm-8-22-1-complains-about-cmsis_iar-h"&gt;devzone.nordicsemi.com/.../iar-ewarm-8-22-1-complains-about-cmsis_iar-h&lt;/a&gt;
      The solution is to remove all occurrences of #include &amp;lt;cmsis_iar.h&amp;gt;.
     
The affected libraries are:
 - micro-ecc crypto:
    - IAR7: Includes library located in the folder named “…_iar\…”.
    - IAR8: Switch to using the library from the folder named “…_armgcc\…”.
 - nrf_cc310, nrf_cc310_bl, and nrf_oberon:
    - IAR7: Link to a library where “short_wchar” is part of the folder name.
    - IAR8: Link to a library without “short_wchar” in the folder name.
 - Gazell, NFC Tag, and 802.15.4:
    - IAR7: Includes the library where the file name ends with “_iar”.
    - IAR8: Switch to using the library with similar file name that ends with “_gcc”.&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_crypto asynchronous operations</title><link>https://devzone.nordicsemi.com/thread/352437?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 17:47:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad67bfb9-674c-4ad3-af3b-3f4cd30e23dd</guid><dc:creator>Hiihtaja</dc:creator><description>&lt;p&gt;Hi !&lt;/p&gt;
&lt;p&gt;Yes one call at the time.&lt;/p&gt;
&lt;p&gt;Do I understand right and highlighted lib is the one what I should use with noint and gcc ?&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1644515161069v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;But what is short-wchar versions are ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Eugene&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_crypto asynchronous operations</title><link>https://devzone.nordicsemi.com/thread/352387?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 14:45:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5ae9e16-6665-491c-a91c-01af0af75baf</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I got confirmation that the nrf_cc310 runtime library does use interrupts, but not a lot. There is a no-interrupts version of the library in the SDK if you plan to use it&amp;nbsp;from interrupt context. Note that we highly recommend only calling the functions from one priority (preferably main/thread). There is only one core in the CC310 Cryptocell, calling the functions from multiple interrupt context will likely cause issues. In nrf_crypto, we have protected the CC310 with mutexes, along with other measures, to prevent issues like this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_crypto asynchronous operations</title><link>https://devzone.nordicsemi.com/thread/352323?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 12:41:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:891a7a2a-b566-455a-b974-d41996a81f2a</guid><dc:creator>Hiihtaja</dc:creator><description>&lt;p&gt;Hi !&lt;/p&gt;
&lt;p&gt;I have enable only cryptocell but not interrupts of it&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;//NVIC_EnableIRQ(CRYPTOCELL_IRQn);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;NRF_CRYPTOCELL&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;ENABLE&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;And at list&amp;nbsp; CRYS_CHACHA can be executed in SWI interrupt event_handler what I allocated via driver.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;nrfx_swi_alloc&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;swin&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;event_handler&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;APP_IRQ_PRIORITY_LOWEST&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I hope we are lucky and only tight loop inside library and we can execute short operations inside any ISR.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;But async APIs is more useful for sure.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Eugene&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_crypto asynchronous operations</title><link>https://devzone.nordicsemi.com/thread/351457?ContentTypeID=1</link><pubDate>Mon, 07 Feb 2022 07:48:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec93e1cc-3f2f-4230-9217-572ec04cd156</guid><dc:creator>Hiihtaja</dc:creator><description>&lt;p&gt;Hi !&lt;/p&gt;
&lt;p&gt;Basically CC310 library is wait real interrupt internally. As result&amp;nbsp; AES-128 ( I need ECB, CTR and CCM only ) operations can&amp;#39;t be executed in ISR context or thread mode when global and/or cc310 interrupts are disabled. Is this so ?&lt;/p&gt;
&lt;p&gt;May be exists some version of library or some other set of APIs where completion of operation is done as polling operation ?&lt;/p&gt;
&lt;p&gt;In this case encryption/decryption can be executed in any context.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Other alternative id find out how to use AES CCM/ECB co-processor. But it not supports CTR mode and also ECB encryption only.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also SW implementation of AES take 2-3 times longer than HW ones.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could it be possible to find information about CC310 what can help to implement AES APIs in asynchronous way or using wait loop instead of interrupts ?&lt;/p&gt;
&lt;p&gt;In test&amp;nbsp;/nRF5_SDK_17.1.0_ddde560/examples/crypto/nrf_cc310/aes/main.c&lt;/p&gt;
&lt;p&gt;I can disable interrupts during AES tests&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;__disable_irq&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;ret&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;aes_tests&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;__enable_irq&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;And they still passed.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Can be be there simple tight loop for wait complexion without real ISR ?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Please suggest.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Eugene&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_crypto asynchronous operations</title><link>https://devzone.nordicsemi.com/thread/351379?ContentTypeID=1</link><pubDate>Fri, 04 Feb 2022 15:50:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8bde493-02de-4274-bc30-8602881d6cd3</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;nrf_crypto does not provide asynchronous APIs. For all other backends than CC310 (mbedtls and nrf_oberon), the CPU is needed to do the cryptographic calculations, as they are SW backends. CC310 is only supported in nRF52840, so it would not make that much sense to add asynchronous APIs only for this. Also, there is currently no support for interrupt driven CC310 outside of the of the ARM runtime libraries, see &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/46695/nrf_cc310-and-arm-trustzone-cryptocell-in-interrupt-mode/184226#184226"&gt;this post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you want to do some work while the CC310 handles its calculations, you would need to do that in interrupt context. You can trigger interrupt using&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/swi.html?cp=4_0_0_5_26"&gt;SWI — Software interrupts&lt;/a&gt;. It may also be possible to get something done using threading in an RTOS like FreeRTOS or Zephyr/NCS.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>