diff options
author | Alexandru Gagniuc <mr.nuke.me@gmail.com> | 2021-09-14 15:53:33 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-09-14 17:46:00 -0400 |
commit | cc34e76ec2ba6317a21ed3aa3119d58d29de7ba5 (patch) | |
tree | 8ad88293b50c59a246e4486add6c6a9f9bf3be70 | |
parent | 1edd7e8aed7596aa78db499f21a50d9370f90a16 (diff) | |
download | u-boot-debug-FIT-tests.zip u-boot-debug-FIT-tests.tar.gz u-boot-debug-FIT-tests.tar.bz2 |
image: Avoid erroneous double byte-swap in CRC valuedebug-FIT-tests
The hash algorithm selection was streamlined in commit 92055e138f28
("image: Drop if/elseif hash selection in calculate_hash()"). Said
commit kept the call to cpu_to_uimage() to convert the CRC to big
endian format.
This would have been correct when calling crc32_wd(). However, the
->hash_func_ws member of crc32 points to crc32_wd_buf(), which already
converts the CRC to big endian. On a little endian host, doing both
conversions results in a little-endian CRC. This is incorrect.
To remedy this, simply drop the call to cpu_to_uimage(), thus only
doing the byte-order conversion once.
Fixes: 92055e138f28 ("image: Drop if/elseif hash selection in
calculate_hash()")
Tested-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
-rw-r--r-- | common/image-fit.c | 9 |
1 files changed, 0 insertions, 9 deletions
diff --git a/common/image-fit.c b/common/image-fit.c index 92d9141..f02d437 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1193,12 +1193,6 @@ int fit_set_timestamp(void *fit, int noffset, time_t timestamp) return 0; } -static void crc32_uimage_fixup(void *value) -{ - /* TODO: In C, this type punning is undefined behavior: */ - *((uint32_t *)value) = cpu_to_uimage(*((uint32_t *)value)); -} - /** * calculate_hash - calculate and return hash for provided input data * @data: pointer to the input data @@ -1232,9 +1226,6 @@ int calculate_hash(const void *data, int data_len, const char *name, algo->hash_func_ws(data, data_len, value, algo->chunk_size); *value_len = algo->digest_size; - if (!strcmp(name, "crc32")) - crc32_uimage_fixup(value); - return 0; } |