mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/3] pbl: decomp: print mismatched hashes on one line each
Date: Wed, 19 Oct 2022 14:38:17 +0200	[thread overview]
Message-ID: <20221019123817.1659468-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20221019123817.1659468-1-a.fatoum@pengutronix.de>

With DEBUG_LL enabled, hashes are printed to show mismatches, but each
byte is padded with 6 or 14 zeroes and has a line just for itself.
Rework this, so it now looks a lot cleaner:

  CH 40e941dfcf53087b86e549fbc279cbc1d4fd87c64febb42af6324c5b3ec64e03
  IH 3aa627d34b97f4a6af6a4ebf022236dc4b025c5902296b694a65eb6b92f8d66d

While at it, print a hexdump of the first 64 bytes of the buffer
that could not be verified. This is only printed when DEBUG is
enabled and serves as a first aid to debugging as verification failure
is not an expected occurrence with firmware baked into barebox PBL.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 pbl/decomp.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/pbl/decomp.c b/pbl/decomp.c
index 553895bac5e8..ebdf81ddfbe5 100644
--- a/pbl/decomp.c
+++ b/pbl/decomp.c
@@ -70,20 +70,20 @@ int pbl_barebox_verify(const void *compressed_start, unsigned int len,
 	sha256_update(&d, compressed_start, len);
 	sha256_final(&d, computed_hash);
 	if (IS_ENABLED(CONFIG_DEBUG_LL)) {
-		putc_ll('C');
-		putc_ll('H');
-		putc_ll('\n');
-		for (i = 0; i < SHA256_DIGEST_SIZE; i++) {
-			puthex_ll(computed_hash[i]);
-			putc_ll('\n');
-		}
-		putc_ll('I');
-		putc_ll('H');
+		puts_ll("CH ");
+
+		for (i = 0; i < SHA256_DIGEST_SIZE; i++)
+			puthexc_ll(computed_hash[i]);
+
+		puts_ll("\nIH ");
+
+		for (i = 0; i < SHA256_DIGEST_SIZE; i++)
+			puthexc_ll(char_hash[i]);
+
 		putc_ll('\n');
-		for (i = 0; i < SHA256_DIGEST_SIZE; i++) {
-			puthex_ll(char_hash[i]);
-			putc_ll('\n');
-		}
+
+		pr_debug("Hexdump of first 64 bytes of %u\n", len);
+		print_hex_dump_bytes("", DUMP_PREFIX_ADDRESS, compressed_start, 64);
 	}
 
 	return memcmp(hash, computed_hash, SHA256_DIGEST_SIZE);
-- 
2.30.2




  parent reply	other threads:[~2022-10-19 12:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 12:38 [PATCH 1/3] include: debug_ll: define puthexc_ll Ahmad Fatoum
2022-10-19 12:38 ` [PATCH 2/3] lib: hexdump: make available for PBL debugging Ahmad Fatoum
2022-10-19 12:38 ` Ahmad Fatoum [this message]
2022-11-02  8:26 ` [PATCH 1/3] include: debug_ll: define puthexc_ll Sascha Hauer

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=20221019123817.1659468-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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