public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Mathew McBride <matt@traverse.com.au>
Cc: u-boot@lists.denx.de, Alexandru Gagniuc <mr.nuke.me@gmail.com>,
	Simon Glass <sjg@chromium.org>
Subject: Re: [PATCH] image: fit: fix byte order for crc32 hash check
Date: Tue, 14 Sep 2021 09:07:11 -0400	[thread overview]
Message-ID: <20210914130711.GF12964@bill-the-cat> (raw)
In-Reply-To: <20210914063141.28737-1-matt@traverse.com.au>

[-- Attachment #1: Type: text/plain, Size: 1488 bytes --]

On Tue, Sep 14, 2021 at 06:31:41AM +0000, Mathew McBride wrote:

> In 92055e138f ("image: Drop if/elseif hash selection in calculate_hash()")
> the FIT image hash verification code was simplified to use the hash API.
> 
> This broke verification of CRC32 hash FIT images (e.g NXP MC firmware)
> as the hash API crc32 calculates in big endian (refer commit
> 74a18ee8a563, "crc32: Correct endianness of crc32 result"), whereas
> the previous call directly to crc32_wd does not do a byteswap.
> 
> Example:
> dumpimage -l qoriq-mc-binary/ls1088a/mc_ls1088a_10.29.1.itb
> FIT description: MC Firmware
> Created:         Fri Aug 27 14:14:32 2021
> ...
>   Hash algo:    crc32
>   Hash value:   c09d959c
> Was returning FB9D3710 to fit_image_check_hash instead of C09D959C
> 
> Correct the byte order in the crc32_uimage_fixup so the little endian
> values are returned.
> 
> Fixes: 92055e138f "image: Drop if/elseif hash selection in calculate_hash()"
> Signed-off-by: Mathew McBride <matt@traverse.com.au>

Good catch.  However:
   sandbox:  w+   sandbox
+(sandbox)   *((uint32_t *)value) = ntohl(*((uint32_t *)value));
+(sandbox)                          ^~~~~
+(sandbox)                          atoll
w+(sandbox) tools/../common/image-fit.c: In function ‘crc32_uimage_fixup’:
w+(sandbox) tools/../common/image-fit.c:1201:25: warning: implicit declaration of function ‘ntohl’; did you mean ‘atoll’? [-Wimplicit-function-declaration]

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

      reply	other threads:[~2021-09-14 13:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14  6:31 [PATCH] image: fit: fix byte order for crc32 hash check Mathew McBride
2021-09-14 13:07 ` Tom Rini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210914130711.GF12964@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=matt@traverse.com.au \
    --cc=mr.nuke.me@gmail.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox