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] [thread-next>] [day] [month] [year] [list]
Message-ID: <OF7D1699A1.9B1BD547-ONC12578E7.005DB5FE-C12578E7.005E4AEB@transmode.se>
Date:	Tue, 9 Aug 2011 19:09:55 +0200
From:	Joakim Tjernlund <joakim.tjernlund@...nsmode.se>
To:	Bob Pearson <rpearson@...temfabricworks.com>
Cc:	akpm@...ux-foundation.org, fzago@...temfabricworks.com,
	linux@...izon.com, linux-kernel@...r.kernel.org
Subject: Re: [patch v3 5/7] crc32: add-real-8-bit.diff



Bob Pearson <rpearson@...temfabricworks.com> wrote on 2011/08/09 07:25:49:

> From: Bob Pearson <rpearson@...temfabricworks.com>
> To: linux-kernel@...r.kernel.org, linux@...izon.com, joakim.tjernlund@...nsmode.se, fzago@...temfabricworks.com, rpearson@...temfabricworks.com, akpm@...ux-foundation.org
> Date: 2011/08/09 07:25
> Subject: [patch v3 5/7] crc32: add-real-8-bit.diff
>
> crc32.c encodes an algorithm that processes 32 bits at a time
> with the value BITS = 8 and leaves out the most common 8 bit algorithm
> for computing the crc. This patch reencodes the 32 bit algorithm
> with the value 32 and adds back the 'standard' 8 bit algorithm.
>
> Signed-off-by: Bob Pearson <rpearson@...temfabricworks.com>
>
> ---
>  lib/crc32.c          |   17 ++++++++++++++---
>  lib/crc32defs.h      |   18 ++++++++++--------
>  lib/gen_crc32table.c |   27 ++++++++++++++++++---------
>  3 files changed, 42 insertions(+), 20 deletions(-)
>

...

> ===================================================================
> --- infiniband.orig/lib/gen_crc32table.c
> +++ infiniband/lib/gen_crc32table.c
> @@ -4,11 +4,20 @@
>
>  #define ENTRIES_PER_LINE 4
>
> +#if CRC_LE_BITS <= 8
>  #define LE_TABLE_SIZE (1 << CRC_LE_BITS)
> +#else
> +#define LE_TABLE_SIZE 256
> +#endif
> +
> +#if CRC_BE_BITS <= 8
>  #define BE_TABLE_SIZE (1 << CRC_BE_BITS)
> +#else
> +#define BE_TABLE_SIZE 256
> +#endif
>
> -static uint32_t crc32table_le[4][LE_TABLE_SIZE];
> -static uint32_t crc32table_be[4][BE_TABLE_SIZE];
> +static uint32_t crc32table_le[8][256];
> +static uint32_t crc32table_be[8][256];

Above is wrong as only 32 bits is supported at this point.

>
>  /**
>   * crc32init_le() - allocate and initialize LE table data
> @@ -24,14 +33,14 @@ static void crc32init_le(void)
>
>     crc32table_le[0][0] = 0;
>
> -   for (i = 1 << (CRC_LE_BITS - 1); i; i >>= 1) {
> +   for (i = LE_TABLE_SIZE >> 1; i; i >>= 1) {
>        crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
>        for (j = 0; j < LE_TABLE_SIZE; j += 2 * i)
>           crc32table_le[0][i + j] = crc ^ crc32table_le[0][j];
>     }
>     for (i = 0; i < LE_TABLE_SIZE; i++) {
>        crc = crc32table_le[0][i];
> -      for (j = 1; j < 4; j++) {
> +      for (j = 1; j < 8; j++) {
>           crc = crc32table_le[0][crc & 0xff] ^ (crc >> 8);
>           crc32table_le[j][i] = crc;
>        }
> @@ -55,18 +64,18 @@ static void crc32init_be(void)
>     }
>     for (i = 0; i < BE_TABLE_SIZE; i++) {
>        crc = crc32table_be[0][i];
> -      for (j = 1; j < 4; j++) {
> +      for (j = 1; j < 8; j++) {
>           crc = crc32table_be[0][(crc >> 24) & 0xff] ^ (crc << 8);
>           crc32table_be[j][i] = crc;
>        }
>     }
>  }
>
> -static void output_table(uint32_t table[4][256], int len, char *trans)
> +static void output_table(uint32_t table[8][256], int len, char *trans)
>  {
>     int i, j;
>
> -   for (j = 0 ; j < 4; j++) {
> +   for (j = 0 ; j < 8; j++) {
>        printf("{");
>        for (i = 0; i < len - 1; i++) {
>           if (i % ENTRIES_PER_LINE == 0)
> @@ -83,14 +92,14 @@ int main(int argc, char** argv)
>
>     if (CRC_LE_BITS > 1) {
>        crc32init_le();
> -      printf("static const u32 crc32table_le[4][256] = {");
> +      printf("static const u32 crc32table_le[8][256] = {");

This makes the table way to big.

>        output_table(crc32table_le, LE_TABLE_SIZE, "tole");
>        printf("};\n");
>     }
>
>     if (CRC_BE_BITS > 1) {
>        crc32init_be();
> -      printf("static const u32 crc32table_be[4][256] = {");
> +      printf("static const u32 crc32table_be[8][256] = {");
Ditto.

>        output_table(crc32table_be, BE_TABLE_SIZE, "tobe");
>        printf("};\n");
>     }

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