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-next>] [day] [month] [year] [list]
Date:	Thu, 31 Jan 2008 23:53:20 -0500
From:	"George Spelvin" <linux@...izon.com>
To:	hpa@...or.com, ijc@...lion.org.uk
Cc:	linux@...izon.com, linux-kernel@...r.kernel.org,
	tglx@...utronix.de, mingo@...hat.com, hpa@...or.com
Subject: There are smaller ways to encode a CRC32 table...

The code to fill it in is smaller than the table itself.
Is it worth complicating things with some INIT code to reduce
the stored image size?  (The table is not compressible.)

#define CRC32POLY	0xedb88320	/* CRC32 polynomial, little-endian */

static uint32_t crctab32[256];

void
crc32init(void)
{
	unsigned i, j;
	uint32_t crc = 1;

	crctab32[0] = 0;

	for (i = 128; i; i >>= 1) {
		crc = (crc >> 1) ^ ((crc & 1) ? CRC32POLY : 0);
		for (j = 0; j < 256; j += 2*i)
			crctab32[i+j] = crc ^ crctab32[j];
	}
}

The above code basically computes the CRCs of the bytes 0x80, 0x40, ... 0x01,
and applies the identity crctab32[i^j] = crctab32[i] ^ crctab32[j].

And BTW, storing the inverse of the CRC only catches trailing (after the CRC)
all-zero padding.  If this is not a problem, it's not necessary, although you
still might want to do it just for consistency.  This inversion changes the
CRC of the entire image (body + CRC) from all-zero to a fixed non-zero value.
(To be precise, to the (non-inverted) CRC of 0xffffffff.)
--
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