<?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>Cross checking nrfutil boot_validation_signature for VALIDATE_ECDSA_P256_SHA256 with openssl command line</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63773/cross-checking-nrfutil-boot_validation_signature-for-validate_ecdsa_p256_sha256-with-openssl-command-line</link><description>Hello, 
 I setup nrfutil to use VALIDATE_ECDSA_P256_SHA256 and have this output from the pkg display output: 
 |- hash_type: SHA256 |- hash (little-endian): 60de8328530e5882b789259309c47d20dc1a9482f89606ad2cb70d9ad6456b1b | |- boot_validation_type: [</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 09 Dec 2020 01:38:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63773/cross-checking-nrfutil-boot_validation_signature-for-validate_ecdsa_p256_sha256-with-openssl-command-line" /><item><title>RE: Cross checking nrfutil boot_validation_signature for VALIDATE_ECDSA_P256_SHA256 with openssl command line</title><link>https://devzone.nordicsemi.com/thread/283935?ContentTypeID=1</link><pubDate>Wed, 09 Dec 2020 01:38:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb497e32-e232-4c05-932a-146b55941fe2</guid><dc:creator>Wendel</dc:creator><description>&lt;p&gt;Hi Richard,&lt;/p&gt;
&lt;p&gt;Thanks for the clarification. It really helps a lot.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cross checking nrfutil boot_validation_signature for VALIDATE_ECDSA_P256_SHA256 with openssl command line</title><link>https://devzone.nordicsemi.com/thread/283848?ContentTypeID=1</link><pubDate>Tue, 08 Dec 2020 14:23:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81d3f43a-9e60-462e-a5d1-d5ee51856672</guid><dc:creator>Richard R</dc:creator><description>&lt;p&gt;Hi Wendel,&lt;/p&gt;
&lt;p&gt;Not directly, no. The answer from &lt;em&gt;Turbo J&amp;nbsp;&lt;/em&gt;is correct.&lt;/p&gt;
&lt;p&gt;nrfutil stores the ecdsa signature as &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;{r,s}&lt;/span&gt; value pairs (32-byte each) in little endian &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;{r_le, s_le}&lt;/span&gt;. See &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;nrfutil/dfu/signing.py&lt;/span&gt; for lines like this:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span class="pl-k"&gt;return&lt;/span&gt; &lt;span class="pl-s1"&gt;signature&lt;/span&gt;[&lt;span class="pl-c1"&gt;31&lt;/span&gt;::&lt;span class="pl-c1"&gt;-&lt;/span&gt;&lt;span class="pl-c1"&gt;1&lt;/span&gt;] &lt;span class="pl-c1"&gt;+&lt;/span&gt; &lt;span class="pl-s1"&gt;signature&lt;/span&gt;[&lt;span class="pl-c1"&gt;63&lt;/span&gt;:&lt;span class="pl-c1"&gt;31&lt;/span&gt;:&lt;span class="pl-c1"&gt;-&lt;/span&gt;&lt;span class="pl-c1"&gt;1&lt;/span&gt;]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I ended up creating a variant of that function that can return the big-endian format.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;I can&amp;#39;t find a simple openssl CLI to cross-check, so I end up using pyca/crytography library (&lt;a href="https://cryptography.io/en/latest/index.html"&gt;https://cryptography.io/en/latest/index.html&lt;/a&gt;) which uses openssl as a back-end for testing.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cross checking nrfutil boot_validation_signature for VALIDATE_ECDSA_P256_SHA256 with openssl command line</title><link>https://devzone.nordicsemi.com/thread/283704?ContentTypeID=1</link><pubDate>Tue, 08 Dec 2020 07:26:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a97ba9d5-a7f2-4803-9683-24f8f5b7eabf</guid><dc:creator>Wendel</dc:creator><description>&lt;p&gt;Hi Richard&lt;/p&gt;
&lt;p&gt;Have you got the method to cross check signature with openssl command line?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cross checking nrfutil boot_validation_signature for VALIDATE_ECDSA_P256_SHA256 with openssl command line</title><link>https://devzone.nordicsemi.com/thread/259998?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2020 20:41:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73afd493-85c1-4e2d-8a5b-fbfb0a246a7a</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;I cannot provide OpenSSL commands, but there are two important things missing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ASN.1 encoding&lt;/li&gt;
&lt;li&gt;big endian byte order&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;nrfutil.sign&lt;/span&gt; file is smaller because it is not ASN.1 encoded. OpenSSL expects signatures to be ASN.1 encoded in order to provide meta information (e.g. which algorithm to use).&lt;/p&gt;
&lt;p&gt;The encoded data is expected to be in network byte order (= big endian). The nrfutil program generates signatures in little endian, since that matches the endianess of the NordicSemi Cortex-M chips - and thus no byte order swapping needs to be done when checking the signature in the bootloader.&lt;/p&gt;
&lt;p&gt;In summary, for OpenSSL to be useful one needs to swap byte order (reverse bytes), and then encode the result &lt;em&gt;properly &lt;/em&gt;as ASN.1 data. Not sure if this is &lt;em&gt;possible&lt;/em&gt; with the command line tool only.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>