lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	23 May 2011 19:38:35 -0400
From:	"George Spelvin" <linux@...izon.com>
To:	arend@...adcom.com, linux@...izon.com
Cc:	johannes@...solutions.net, linux-kernel@...r.kernel.org
Subject: Re: [RFC] lib: crc8: add new library module providing crc8

>> Thanks. However, your code example is confusing.

>>> You can fill in a CRC table for an arbitrary polynomial with
>>>
>>> #define POLY 0xAB	/* 1 + x^2 + x^4 + x^6 + x^7 (+ x^8) */
>>> typedef uint8_t crc_type;	/* Must be an unsigned type */
>>>
>>> void
>>> crc_le(crc_type const table[256], crc_type crc, u8 const *buf, size_t len)
>>> {
>>> 	while (len--)
>>> 		crc = (crc>>  8) ^ table[(crc ^ *buf++)&  0xff];
> 
>> Here is where my confusion starts. Shifting crc by 8 bits basically 
>> means 0 ^ table[], right?

> I think I understand the code a bit better. Your code is generic for any 
> given crc_type.

Yes, exactly.  The crc_type has to be at least as wide as the CRC
being computed.  If the crc_type is only 8 bits, the shift by 8 does
indeed get optimized away.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ