<?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>NRF52840 Cryptocell EC signature verify getting stuck in a loop</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/56250/nrf52840-cryptocell-ec-signature-verify-getting-stuck-in-a-loop</link><description>Using a NRF52840 running zephyr and mcuboot, the function nrf_cc310_bl_ecdsa_verify_secp256r1() is getting stuck in a loop. 
 I am using NRFXLIB v1.1.0 
 Looking at the disassembly window in my IDE 
 PkaEcdsaVerify is getting tuck in a loop and never</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 09 Jan 2020 12:59:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/56250/nrf52840-cryptocell-ec-signature-verify-getting-stuck-in-a-loop" /><item><title>RE: NRF52840 Cryptocell EC signature verify getting stuck in a loop</title><link>https://devzone.nordicsemi.com/thread/228359?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2020 12:59:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4be6f40e-15e8-4d91-ad71-82707b9183d1</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am glad you found a workaround. The R&amp;amp;D team is&amp;nbsp;working on improving the crypto support in nRF Connect SDK, and they are aware of this specific issue, but I cannot say when we will have a better solution.&lt;/p&gt;
&lt;p&gt;That said, I am a bit puzzled&amp;nbsp;that how you import the signature and public key mattered since they are valid. Just a shot in the dark, but could it be that you just had the wrong endianness? Could you try to swap the endianness and see? (If so, remember to swap the two halfs of the public key separately).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Cryptocell EC signature verify getting stuck in a loop</title><link>https://devzone.nordicsemi.com/thread/228231?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2020 21:36:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1db6d1d-fd4e-4602-b545-d7a6b083567b</guid><dc:creator>Barry</dc:creator><description>&lt;p&gt;I was able to get the signature checking to work by using&amp;nbsp;&lt;/p&gt;
&lt;p&gt;mbedtls_ecdsa_verify()&lt;/p&gt;
&lt;p&gt;instead of&amp;nbsp;&lt;/p&gt;
&lt;p&gt;nrf_cc310_bl_ecdsa_verify_secp256r1()&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Of course, using&amp;nbsp;&lt;span&gt;mbedtls_ecdsa_verify() took a whole lot of extra work to be able to transform the signature, and public key into the correct formats. It also increased the size of the&amp;nbsp;bootloader significantly by requiring me to include a number of extra MBEDTLS code to do the setup and transformations necessary to get the inputs to this function.&amp;nbsp;&amp;nbsp;And it forced me to hack some MCUboot code I would have rather left un-hacked up.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So I would still appreciate&amp;nbsp;some resolution if possible, but I have a work around worst case scenario.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Cryptocell EC signature verify getting stuck in a loop</title><link>https://devzone.nordicsemi.com/thread/228194?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2020 15:14:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d559715-2e68-4d1f-9aa5-8c73ddd11585</guid><dc:creator>Barry</dc:creator><description>&lt;p&gt;Never mind. I tried removing CONFIG_HW_CC310=y and&amp;nbsp;CONFIG_ENTROPY_GENERATOR=y, and I still had the same issue. So even without those platform initializations I am still getting stuck in the same loop.&lt;/p&gt;
&lt;p&gt;I noticed that MCUboot was passing a location is flash for the public key as opposed to a ram location. I thought that might be an issue. But I changed the implementation to copy the public key to RAM before providing it to the verify function. That did not impact the behavior either. Regardless of it not fixing this issue, is that something that should be done? If so I will recommend it to MCUboot.&lt;/p&gt;
&lt;p&gt;So I am stuck as to what could be wrong.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;MCUboot makes the following function call&lt;/p&gt;
&lt;p&gt;nrf_cc310_bl_ecdsa_verify_secp256r1(&amp;amp;ctx,&lt;br /&gt; (nrf_cc310_bl_ecc_public_key_secp256r1_t *) public_key,&lt;br /&gt; (nrf_cc310_bl_ecc_signature_secp256r1_t *) signature,&lt;br /&gt; hash,&lt;br /&gt; hash_len);&lt;/p&gt;
&lt;p&gt;Where pblic_key, signature, and has have the values I provided before.&lt;/p&gt;
&lt;p&gt;hash_len is 32.&lt;/p&gt;
&lt;p&gt;ctx is decalred with&amp;nbsp;nrf_cc310_bl_ecdsa_verify_context_secp256r1_t ctx;&lt;/p&gt;
&lt;p&gt;Before the verify function is called the following things are done by MCUboot:&lt;/p&gt;
&lt;p&gt;NRF_CRYPTOCELL-&amp;gt;ENABLE=1;&lt;/p&gt;
&lt;p&gt;nrf_cc310_bl_init();&lt;/p&gt;
&lt;p&gt;NRF_CRYPTOCELL-&amp;gt;ENABLE=0;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_CRYPTOCELL-&amp;gt;ENABLE=1;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;does this make sense as an implementation?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Cryptocell EC signature verify getting stuck in a loop</title><link>https://devzone.nordicsemi.com/thread/228181?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2020 14:31:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edeb306d-0e63-47cf-9524-4b0f774be811</guid><dc:creator>Barry</dc:creator><description>&lt;p&gt;What is B0?&lt;/p&gt;
&lt;p&gt;I guess it could be a configuration issue. I am trying to do crypto operations beyond the the nrf_cc310_bl module in my bootloader. So I am enabling the&amp;nbsp;nrf_cc310_platform and&amp;nbsp;nrf_cc310_mbedcrypto libraries also. So maybe it is an initialization issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I do see at the&amp;nbsp;nrf_cc310_bl_init() function declaration it says &amp;quot;Running this initialization is intended for cases where there&amp;nbsp;is no direct requirement for the RNG subsystem&amp;quot;. But I have enabled entropy and the cc310 platform, so hw_cc310 is also in the build. It does do several initialization functions including&amp;nbsp;&lt;/p&gt;
&lt;p&gt;nrf_cc310_platform_abort_init()&lt;/p&gt;
&lt;p&gt;nrf_cc310_platform_mutex_init()&lt;/p&gt;
&lt;p&gt;nrf_cc310_platform_init()&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So maybe these initialization are messing with the&amp;nbsp;&lt;span&gt;nrf_cc310_bl_init() function.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If that is the case. Then what are my options? I guess I could just skip including the nrf_cc310_bl libary, since the things it can do can all be done in the&amp;nbsp;nrf_cc310_mbedcrypto library. I need to do some AES operations&amp;nbsp;in my bootloader, so I need the full crypto capabilities&amp;nbsp;in the bootloader.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Cryptocell EC signature verify getting stuck in a loop</title><link>https://devzone.nordicsemi.com/thread/228157?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2020 13:41:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:904f8f04-92d1-4ff1-9169-76b43fc473c9</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The public key is valid, and in fact, this runs correctly with nrf_cc310_bl in SDK 16.0.0. So it seems there may be an MCUboot/B0 configuration issue or bug, but I am not sure what is going on. We need to look a bit more into it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Cryptocell EC signature verify getting stuck in a loop</title><link>https://devzone.nordicsemi.com/thread/227981?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2020 17:35:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a21eed27-a47e-48c7-a670-fbb498b008f2</guid><dc:creator>Barry</dc:creator><description>&lt;p&gt;I think these are my values&lt;/p&gt;
&lt;p&gt;Signature&lt;br /&gt;B4 D8 E8 F8 8B FA E9 88 C6 CE 06 B6 3C 62 30 39 E4 30 82 5F 8C D4 A5 2B D4 46 BD 2C 9C DA E1 F0 30 25 27 0A EA 6A 1A 5D F1 D0 60 F1 10 CF 4E CC 79 56 DD 09 3C C2 E7 85 8D 2E E7 CE 69 35 A3 9C&lt;/p&gt;
&lt;p&gt;Hash&lt;br /&gt;E5 26 87 64 4F D7 58 BD F4 F1 0E 2F C5 63 35 1C C4 6D 75 CF 91 62 49 EF BC 1C C0 18 66 CE 61 0A&lt;/p&gt;
&lt;p&gt;Public key&lt;br /&gt;2A CB 40 3C E8 FE ED 5B A4 49 95 A1 A9 1D AE E8 DB BE 19 37 CD 14 FB 2F 24 57 37 E5 95 39 88 D9 94 B9 D6 5A EB D7 CD D5 30 8A D6 FE 48 B2 4A 6A 81 0E E5 F0 7D 8B 68 34 CC 3A 6A FC 53 8E FA C1&lt;/p&gt;
&lt;p&gt;Same data without spaces&lt;/p&gt;
&lt;p&gt;Signature&lt;br /&gt;B4D8E8F88BFAE988C6CE06B63C623039E430825F8CD4A52BD446BD2C9CDAE1F03025270AEA6A1A5DF1D060F110CF4ECC7956DD093CC2E7858D2EE7CE6935A39C&lt;/p&gt;
&lt;p&gt;Hash&lt;br /&gt;E52687644FD758BDF4F10E2FC563351CC46D75CF916249EFBC1CC01866CE610A&lt;/p&gt;
&lt;p&gt;Public key&lt;br /&gt;2ACB403CE8FEED5BA44995A1A91DAEE8DBBE1937CD14FB2F245737E5953988D994B9D65AEBD7CDD5308AD6FE48B24A6A810EE5F07D8B6834CC3A6AFC538EFAC1&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Edit 1: I originally posted the wrong thing for the Public key but it was amended 3:21 PM eastern time 1/7/20202&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Cryptocell EC signature verify getting stuck in a loop</title><link>https://devzone.nordicsemi.com/thread/227948?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2020 15:03:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c24c0c5f-a15c-4dd7-9ddc-12cc421defff</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I do think we have seen this issue before. One thought is that we do not know exactly what happens in the HW if the public key is invalid. Can you try to validate it and see if that could be the issue? Alternatively, could you provide us with the signature, hash and public key so that I can test on my side (it is typically not secret information, but you can open a private case for it if you do not want to share it publically).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>