aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBenny Halevy <bhalevy@fs1.bhalevy.com>2007-11-08 08:34:09 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2007-11-08 08:34:09 -0500
commitef19454bd437b2ba14c9cda1de85debd9f383484 (patch)
tree842280a85e54d735bf31e1bba17e6fc88c990df0 /lib
parentdbeeb816e805091e7cfc03baf36dc40b4adb2bbd (diff)
[LIB] crc32c: Keep intermediate crc state in cpu order
crypto/crc32.c:chksum_final() is computing the digest as *(__le32 *)out = ~cpu_to_le32(mctx->crc); so the low-level crc32c_le routines should just keep the crc in cpu order, otherwise it is getting swabbed one too many times on big-endian machines. Signed-off-by: Benny Halevy <bhalevy@fs1.bhalevy.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrc32c.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/libcrc32c.c b/lib/libcrc32c.c
index 802f11f0bf5b..b5c3287d8ea4 100644
--- a/lib/libcrc32c.c
+++ b/lib/libcrc32c.c
@@ -33,7 +33,6 @@
33#include <linux/crc32c.h> 33#include <linux/crc32c.h>
34#include <linux/compiler.h> 34#include <linux/compiler.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <asm/byteorder.h>
37 36
38MODULE_AUTHOR("Clay Haapala <chaapala@cisco.com>"); 37MODULE_AUTHOR("Clay Haapala <chaapala@cisco.com>");
39MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations"); 38MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations");
@@ -161,15 +160,13 @@ static const u32 crc32c_table[256] = {
161 */ 160 */
162 161
163u32 __pure 162u32 __pure
164crc32c_le(u32 seed, unsigned char const *data, size_t length) 163crc32c_le(u32 crc, unsigned char const *data, size_t length)
165{ 164{
166 u32 crc = __cpu_to_le32(seed);
167
168 while (length--) 165 while (length--)
169 crc = 166 crc =
170 crc32c_table[(crc ^ *data++) & 0xFFL] ^ (crc >> 8); 167 crc32c_table[(crc ^ *data++) & 0xFFL] ^ (crc >> 8);
171 168
172 return __le32_to_cpu(crc); 169 return crc;
173} 170}
174 171
175#endif /* CRC_LE_BITS == 8 */ 172#endif /* CRC_LE_BITS == 8 */