From owner-freebsd-hackers Thu Jan 23 09:27:06 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id JAA00864 for hackers-outgoing; Thu, 23 Jan 1997 09:27:06 -0800 (PST) Received: from lassie.eunet.fi (lassie.eunet.fi [192.26.119.7]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id JAA00859 for ; Thu, 23 Jan 1997 09:27:02 -0800 (PST) Received: from marathon.tekla.fi by lassie.eunet.fi with SMTP id AA26279 (5.67a/IDA-1.5 for ); Thu, 23 Jan 1997 19:26:53 +0200 Received: from poveri.tekla.fi by marathon.tekla.fi (5.65/20-jun-90) id AA24616; Thu, 23 Jan 1997 19:26:52 +0200 From: sja@tekla.fi (Sakari Jalovaara) Received: by poveri.tekla.fi; (5.65v3.2/1.1.8.2/20Aug96-0557PM) id AA15141; Thu, 23 Jan 1997 19:26:49 +0200 Date: Thu, 23 Jan 1997 19:26:49 +0200 Message-Id: <9701231726.AA15141@poveri.tekla.fi> To: hackers@freebsd.org Cc: msmith@atrad.adelaide.edu.au Subject: Re: CRC-16 algorithms? Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > 00000000 00 39 3c 3e 01 02 03 00 80 00 00 00 00 00 00 00 |.9<>............| > 00000010 08 00 0e 20 3d 4b 00 00 00 00 00 00 00 02 01 00 |... =K..........| > 00000020 01 03 00 de ad 01 00 00 00 00 00 00 00 00 00 01 |....-...........| > 00000030 00 00 00 00 00 00 00 00 00 00 00 00 01 26 3c aa |.............&<.| > > The bytes at 0x3d and 0x3e are the CRC-16 of the bytes from 0-0x3c Just checking: without the _three_ last bytes of that data, the CRC-16 checksum is 0x3d3e? I don't seem to find such a CRC-16 algorithm (unless we assume an arbitrary "XorOut" parameter.) For trying CRC-16 with different parameters, get "crcmodel.c" from http://kbs.cs.tu-berlin.de/isis/crc and use the following little main program. I didn't try all different "cm_init" values, just -1 and 0. Write your own for loop for that. You'll need another set of test data if you try that. Or if you try different final xor parameters. int main (void) { cm_t cm; int x, crc; static unsigned char data[] = { 0x00, 0x39, 0x3c, 0x3e, 0x01, 0x02, 0x03, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0e, 0x20, 0x3d, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x03, 0x00, 0xde, 0xad, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, }; int n; for (x = 1; x <= 0xffff; x += 2) { cm.cm_width = 16; cm.cm_poly = x; cm.cm_init = 0L; cm.cm_refin = FALSE; cm.cm_refot = FALSE; cm.cm_xorot = 0L; cm_ini(&cm); for (n = 0; n < sizeof (data); n++) cm_nxt(&cm, data[n]); crc = cm_crc(&cm); if (crc == 0x3d3e) printf("%x %x\n", crc, x); } return 0; } ++sja