Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 254A4C433EF for ; Wed, 5 Jan 2022 15:30:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 56D9582A59; Wed, 5 Jan 2022 16:30:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1641396649; bh=lFd0n5Z2a4Ify5ui/c4b0zPRbyXvQDKR0JQ/HasQrU8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sDleMzdwQRKZNsHnjE7LF6WhR/0hZr0XyouhyMMPAfNUgEj8xMlABTN8Gcil31oV/ jTlGH+blqGFy7u6LfSwQB0QJElZQ+rDno2PTKN5zDpxlGn+Ra/rlJr/lhSN8vN+PL/ 1MbKOP1xV+93QvMXEPzhpbEbvFiCquT+SrKwC1e3vEEM373flqX3TI6mVhO/5aLwID EmOGmqkyHyIbarrOr6zb19lg1ntnG7td5WhezxTAcLJz7XhpmiicA/vS1KErA7vh4i Q+WJgQcSW3YWsVPzchuyWeVh8V2/rO7F1ec7RC9l44wZ5zVaAyZ2npL9BQcM/krJks hXyQl7lPrwOCA== Received: by phobos.denx.de (Postfix, from userid 109) id B44FF82A59; Wed, 5 Jan 2022 16:30:47 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3C62E81432 for ; Wed, 5 Jan 2022 16:30:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4JTYN45QZwzQlGs; Wed, 5 Jan 2022 16:30:44 +0100 (CET) Message-ID: Date: Wed, 5 Jan 2022 16:30:40 +0100 MIME-Version: 1.0 Subject: Re: [PATCH] tools: kwbimage: Fix checksum calculation for v1 images Content-Language: en-US To: Pierre Bourdon , u-boot@lists.denx.de Cc: =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= References: <20211225195019.1509965-1-delroth@gmail.com> From: Stefan Roese In-Reply-To: <20211225195019.1509965-1-delroth@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 12/25/21 20:50, Pierre Bourdon wrote: > Recent changes caused fields in the image main header to be modified > after the header checksum had already been computed. Move the checksum > computation to once again be the last operation performed on the header. > > Fixes: 2b0980c24027 ("tools: kwbimage: Fill the real header size into the main header") > > Signed-off-by: Pierre Bourdon Reviewed-by: Stefan Roese Thanks, Stefan > --- > tools/kwbimage.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/tools/kwbimage.c b/tools/kwbimage.c > index 875f636c7a..0951d7861c 100644 > --- a/tools/kwbimage.c > +++ b/tools/kwbimage.c > @@ -1398,9 +1398,6 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, > headersz, image, secure_hdr)) > return NULL; > > - /* Calculate and set the header checksum */ > - main_hdr->checksum = image_checksum8(main_hdr, headersz); > - > *imagesz = headersz; > > /* Fill the real header size without padding into the main header */ > @@ -1410,6 +1407,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, > main_hdr->headersz_lsb = cpu_to_le16(headersz & 0xFFFF); > main_hdr->headersz_msb = (headersz & 0xFFFF0000) >> 16; > > + /* Calculate and set the header checksum */ > + main_hdr->checksum = image_checksum8(main_hdr, headersz); > + > return image; > } > > Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de