summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/crc32.c12
-rw-r--r--include/crc.h1
2 files changed, 13 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)
{
diff --git a/include/crc.h b/include/crc.h
index eb972705c2..a5204aaabb 100644
--- a/include/crc.h
+++ b/include/crc.h
@@ -36,6 +36,7 @@ static inline u16 crc_itu_t_byte(u16 crc, const u8 data)
#endif
uint32_t crc32(uint32_t, const void *, unsigned int);
+uint32_t crc32_be(uint32_t, const void *, unsigned int);
uint32_t crc32_no_comp(uint32_t, const void *, unsigned int);
int file_crc(char *filename, unsigned long start, unsigned long size,
unsigned long *crc, unsigned long *total);