aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass2013-04-18 05:25:51 -0500
committerTom Rini2013-04-19 09:24:14 -0500
commit74a18ee8a563d9c21b5856269f911b69bc4aaccb (patch)
tree10bd52a8c5b1b855831bb47095ca7819b1d26222 /lib
parent2386060c16471f4cd183e6f8bce82450a7574ec6 (diff)
downloadu-boot-74a18ee8a563d9c21b5856269f911b69bc4aaccb.tar.gz
u-boot-74a18ee8a563d9c21b5856269f911b69bc4aaccb.tar.xz
u-boot-74a18ee8a563d9c21b5856269f911b69bc4aaccb.zip
crc32: Correct endianness of crc32 result
When crc32 is handled by the hash library, it requires the data to be in big-endian format, since it reads it byte-wise. Thus at present the 'crc32' command reports incorrect data. For example, previously we might see: Peach # crc32 40000000 100 CRC32 for 40000000 ... 400000ff ==> 0d968558 but instead with the hash library we see: Peach # crc32 40000000 100 CRC32 for 40000000 ... 400000ff ==> 5885960d Correct this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@google.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/crc32.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/crc32.c b/lib/crc32.c
index 76205da4f3..9759212486 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -8,7 +8,9 @@
8 * For conditions of distribution and use, see copyright notice in zlib.h 8 * For conditions of distribution and use, see copyright notice in zlib.h
9 */ 9 */
10 10
11#ifndef USE_HOSTCC 11#ifdef USE_HOSTCC
12#include <arpa/inet.h>
13#else
12#include <common.h> 14#include <common.h>
13#endif 15#endif
14#include <compiler.h> 16#include <compiler.h>
@@ -256,5 +258,6 @@ void crc32_wd_buf(const unsigned char *input, unsigned int ilen,
256 uint32_t crc; 258 uint32_t crc;
257 259
258 crc = crc32_wd(0, input, ilen, chunk_sz); 260 crc = crc32_wd(0, input, ilen, chunk_sz);
261 crc = htonl(crc);
259 memcpy(output, &crc, sizeof(crc)); 262 memcpy(output, &crc, sizeof(crc));
260} 263}