mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] crypto: crc32: implement crc32() with crc32_no_comp()
@ 2023-12-13 14:00 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2023-12-13 14:00 UTC (permalink / raw)
  To: Barebox List

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 crypto/crc32.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/crypto/crc32.c b/crypto/crc32.c
index 287dfa3303..7e969cd18e 100644
--- a/crypto/crc32.c
+++ b/crypto/crc32.c
@@ -77,28 +77,6 @@ static void make_crc_table(void)
 #define DO4(buf)  DO2(buf); DO2(buf);
 #define DO8(buf)  DO4(buf); DO4(buf);
 
-STATIC uint32_t crc32(uint32_t crc, const void *_buf, unsigned int len)
-{
-	const unsigned char *buf = _buf;
-
-	make_crc_table();
-
-	crc = crc ^ 0xffffffffL;
-	while (len >= 8) {
-		DO8(buf);
-		len -= 8;
-	}
-	if (len)
-		do {
-			DO1(buf);
-		} while (--len);
-	return crc ^ 0xffffffffL;
-}
-
-#ifdef __BAREBOX__
-EXPORT_SYMBOL(crc32);
-#endif
-
 /* No ones complement version. JFFS2 (and other things ?)
  * don't use ones compliment in their CRC calculations.
  */
@@ -120,6 +98,15 @@ STATIC uint32_t crc32_no_comp(uint32_t crc, const void *_buf, unsigned int len)
 	return crc;
 }
 
+STATIC uint32_t crc32(uint32_t crc, const void *buf, unsigned int len)
+{
+	return ~crc32_no_comp(~crc, buf, len);
+}
+
+#ifdef __BAREBOX__
+EXPORT_SYMBOL(crc32);
+#endif
+
 STATIC uint32_t crc32_be(uint32_t crc, const void *_buf, unsigned int len)
 {
 	const unsigned char *buf = _buf;
-- 
2.39.2




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-13 14:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13 14:00 [PATCH] crypto: crc32: implement crc32() with crc32_no_comp() Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox