mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Michael Tretter <m.tretter@pengutronix.de>
Cc: BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 2/5] scripts: rockchip: add helper for updating hash
Date: Tue, 5 Aug 2025 07:06:31 +0200	[thread overview]
Message-ID: <aJGRVxKTPGNN-aba@pengutronix.de> (raw)
In-Reply-To: <20250731-rkimage-cleanup-v1-2-967037e5d67a@pengutronix.de>

Hi Michael,

On Thu, Jul 31, 2025 at 12:48:22PM +0200, Michael Tretter wrote:
> The idb contains a flag for the used hash type. Use the flag to
> determine the used hash function and update the hash accordingly.
> 
> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> ---
>  scripts/rkimage.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/scripts/rkimage.c b/scripts/rkimage.c
> index ba89f32d9376d0153692baa3ddde1c793c1e4cc2..fd97bd1dd9f5967762d0a8bf9d186594a05a2a9f 100644
> --- a/scripts/rkimage.c
> +++ b/scripts/rkimage.c
> @@ -42,6 +42,17 @@ static void sha512(const void *buf, int len, void *out)
>  	EVP_MD_CTX_free(md_ctx);
>  }
>  
> +static void idb_hash(struct newidb *idb)
> +{
> +	unsigned char *idbu8 = (void *)idb;
> +	size_t size = 1536;
> +
> +	if (!!(idb->flags & NEWIDB_FLAGS_SHA256))
> +		sha256(idbu8, size, idbu8 + size);
> +	else if (!!(idb->flags & NEWIDB_FLAGS_SHA512))
> +		sha512(idbu8, size, idbu8 + size);
> +}

Drop these double negations.

NEWIDB_FLAGS_* are defined in the next patch, should be here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2025-08-05  5:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-31 10:48 [PATCH 0/5] scripts: rockchip: fix and cleanup rkimage Michael Tretter
2025-07-31 10:48 ` [PATCH 1/5] scripts: rockchip: use correct header size Michael Tretter
2025-07-31 10:48 ` [PATCH 2/5] scripts: rockchip: add helper for updating hash Michael Tretter
2025-08-05  5:06   ` Sascha Hauer [this message]
2025-07-31 10:48 ` [PATCH 3/5] scripts: rockchip: rename hashtype to flags Michael Tretter
2025-07-31 10:48 ` [PATCH 4/5] scripts: rockchip: rename NEWIDB_MAGIC to NEWIDB_MAGIC_RKNS Michael Tretter
2025-07-31 10:48 ` [PATCH 5/5] scripts: rockchip: support RKSS images Michael Tretter

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=aJGRVxKTPGNN-aba@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.tretter@pengutronix.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