[PATCH 3/3] pbl: decomp: print mismatched hashes on one line each
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Oct 19 05:38:17 PDT 2022
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 at 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
More information about the barebox
mailing list