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]
Message-ID: <OF718A605A.F3B31DD6-ONC1257904.003A5AB7-C1257904.003A8AD4@transmode.se>
Date:	Wed, 7 Sep 2011 12:39:26 +0200
From:	Joakim Tjernlund <joakim.tjernlund@...nsmode.se>
To:	"George Spelvin" <linux@...izon.com>
Cc:	akpm@...ux-foundation.org, fzago@...temfabricworks.com,
	linux-kernel@...r.kernel.org, rpearson@...temfabricworks.com
Subject: Re: [patch v5 7/8] crc32-add-slicing-by-8.diff


"George Spelvin" <linux@...izon.com> wrote on 2011/08/11 17:34:01:
>
> I don't know if you care, but here's some slightly more compact code for
> creating the tables.  It produces the same results, and I don't think
> it's any slower.
>
> I can explain it if anyone's confused, but it's hopefully fairly
> easy to figure out assuming a backgriund in CRC math.
>
> (Tested against existing code, not in kernel.)
> Signed-off-by: George Spelvin <linux@...izon.com>

Forgot about this mail. Looks really neat :)
Easy to generalize to support crc16 too.

 Jocke
>
> static void crc32init_le(void)
> {
>    unsigned i, j, k;
>    uint32_t crc = 1;
>
>    for (i = 0; i < LE_TABLE_ROWS; i++) {
>       crc32table_le[i][0] = 0;
>       for (j = LE_TABLE_SIZE >> 1; j; j >>= 1) {
>          crc = (crc >> 1) ^ (crc & 1 ? CRCPOLY_LE : 0);
>          for (k = 0; k < LE_TABLE_SIZE; k += 2 * j)
>             crc32table_le[i][j + k] = crc ^ crc32table_le[i][k];
>       }
>    }
> }
>
> static void crc32init_be(void)
> {
>    unsigned i, j, k;
>    uint32_t crc = 0x80000000;
>
>    for (i = 0; i < BE_TABLE_ROWS; i++) {
>       crc32table_be[i][0] = 0;
>       for (j = 1; j < BE_TABLE_SIZE; j <<= 1) {
>          crc = (crc << 1) ^ (crc & 0x80000000 ? CRCPOLY_BE : 0);
>          for (k = 0; k < j; k++)
>             crc32table_be[i][j + k] = crc ^ crc32table_be[i][k];
>       }
>    }
> }

--
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