<?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>Overflowing CCM scratchpad</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48610/overflowing-ccm-scratchpad</link><description>The scratchpad is overflowing when generating a keystream prior to a CCM decrypt operation. 
 The size of the scratchpad is calculated according to the formula in the product specification: 
 &amp;quot;A space of 43 bytes, or (16 + MAXPACKETSIZE) bytes, whatever</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Jun 2019 10:01:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48610/overflowing-ccm-scratchpad" /><item><title>RE: Overflowing CCM scratchpad</title><link>https://devzone.nordicsemi.com/thread/193610?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2019 10:01:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1da2ba77-058d-40e8-8e35-b67ea30a82d1</guid><dc:creator>David Anthony</dc:creator><description>&lt;p&gt;Thanks !!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Overflowing CCM scratchpad</title><link>https://devzone.nordicsemi.com/thread/193543?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2019 07:00:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9ae67ae-0864-4048-9104-874166e3d175</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am glad you found the issue., and thanks for letting me know the details. I have reported this internally so that the PS can be updated, properly defining&amp;nbsp;MAXPACKETSIZE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Overflowing CCM scratchpad</title><link>https://devzone.nordicsemi.com/thread/193464?ContentTypeID=1</link><pubDate>Tue, 18 Jun 2019 14:04:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a546d5eb-a174-4138-8266-4fe976bf7b0a</guid><dc:creator>David Anthony</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This question was originally posted a few days ago.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Since then I have solved the issue.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The root of the problem was the amount of space allocated for the scratchpad.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;According to the CCM chapter of the product specification:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;A space of 43 bytes, or (16 + MAXPACKETSIZE) bytes, whatever is largest, must be reserved in RAM.&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As there is no definition of&amp;nbsp;MAXPACKETSIZE to be found in the CCM chapter, I made an assumption.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I took MAXPACKETSIZE&amp;nbsp; to mean the maximum packet size I intended to use which was:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt; 64 + header + length + RFU + MIC = 64 + 1 + 1 + 1 + 4 = 71.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This turned out to be inadequate and caused scratchpad overflows.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Trial and error showed that&amp;nbsp;MAXPACKETSIZE&amp;nbsp;actually means the maximum theoretical packet size. This gives:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;MAXPACKETSIZE&amp;nbsp; = 255&amp;nbsp;+ header + length + RFU + MIC = 255&amp;nbsp;+ 1 + 1 + 1 + 4 = 262&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Using this value of&amp;nbsp;MAXPACKETSIZE&amp;nbsp;to calculate the required scratchpad size results in no overflows.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The requirements for the size of the scratch data area could perhaps be a little clearer in the product specification.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Overflowing CCM scratchpad</title><link>https://devzone.nordicsemi.com/thread/193142?ContentTypeID=1</link><pubDate>Mon, 17 Jun 2019 11:11:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44d77b52-a854-4df5-917b-178c1d3a110d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am lacking a bit of information in order to understand your test better. Can you show more of your code, particularly how scratchpad is declared? How do you know that there has been an overflow? Did you, for instance, memset it to a known pattern before doing the CCM decrypt operation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>