<?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>dfu hash not matching calculated hash from a .bin file</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83146/dfu-hash-not-matching-calculated-hash-from-a-bin-file</link><description>hello nordic 
 
 i am working with nrf52840, device with zephyr and i am writing an application that uses the smp service to preform dfu over BLE. 
 i am struggling with calculating or finding the hash in from the .bin file generated with west build </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 30 Dec 2021 16:25:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83146/dfu-hash-not-matching-calculated-hash-from-a-bin-file" /><item><title>RE: dfu hash not matching calculated hash from a .bin file</title><link>https://devzone.nordicsemi.com/thread/345506?ContentTypeID=1</link><pubDate>Thu, 30 Dec 2021 16:25:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:786c7edf-24fd-48f6-9bb8-d14728c9d8a1</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Try running&amp;nbsp;&lt;code&gt;imgtool verify &amp;lt;binary file&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;For example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;imgtool verify app_update.bin
Image was correctly validated
Image version: 0.0.0+0
Image digest: 1e28160956d8a6d507e6279730c6b7302191248eaae2aab338e426c91e9869ac&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The value after &amp;quot;Image digest&amp;quot; is the&amp;nbsp;hash (sha256) of the image header + body.&lt;/p&gt;
&lt;p&gt;You can check out the python functions&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/v1.7.99-ncs4/scripts/imgtool/main.py#L145"&gt;main.py--&amp;gt;verify()&lt;/a&gt;&amp;nbsp;--&amp;gt;&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/v1.7.99-ncs4/scripts/imgtool/image.py#L574-L577"&gt;image.py--&amp;gt;verify()&lt;/a&gt; to see the calculations.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>