<?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>Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84262/encrypting-decrypting-packets-on-the-fly</link><description>Hello ! 
 1. Do you have examples for nRF52840 what is demonstrate encryption/decryption packets on the fly as it explained in PS chapter 6.4 ? 
 2. What about examples for usage of CryptoCell 310 in similar way ? I mean transparently wit some shortcuts</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 11 Feb 2022 13:34:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84262/encrypting-decrypting-packets-on-the-fly" /><item><title>RE: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/352641?ContentTypeID=1</link><pubDate>Fri, 11 Feb 2022 13:34:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f7c2def-ad4d-44ef-9680-8bbc00a31d37</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The CCM peripheral is designed specifically for use with BLE, and only supports data rates relevant for that. So for the nRF52840 you have 1Mbps, 2Mbps, 125 kbps and 500 kbps. No other data rates are possible (so no 250 kbps for 802.15.4).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/352507?ContentTypeID=1</link><pubDate>Fri, 11 Feb 2022 09:12:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a5c629b-d900-4c10-bc29-9bd29e417860</guid><dc:creator>Hiihtaja</dc:creator><description>&lt;p&gt;Hi Einar !&lt;/p&gt;
&lt;p&gt;What about MODE.DATARATE register values. Are all of them are specified ?&lt;/p&gt;
&lt;p&gt;Co-processor should perform AES-CCM faster than radio and may be this asynchronous value is not specified.&lt;/p&gt;
&lt;p&gt;Looks like co-processor can be used synchronously with Nordic&amp;#39;s proprietary and Bluetooth&amp;reg; low energy modes only.&lt;/p&gt;
&lt;p&gt;But no any way to attach it to&amp;nbsp;IEEE 802.15.4 radio, at list in some partial way to use it on fly ?&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;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/352493?ContentTypeID=1</link><pubDate>Fri, 11 Feb 2022 08:29:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3a68b73-ee8c-4a86-bf09-6759c35172b2</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Eugene,&lt;/p&gt;
[quote user="Hiihtaja"]It is not so clear if after decryption on fly, if original encrypted frame is also stored in scratchpad or any other memory area. [/quote]
&lt;p&gt;It is available in the OUTPTR location, but no where else. The CCM peripheral does not use RAM for context memory or similar, so there is no other parts of the RAM that holds any data.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="Hiihtaja"]What about encryption on fly ? Does encrypted packet stored in some place after it transferred to air ?[/quote]
&lt;p&gt;It is also stored in the&amp;nbsp;memory&amp;nbsp;pointed to by OUTPTR.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/352482?ContentTypeID=1</link><pubDate>Fri, 11 Feb 2022 07:48:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e29978c-94ba-4712-92fe-0a51523c2cf1</guid><dc:creator>Hiihtaja</dc:creator><description>&lt;p&gt;Hi Einar !&lt;/p&gt;
&lt;p&gt;It is not so clear if after decryption on fly, if original encrypted frame is also stored in scratchpad or any other memory area. Does it available at some location ? It can be used for debug purposed and may be need to be wiped for minimize risks.&lt;/p&gt;
&lt;p&gt;What about encryption on fly ? Does encrypted packet stored in some place after it transferred to air ?&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: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/352345?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 13:31:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6255da9-78c2-4172-bd31-f2b91ec9d9e4</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Eugene,&lt;/p&gt;
&lt;p&gt;The direction bit comes from the Bluetooth specification (which the CCM peripheral is specially designed for):&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;The directionBit shall be set to 1 for Data Channel PDUs sent by the master and set to 0 for Data Channel PDUs sent by the slave.&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/352324?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 12:48:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bfb1780-4c69-46f6-86d0-eed3d3278b93</guid><dc:creator>Hiihtaja</dc:creator><description>&lt;p&gt;Hi Einar !&lt;/p&gt;
&lt;p&gt;Thank you !&lt;/p&gt;
&lt;p&gt;I close and close to start coding this topic.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But about what direction this bit &amp;quot;&lt;span&gt;Bit 0: Direction bit&amp;quot; in CCM structure are responsible ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I can see encrypt/decrypt are specified in own register or it should be set here as well or this is some other meaning ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Eugene&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/352321?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 12:36:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:296fd4b0-30b4-4122-820a-c69c60856b99</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Eugene,&lt;/p&gt;
&lt;p&gt;The length is not encrypted (I included that conceptually as part of he header, so I was not&amp;nbsp;clear&amp;nbsp;enough). You will see this clearly from figure 2, though:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/crypt.png" /&gt;&lt;/p&gt;
&lt;p&gt;You can see how the RADIO must be configured in the CCM documentation under the section&amp;nbsp;&lt;em&gt;AES CCM and RADIO concurrent operation&lt;/em&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/352316?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 12:30:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d7bc5c8-5223-4ebd-898b-c01338a2fdd4</guid><dc:creator>Hiihtaja</dc:creator><description>&lt;p&gt;Hi Einar !&lt;/p&gt;
&lt;p&gt;If I see packet structure in PS&amp;nbsp;6.20.1 Packet configuration&lt;/p&gt;
&lt;p&gt;LENGTH is located after S0 and going to be encrypted as well.&lt;/p&gt;
&lt;p&gt;How other side is able to know what amount of bytes need to be received if byte is encrypted ?&lt;/p&gt;
&lt;p&gt;Or it somehow decrypt first block and immediately know what is amount of bytes are expected ?&lt;/p&gt;
&lt;p&gt;In our case&amp;nbsp;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_LFLEN_BITS&lt;/span&gt;&lt;span&gt;&amp;nbsp;(&lt;/span&gt;&lt;span&gt;8&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_S0LEN&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_S1LEN_BITS&lt;/span&gt;&lt;span&gt;&amp;nbsp;(0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_CILEN_BITS&lt;/span&gt;&lt;span&gt;&amp;nbsp; (&lt;/span&gt;&lt;span&gt;2&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;#define NRF_STATLEN&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(0)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;as result length of the packet in the position where the LENGTH field in the packet.&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;span&gt;In case if TX operation, MAXLEN can be set to 250 and LENGTH is set to exact value what need to be send.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;In case of RX, MAXLEN is set to 64 or to 250 for limit MAX size of received packet.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;So I can change MAXLEN and LENGTH only if I would like to limit RX/TX transfers.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Is this radio configuration is fully compatible with on-fly encryption ( MIC space available for sure )&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;?&lt;/p&gt;
&lt;p&gt;Or using on fly encryption nees some specific radio configuration ?&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: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/352233?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 08:29:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c64bce8-6263-4c86-800b-d323b91a4949</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Eugene,&lt;/p&gt;
[quote user="Hiihtaja"]&lt;p&gt;Do I understand right and AES-128-CCM scheme is only add 4 byte MAC (MIC) at the end of packet ?&lt;/p&gt;
&lt;p&gt;It is no any other overhead and to user available 255-4=251 byte payload.&lt;/p&gt;[/quote]
&lt;p&gt;The 4 byte MIC follows immediately after, there is no other overhead.&lt;/p&gt;
[quote user="Hiihtaja"]Can packet contains some non-encrypted header or tail ? Or entire packet are encrypted ?[/quote]
&lt;p&gt;The entire packet except the header is encrypted. See &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/ccm.html?cp=4_0_0_5_3_1#unique_763300313"&gt;Figure 2 in the CCM chapter&lt;/a&gt;.&lt;/p&gt;
[quote user="Hiihtaja"]Bit 0: Direction bit Bit 7 – Bit 1: Zero padded[/quote]
&lt;p&gt;This s byte 24 in the CCM data structure. The point here is that Bit 0 can be 1 or 0&amp;nbsp;depending&amp;nbsp;on direction, and the other 7 bits shall always be 0.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/352182?ContentTypeID=1</link><pubDate>Wed, 09 Feb 2022 19:13:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37d5763b-a615-474f-90de-52641307e877</guid><dc:creator>Hiihtaja</dc:creator><description>&lt;p&gt;Hi Einar !&lt;/p&gt;
&lt;p&gt;Do I understand right and AES-128-CCM scheme is only add 4 byte MAC (MIC) at the end of packet ?&lt;/p&gt;
&lt;p&gt;It is no any other overhead and to user available 255-4=251 byte payload.&lt;/p&gt;
&lt;p&gt;Can packet contains some non-encrypted header or tail ? Or entire packet are encrypted ?&lt;/p&gt;
&lt;p&gt;Key and other IV information should be specified in&amp;nbsp;6.4.7 CCM data structure and must be equal on RX and TX side ( in some instant moment , one time e.g nonce) ?&lt;/p&gt;
&lt;p&gt;But what means &amp;quot;&lt;/p&gt;
&lt;table class="table simple" id="unique_25052973__table.ccm" border="1" cellpadding="4" cellspacing="0" frame="border" rules="all" summary=""&gt;
&lt;tbody class="tbody"&gt;
&lt;tr class="row"&gt;
&lt;td class="entry nocellnorowborder" colspan="1" headers="d44315e546" rowspan="1"&gt;24&lt;/td&gt;
&lt;td class="entry cell-norowborder" colspan="1" headers="d44315e549" rowspan="1"&gt;Bit 0: Direction bit Bit 7 &amp;ndash; Bit 1: Zero padded&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&amp;quot; ?&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: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/350682?ContentTypeID=1</link><pubDate>Tue, 01 Feb 2022 13:16:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6323d62-33ed-4451-8662-b102975506a7</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Eugene,&lt;/p&gt;
&lt;p&gt;There are no other references in official code that I am aware of. You may be able to find some old threads on DevZone or open source third party projects that could be useful though, but I have no particular in mind. Update: &lt;a href="https://github.com/NordicPlayground/nrf52-esb-ccm-example"&gt;nrf-esb-ccm-example&lt;/a&gt;&amp;nbsp;is a simpler example demonstrating this.&lt;/p&gt;
&lt;p&gt;We do not have performance numbers for CryptoCell. However, you can run &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/nrf/samples/samples_crypto.html"&gt;crypto examples&lt;/a&gt;&amp;nbsp;from the SDKs with different configurations to compare CryptoCell with other software backends.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/350681?ContentTypeID=1</link><pubDate>Tue, 01 Feb 2022 13:10:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f03f004d-96ca-4673-8cc6-c9d1c7829102</guid><dc:creator>Hiihtaja</dc:creator><description>&lt;p&gt;Hi Einar !&lt;/p&gt;
&lt;p&gt;I think in SoftDevice you have everything ( Endeverything work fine !) but I need to implement something like this for proprietary radio and according to PS it does not look so simple. If you have some other references always welcome !&lt;/p&gt;
&lt;p&gt;2. Do you have any performance digits for CryptoCell ? Just for understand how long similar crypto operation can take ?.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Maybe it so long time and in this case, encrypt/decrypt can be done as pre/post-operation even in a tight loop.&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: Encrypting/decrypting packets on-the-fly</title><link>https://devzone.nordicsemi.com/thread/350667?ContentTypeID=1</link><pubDate>Tue, 01 Feb 2022 12:29:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c282f68-0441-4422-ad24-356ddc437b0a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Eugene,&lt;/p&gt;
[quote user=""]1. Do you have examples for nRF52840 what is demonstrate encryption/decryption packets on the fly as it explained in PS chapter 6.4 ?[/quote]
&lt;p&gt;The CCM peripheral is used to encrypt packets on the fly in for instance Bluetooth. This is part of the stack implementations. The SoftDevice stack (used in the nRF5 SDK) and the SoftDevice controller (link layer) used in the nRF Connect SDK are closed source so you cannot refer to those, but you can see how this is used in the Zephyr LL by looking at &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c"&gt;zephyr\subsys\bluetooth\controller\ll_sw\nordic\hal\nrf5\radio\radio.c&lt;/a&gt;.&lt;/p&gt;
[quote user=""]2. What about examples for usage of CryptoCell 310 in similar way ? I mean transparently wit some shortcuts from radio to it ?[/quote]
&lt;p&gt;No, there is no HW support for using CryptoCell on the fly together with the radio. You will need to first receive the data in a RAM buffer, then use CPU to start the crypto operation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>