diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-12-09 11:58:32 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-12-13 23:17:32 +0100 |
commit | ef2fe9f793c0796beea292a12ad0a1577645ef01 (patch) | |
tree | 99bbc2f0a575e993d27f767e6287563613ef682c /crypto | |
parent | 7daf1c9835672a1a0731bcac30e5ae9751273c58 (diff) | |
download | barebox-ef2fe9f793c0796beea292a12ad0a1577645ef01.tar.gz barebox-ef2fe9f793c0796beea292a12ad0a1577645ef01.tar.xz |
crypto: crc32: add big endian CRC implementation
This implementation is a straight copy of the tableless
implementation inside Linux' lib/crc32.c
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20211209105832.3518384-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/crc32.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/crc32.c b/crypto/crc32.c index 232c023adb..998cbc9de2 100644 --- a/crypto/crc32.c +++ b/crypto/crc32.c @@ -187,6 +187,18 @@ STATIC uint32_t crc32_no_comp(uint32_t crc, const void *_buf, unsigned int len) return crc; } +STATIC uint32_t crc32_be(uint32_t crc, const void *_buf, unsigned int len) +{ + const unsigned char *buf = _buf; + int i; + while (len--) { + crc ^= *buf++ << 24; + for (i = 0; i < 8; i++) + crc = (crc << 1) ^ ((crc & 0x80000000) ? 0x04c11db7 : 0); + } + return crc; +} + STATIC int file_crc(char *filename, ulong start, ulong size, ulong *crc, ulong *total) { |