diff --git a/src/crc16.c b/src/crc16.c index 2153177578..cbab2782d3 100644 --- a/src/crc16.c +++ b/src/crc16.c @@ -44,7 +44,8 @@ * Output for "123456789" : 31C3 */ -static const uint16_t crc16tab[256]= { +static const uint16_t crc16tab[]= { + /* zeroth byte LUT */ 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7, 0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef, 0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6, @@ -76,13 +77,618 @@ static const uint16_t crc16tab[256]= { 0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9, 0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1, 0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8, - 0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0 + 0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0, + + /* first byte LUT */ + 0x0000,0x3331,0x6662,0x5553,0xccc4,0xfff5,0xaaa6,0x9997, + 0x89a9,0xba98,0xefcb,0xdcfa,0x456d,0x765c,0x230f,0x103e, + 0x0373,0x3042,0x6511,0x5620,0xcfb7,0xfc86,0xa9d5,0x9ae4, + 0x8ada,0xb9eb,0xecb8,0xdf89,0x461e,0x752f,0x207c,0x134d, + 0x06e6,0x35d7,0x6084,0x53b5,0xca22,0xf913,0xac40,0x9f71, + 0x8f4f,0xbc7e,0xe92d,0xda1c,0x438b,0x70ba,0x25e9,0x16d8, + 0x0595,0x36a4,0x63f7,0x50c6,0xc951,0xfa60,0xaf33,0x9c02, + 0x8c3c,0xbf0d,0xea5e,0xd96f,0x40f8,0x73c9,0x269a,0x15ab, + 0x0dcc,0x3efd,0x6bae,0x589f,0xc108,0xf239,0xa76a,0x945b, + 0x8465,0xb754,0xe207,0xd136,0x48a1,0x7b90,0x2ec3,0x1df2, + 0x0ebf,0x3d8e,0x68dd,0x5bec,0xc27b,0xf14a,0xa419,0x9728, + 0x8716,0xb427,0xe174,0xd245,0x4bd2,0x78e3,0x2db0,0x1e81, + 0x0b2a,0x381b,0x6d48,0x5e79,0xc7ee,0xf4df,0xa18c,0x92bd, + 0x8283,0xb1b2,0xe4e1,0xd7d0,0x4e47,0x7d76,0x2825,0x1b14, + 0x0859,0x3b68,0x6e3b,0x5d0a,0xc49d,0xf7ac,0xa2ff,0x91ce, + 0x81f0,0xb2c1,0xe792,0xd4a3,0x4d34,0x7e05,0x2b56,0x1867, + 0x1b98,0x28a9,0x7dfa,0x4ecb,0xd75c,0xe46d,0xb13e,0x820f, + 0x9231,0xa100,0xf453,0xc762,0x5ef5,0x6dc4,0x3897,0x0ba6, + 0x18eb,0x2bda,0x7e89,0x4db8,0xd42f,0xe71e,0xb24d,0x817c, + 0x9142,0xa273,0xf720,0xc411,0x5d86,0x6eb7,0x3be4,0x08d5, + 0x1d7e,0x2e4f,0x7b1c,0x482d,0xd1ba,0xe28b,0xb7d8,0x84e9, + 0x94d7,0xa7e6,0xf2b5,0xc184,0x5813,0x6b22,0x3e71,0x0d40, + 0x1e0d,0x2d3c,0x786f,0x4b5e,0xd2c9,0xe1f8,0xb4ab,0x879a, + 0x97a4,0xa495,0xf1c6,0xc2f7,0x5b60,0x6851,0x3d02,0x0e33, + 0x1654,0x2565,0x7036,0x4307,0xda90,0xe9a1,0xbcf2,0x8fc3, + 0x9ffd,0xaccc,0xf99f,0xcaae,0x5339,0x6008,0x355b,0x066a, + 0x1527,0x2616,0x7345,0x4074,0xd9e3,0xead2,0xbf81,0x8cb0, + 0x9c8e,0xafbf,0xfaec,0xc9dd,0x504a,0x637b,0x3628,0x0519, + 0x10b2,0x2383,0x76d0,0x45e1,0xdc76,0xef47,0xba14,0x8925, + 0x991b,0xaa2a,0xff79,0xcc48,0x55df,0x66ee,0x33bd,0x008c, + 0x13c1,0x20f0,0x75a3,0x4692,0xdf05,0xec34,0xb967,0x8a56, + 0x9a68,0xa959,0xfc0a,0xcf3b,0x56ac,0x659d,0x30ce,0x03ff, + + /* second byte LUT */ + 0x0000,0x3730,0x6e60,0x5950,0xdcc0,0xebf0,0xb2a0,0x8590, + 0xa9a1,0x9e91,0xc7c1,0xf0f1,0x7561,0x4251,0x1b01,0x2c31, + 0x4363,0x7453,0x2d03,0x1a33,0x9fa3,0xa893,0xf1c3,0xc6f3, + 0xeac2,0xddf2,0x84a2,0xb392,0x3602,0x0132,0x5862,0x6f52, + 0x86c6,0xb1f6,0xe8a6,0xdf96,0x5a06,0x6d36,0x3466,0x0356, + 0x2f67,0x1857,0x4107,0x7637,0xf3a7,0xc497,0x9dc7,0xaaf7, + 0xc5a5,0xf295,0xabc5,0x9cf5,0x1965,0x2e55,0x7705,0x4035, + 0x6c04,0x5b34,0x0264,0x3554,0xb0c4,0x87f4,0xdea4,0xe994, + 0x1dad,0x2a9d,0x73cd,0x44fd,0xc16d,0xf65d,0xaf0d,0x983d, + 0xb40c,0x833c,0xda6c,0xed5c,0x68cc,0x5ffc,0x06ac,0x319c, + 0x5ece,0x69fe,0x30ae,0x079e,0x820e,0xb53e,0xec6e,0xdb5e, + 0xf76f,0xc05f,0x990f,0xae3f,0x2baf,0x1c9f,0x45cf,0x72ff, + 0x9b6b,0xac5b,0xf50b,0xc23b,0x47ab,0x709b,0x29cb,0x1efb, + 0x32ca,0x05fa,0x5caa,0x6b9a,0xee0a,0xd93a,0x806a,0xb75a, + 0xd808,0xef38,0xb668,0x8158,0x04c8,0x33f8,0x6aa8,0x5d98, + 0x71a9,0x4699,0x1fc9,0x28f9,0xad69,0x9a59,0xc309,0xf439, + 0x3b5a,0x0c6a,0x553a,0x620a,0xe79a,0xd0aa,0x89fa,0xbeca, + 0x92fb,0xa5cb,0xfc9b,0xcbab,0x4e3b,0x790b,0x205b,0x176b, + 0x7839,0x4f09,0x1659,0x2169,0xa4f9,0x93c9,0xca99,0xfda9, + 0xd198,0xe6a8,0xbff8,0x88c8,0x0d58,0x3a68,0x6338,0x5408, + 0xbd9c,0x8aac,0xd3fc,0xe4cc,0x615c,0x566c,0x0f3c,0x380c, + 0x143d,0x230d,0x7a5d,0x4d6d,0xc8fd,0xffcd,0xa69d,0x91ad, + 0xfeff,0xc9cf,0x909f,0xa7af,0x223f,0x150f,0x4c5f,0x7b6f, + 0x575e,0x606e,0x393e,0x0e0e,0x8b9e,0xbcae,0xe5fe,0xd2ce, + 0x26f7,0x11c7,0x4897,0x7fa7,0xfa37,0xcd07,0x9457,0xa367, + 0x8f56,0xb866,0xe136,0xd606,0x5396,0x64a6,0x3df6,0x0ac6, + 0x6594,0x52a4,0x0bf4,0x3cc4,0xb954,0x8e64,0xd734,0xe004, + 0xcc35,0xfb05,0xa255,0x9565,0x10f5,0x27c5,0x7e95,0x49a5, + 0xa031,0x9701,0xce51,0xf961,0x7cf1,0x4bc1,0x1291,0x25a1, + 0x0990,0x3ea0,0x67f0,0x50c0,0xd550,0xe260,0xbb30,0x8c00, + 0xe352,0xd462,0x8d32,0xba02,0x3f92,0x08a2,0x51f2,0x66c2, + 0x4af3,0x7dc3,0x2493,0x13a3,0x9633,0xa103,0xf853,0xcf63, + + /* third byte LUT */ + 0x0000,0x76b4,0xed68,0x9bdc,0xcaf1,0xbc45,0x2799,0x512d, + 0x85c3,0xf377,0x68ab,0x1e1f,0x4f32,0x3986,0xa25a,0xd4ee, + 0x1ba7,0x6d13,0xf6cf,0x807b,0xd156,0xa7e2,0x3c3e,0x4a8a, + 0x9e64,0xe8d0,0x730c,0x05b8,0x5495,0x2221,0xb9fd,0xcf49, + 0x374e,0x41fa,0xda26,0xac92,0xfdbf,0x8b0b,0x10d7,0x6663, + 0xb28d,0xc439,0x5fe5,0x2951,0x787c,0x0ec8,0x9514,0xe3a0, + 0x2ce9,0x5a5d,0xc181,0xb735,0xe618,0x90ac,0x0b70,0x7dc4, + 0xa92a,0xdf9e,0x4442,0x32f6,0x63db,0x156f,0x8eb3,0xf807, + 0x6e9c,0x1828,0x83f4,0xf540,0xa46d,0xd2d9,0x4905,0x3fb1, + 0xeb5f,0x9deb,0x0637,0x7083,0x21ae,0x571a,0xccc6,0xba72, + 0x753b,0x038f,0x9853,0xeee7,0xbfca,0xc97e,0x52a2,0x2416, + 0xf0f8,0x864c,0x1d90,0x6b24,0x3a09,0x4cbd,0xd761,0xa1d5, + 0x59d2,0x2f66,0xb4ba,0xc20e,0x9323,0xe597,0x7e4b,0x08ff, + 0xdc11,0xaaa5,0x3179,0x47cd,0x16e0,0x6054,0xfb88,0x8d3c, + 0x4275,0x34c1,0xaf1d,0xd9a9,0x8884,0xfe30,0x65ec,0x1358, + 0xc7b6,0xb102,0x2ade,0x5c6a,0x0d47,0x7bf3,0xe02f,0x969b, + 0xdd38,0xab8c,0x3050,0x46e4,0x17c9,0x617d,0xfaa1,0x8c15, + 0x58fb,0x2e4f,0xb593,0xc327,0x920a,0xe4be,0x7f62,0x09d6, + 0xc69f,0xb02b,0x2bf7,0x5d43,0x0c6e,0x7ada,0xe106,0x97b2, + 0x435c,0x35e8,0xae34,0xd880,0x89ad,0xff19,0x64c5,0x1271, + 0xea76,0x9cc2,0x071e,0x71aa,0x2087,0x5633,0xcdef,0xbb5b, + 0x6fb5,0x1901,0x82dd,0xf469,0xa544,0xd3f0,0x482c,0x3e98, + 0xf1d1,0x8765,0x1cb9,0x6a0d,0x3b20,0x4d94,0xd648,0xa0fc, + 0x7412,0x02a6,0x997a,0xefce,0xbee3,0xc857,0x538b,0x253f, + 0xb3a4,0xc510,0x5ecc,0x2878,0x7955,0x0fe1,0x943d,0xe289, + 0x3667,0x40d3,0xdb0f,0xadbb,0xfc96,0x8a22,0x11fe,0x674a, + 0xa803,0xdeb7,0x456b,0x33df,0x62f2,0x1446,0x8f9a,0xf92e, + 0x2dc0,0x5b74,0xc0a8,0xb61c,0xe731,0x9185,0x0a59,0x7ced, + 0x84ea,0xf25e,0x6982,0x1f36,0x4e1b,0x38af,0xa373,0xd5c7, + 0x0129,0x779d,0xec41,0x9af5,0xcbd8,0xbd6c,0x26b0,0x5004, + 0x9f4d,0xe9f9,0x7225,0x0491,0x55bc,0x2308,0xb8d4,0xce60, + 0x1a8e,0x6c3a,0xf7e6,0x8152,0xd07f,0xa6cb,0x3d17,0x4ba3, + + /* fourth byte LUT */ + 0x0000,0xaa51,0x4483,0xeed2,0x8906,0x2357,0xcd85,0x67d4, + 0x022d,0xa87c,0x46ae,0xecff,0x8b2b,0x217a,0xcfa8,0x65f9, + 0x045a,0xae0b,0x40d9,0xea88,0x8d5c,0x270d,0xc9df,0x638e, + 0x0677,0xac26,0x42f4,0xe8a5,0x8f71,0x2520,0xcbf2,0x61a3, + 0x08b4,0xa2e5,0x4c37,0xe666,0x81b2,0x2be3,0xc531,0x6f60, + 0x0a99,0xa0c8,0x4e1a,0xe44b,0x839f,0x29ce,0xc71c,0x6d4d, + 0x0cee,0xa6bf,0x486d,0xe23c,0x85e8,0x2fb9,0xc16b,0x6b3a, + 0x0ec3,0xa492,0x4a40,0xe011,0x87c5,0x2d94,0xc346,0x6917, + 0x1168,0xbb39,0x55eb,0xffba,0x986e,0x323f,0xdced,0x76bc, + 0x1345,0xb914,0x57c6,0xfd97,0x9a43,0x3012,0xdec0,0x7491, + 0x1532,0xbf63,0x51b1,0xfbe0,0x9c34,0x3665,0xd8b7,0x72e6, + 0x171f,0xbd4e,0x539c,0xf9cd,0x9e19,0x3448,0xda9a,0x70cb, + 0x19dc,0xb38d,0x5d5f,0xf70e,0x90da,0x3a8b,0xd459,0x7e08, + 0x1bf1,0xb1a0,0x5f72,0xf523,0x92f7,0x38a6,0xd674,0x7c25, + 0x1d86,0xb7d7,0x5905,0xf354,0x9480,0x3ed1,0xd003,0x7a52, + 0x1fab,0xb5fa,0x5b28,0xf179,0x96ad,0x3cfc,0xd22e,0x787f, + 0x22d0,0x8881,0x6653,0xcc02,0xabd6,0x0187,0xef55,0x4504, + 0x20fd,0x8aac,0x647e,0xce2f,0xa9fb,0x03aa,0xed78,0x4729, + 0x268a,0x8cdb,0x6209,0xc858,0xaf8c,0x05dd,0xeb0f,0x415e, + 0x24a7,0x8ef6,0x6024,0xca75,0xada1,0x07f0,0xe922,0x4373, + 0x2a64,0x8035,0x6ee7,0xc4b6,0xa362,0x0933,0xe7e1,0x4db0, + 0x2849,0x8218,0x6cca,0xc69b,0xa14f,0x0b1e,0xe5cc,0x4f9d, + 0x2e3e,0x846f,0x6abd,0xc0ec,0xa738,0x0d69,0xe3bb,0x49ea, + 0x2c13,0x8642,0x6890,0xc2c1,0xa515,0x0f44,0xe196,0x4bc7, + 0x33b8,0x99e9,0x773b,0xdd6a,0xbabe,0x10ef,0xfe3d,0x546c, + 0x3195,0x9bc4,0x7516,0xdf47,0xb893,0x12c2,0xfc10,0x5641, + 0x37e2,0x9db3,0x7361,0xd930,0xbee4,0x14b5,0xfa67,0x5036, + 0x35cf,0x9f9e,0x714c,0xdb1d,0xbcc9,0x1698,0xf84a,0x521b, + 0x3b0c,0x915d,0x7f8f,0xd5de,0xb20a,0x185b,0xf689,0x5cd8, + 0x3921,0x9370,0x7da2,0xd7f3,0xb027,0x1a76,0xf4a4,0x5ef5, + 0x3f56,0x9507,0x7bd5,0xd184,0xb650,0x1c01,0xf2d3,0x5882, + 0x3d7b,0x972a,0x79f8,0xd3a9,0xb47d,0x1e2c,0xf0fe,0x5aaf, + + /* fifth byte LUT */ + 0x0000,0x45a0,0x8b40,0xcee0,0x06a1,0x4301,0x8de1,0xc841, + 0x0d42,0x48e2,0x8602,0xc3a2,0x0be3,0x4e43,0x80a3,0xc503, + 0x1a84,0x5f24,0x91c4,0xd464,0x1c25,0x5985,0x9765,0xd2c5, + 0x17c6,0x5266,0x9c86,0xd926,0x1167,0x54c7,0x9a27,0xdf87, + 0x3508,0x70a8,0xbe48,0xfbe8,0x33a9,0x7609,0xb8e9,0xfd49, + 0x384a,0x7dea,0xb30a,0xf6aa,0x3eeb,0x7b4b,0xb5ab,0xf00b, + 0x2f8c,0x6a2c,0xa4cc,0xe16c,0x292d,0x6c8d,0xa26d,0xe7cd, + 0x22ce,0x676e,0xa98e,0xec2e,0x246f,0x61cf,0xaf2f,0xea8f, + 0x6a10,0x2fb0,0xe150,0xa4f0,0x6cb1,0x2911,0xe7f1,0xa251, + 0x6752,0x22f2,0xec12,0xa9b2,0x61f3,0x2453,0xeab3,0xaf13, + 0x7094,0x3534,0xfbd4,0xbe74,0x7635,0x3395,0xfd75,0xb8d5, + 0x7dd6,0x3876,0xf696,0xb336,0x7b77,0x3ed7,0xf037,0xb597, + 0x5f18,0x1ab8,0xd458,0x91f8,0x59b9,0x1c19,0xd2f9,0x9759, + 0x525a,0x17fa,0xd91a,0x9cba,0x54fb,0x115b,0xdfbb,0x9a1b, + 0x459c,0x003c,0xcedc,0x8b7c,0x433d,0x069d,0xc87d,0x8ddd, + 0x48de,0x0d7e,0xc39e,0x863e,0x4e7f,0x0bdf,0xc53f,0x809f, + 0xd420,0x9180,0x5f60,0x1ac0,0xd281,0x9721,0x59c1,0x1c61, + 0xd962,0x9cc2,0x5222,0x1782,0xdfc3,0x9a63,0x5483,0x1123, + 0xcea4,0x8b04,0x45e4,0x0044,0xc805,0x8da5,0x4345,0x06e5, + 0xc3e6,0x8646,0x48a6,0x0d06,0xc547,0x80e7,0x4e07,0x0ba7, + 0xe128,0xa488,0x6a68,0x2fc8,0xe789,0xa229,0x6cc9,0x2969, + 0xec6a,0xa9ca,0x672a,0x228a,0xeacb,0xaf6b,0x618b,0x242b, + 0xfbac,0xbe0c,0x70ec,0x354c,0xfd0d,0xb8ad,0x764d,0x33ed, + 0xf6ee,0xb34e,0x7dae,0x380e,0xf04f,0xb5ef,0x7b0f,0x3eaf, + 0xbe30,0xfb90,0x3570,0x70d0,0xb891,0xfd31,0x33d1,0x7671, + 0xb372,0xf6d2,0x3832,0x7d92,0xb5d3,0xf073,0x3e93,0x7b33, + 0xa4b4,0xe114,0x2ff4,0x6a54,0xa215,0xe7b5,0x2955,0x6cf5, + 0xa9f6,0xec56,0x22b6,0x6716,0xaf57,0xeaf7,0x2417,0x61b7, + 0x8b38,0xce98,0x0078,0x45d8,0x8d99,0xc839,0x06d9,0x4379, + 0x867a,0xc3da,0x0d3a,0x489a,0x80db,0xc57b,0x0b9b,0x4e3b, + 0x91bc,0xd41c,0x1afc,0x5f5c,0x971d,0xd2bd,0x1c5d,0x59fd, + 0x9cfe,0xd95e,0x17be,0x521e,0x9a5f,0xdfff,0x111f,0x54bf, + + /* sixth byte LUT */ + 0x0000,0xb861,0x60e3,0xd882,0xc1c6,0x79a7,0xa125,0x1944, + 0x93ad,0x2bcc,0xf34e,0x4b2f,0x526b,0xea0a,0x3288,0x8ae9, + 0x377b,0x8f1a,0x5798,0xeff9,0xf6bd,0x4edc,0x965e,0x2e3f, + 0xa4d6,0x1cb7,0xc435,0x7c54,0x6510,0xdd71,0x05f3,0xbd92, + 0x6ef6,0xd697,0x0e15,0xb674,0xaf30,0x1751,0xcfd3,0x77b2, + 0xfd5b,0x453a,0x9db8,0x25d9,0x3c9d,0x84fc,0x5c7e,0xe41f, + 0x598d,0xe1ec,0x396e,0x810f,0x984b,0x202a,0xf8a8,0x40c9, + 0xca20,0x7241,0xaac3,0x12a2,0x0be6,0xb387,0x6b05,0xd364, + 0xddec,0x658d,0xbd0f,0x056e,0x1c2a,0xa44b,0x7cc9,0xc4a8, + 0x4e41,0xf620,0x2ea2,0x96c3,0x8f87,0x37e6,0xef64,0x5705, + 0xea97,0x52f6,0x8a74,0x3215,0x2b51,0x9330,0x4bb2,0xf3d3, + 0x793a,0xc15b,0x19d9,0xa1b8,0xb8fc,0x009d,0xd81f,0x607e, + 0xb31a,0x0b7b,0xd3f9,0x6b98,0x72dc,0xcabd,0x123f,0xaa5e, + 0x20b7,0x98d6,0x4054,0xf835,0xe171,0x5910,0x8192,0x39f3, + 0x8461,0x3c00,0xe482,0x5ce3,0x45a7,0xfdc6,0x2544,0x9d25, + 0x17cc,0xafad,0x772f,0xcf4e,0xd60a,0x6e6b,0xb6e9,0x0e88, + 0xabf9,0x1398,0xcb1a,0x737b,0x6a3f,0xd25e,0x0adc,0xb2bd, + 0x3854,0x8035,0x58b7,0xe0d6,0xf992,0x41f3,0x9971,0x2110, + 0x9c82,0x24e3,0xfc61,0x4400,0x5d44,0xe525,0x3da7,0x85c6, + 0x0f2f,0xb74e,0x6fcc,0xd7ad,0xcee9,0x7688,0xae0a,0x166b, + 0xc50f,0x7d6e,0xa5ec,0x1d8d,0x04c9,0xbca8,0x642a,0xdc4b, + 0x56a2,0xeec3,0x3641,0x8e20,0x9764,0x2f05,0xf787,0x4fe6, + 0xf274,0x4a15,0x9297,0x2af6,0x33b2,0x8bd3,0x5351,0xeb30, + 0x61d9,0xd9b8,0x013a,0xb95b,0xa01f,0x187e,0xc0fc,0x789d, + 0x7615,0xce74,0x16f6,0xae97,0xb7d3,0x0fb2,0xd730,0x6f51, + 0xe5b8,0x5dd9,0x855b,0x3d3a,0x247e,0x9c1f,0x449d,0xfcfc, + 0x416e,0xf90f,0x218d,0x99ec,0x80a8,0x38c9,0xe04b,0x582a, + 0xd2c3,0x6aa2,0xb220,0x0a41,0x1305,0xab64,0x73e6,0xcb87, + 0x18e3,0xa082,0x7800,0xc061,0xd925,0x6144,0xb9c6,0x01a7, + 0x8b4e,0x332f,0xebad,0x53cc,0x4a88,0xf2e9,0x2a6b,0x920a, + 0x2f98,0x97f9,0x4f7b,0xf71a,0xee5e,0x563f,0x8ebd,0x36dc, + 0xbc35,0x0454,0xdcd6,0x64b7,0x7df3,0xc592,0x1d10,0xa571, + + /* seventh byte LUT */ + 0x0000,0x47d3,0x8fa6,0xc875,0x0f6d,0x48be,0x80cb,0xc718, + 0x1eda,0x5909,0x917c,0xd6af,0x11b7,0x5664,0x9e11,0xd9c2, + 0x3db4,0x7a67,0xb212,0xf5c1,0x32d9,0x750a,0xbd7f,0xfaac, + 0x236e,0x64bd,0xacc8,0xeb1b,0x2c03,0x6bd0,0xa3a5,0xe476, + 0x7b68,0x3cbb,0xf4ce,0xb31d,0x7405,0x33d6,0xfba3,0xbc70, + 0x65b2,0x2261,0xea14,0xadc7,0x6adf,0x2d0c,0xe579,0xa2aa, + 0x46dc,0x010f,0xc97a,0x8ea9,0x49b1,0x0e62,0xc617,0x81c4, + 0x5806,0x1fd5,0xd7a0,0x9073,0x576b,0x10b8,0xd8cd,0x9f1e, + 0xf6d0,0xb103,0x7976,0x3ea5,0xf9bd,0xbe6e,0x761b,0x31c8, + 0xe80a,0xafd9,0x67ac,0x207f,0xe767,0xa0b4,0x68c1,0x2f12, + 0xcb64,0x8cb7,0x44c2,0x0311,0xc409,0x83da,0x4baf,0x0c7c, + 0xd5be,0x926d,0x5a18,0x1dcb,0xdad3,0x9d00,0x5575,0x12a6, + 0x8db8,0xca6b,0x021e,0x45cd,0x82d5,0xc506,0x0d73,0x4aa0, + 0x9362,0xd4b1,0x1cc4,0x5b17,0x9c0f,0xdbdc,0x13a9,0x547a, + 0xb00c,0xf7df,0x3faa,0x7879,0xbf61,0xf8b2,0x30c7,0x7714, + 0xaed6,0xe905,0x2170,0x66a3,0xa1bb,0xe668,0x2e1d,0x69ce, + 0xfd81,0xba52,0x7227,0x35f4,0xf2ec,0xb53f,0x7d4a,0x3a99, + 0xe35b,0xa488,0x6cfd,0x2b2e,0xec36,0xabe5,0x6390,0x2443, + 0xc035,0x87e6,0x4f93,0x0840,0xcf58,0x888b,0x40fe,0x072d, + 0xdeef,0x993c,0x5149,0x169a,0xd182,0x9651,0x5e24,0x19f7, + 0x86e9,0xc13a,0x094f,0x4e9c,0x8984,0xce57,0x0622,0x41f1, + 0x9833,0xdfe0,0x1795,0x5046,0x975e,0xd08d,0x18f8,0x5f2b, + 0xbb5d,0xfc8e,0x34fb,0x7328,0xb430,0xf3e3,0x3b96,0x7c45, + 0xa587,0xe254,0x2a21,0x6df2,0xaaea,0xed39,0x254c,0x629f, + 0x0b51,0x4c82,0x84f7,0xc324,0x043c,0x43ef,0x8b9a,0xcc49, + 0x158b,0x5258,0x9a2d,0xddfe,0x1ae6,0x5d35,0x9540,0xd293, + 0x36e5,0x7136,0xb943,0xfe90,0x3988,0x7e5b,0xb62e,0xf1fd, + 0x283f,0x6fec,0xa799,0xe04a,0x2752,0x6081,0xa8f4,0xef27, + 0x7039,0x37ea,0xff9f,0xb84c,0x7f54,0x3887,0xf0f2,0xb721, + 0x6ee3,0x2930,0xe145,0xa696,0x618e,0x265d,0xee28,0xa9fb, + 0x4d8d,0x0a5e,0xc22b,0x85f8,0x42e0,0x0533,0xcd46,0x8a95, + 0x5357,0x1484,0xdcf1,0x9b22,0x5c3a,0x1be9,0xd39c,0x944f, + + /* eighth byte LUT */ + 0x0000,0xeb23,0xc667,0x2d44,0x9cef,0x77cc,0x5a88,0xb1ab, + 0x29ff,0xc2dc,0xef98,0x04bb,0xb510,0x5e33,0x7377,0x9854, + 0x53fe,0xb8dd,0x9599,0x7eba,0xcf11,0x2432,0x0976,0xe255, + 0x7a01,0x9122,0xbc66,0x5745,0xe6ee,0x0dcd,0x2089,0xcbaa, + 0xa7fc,0x4cdf,0x619b,0x8ab8,0x3b13,0xd030,0xfd74,0x1657, + 0x8e03,0x6520,0x4864,0xa347,0x12ec,0xf9cf,0xd48b,0x3fa8, + 0xf402,0x1f21,0x3265,0xd946,0x68ed,0x83ce,0xae8a,0x45a9, + 0xddfd,0x36de,0x1b9a,0xf0b9,0x4112,0xaa31,0x8775,0x6c56, + 0x5fd9,0xb4fa,0x99be,0x729d,0xc336,0x2815,0x0551,0xee72, + 0x7626,0x9d05,0xb041,0x5b62,0xeac9,0x01ea,0x2cae,0xc78d, + 0x0c27,0xe704,0xca40,0x2163,0x90c8,0x7beb,0x56af,0xbd8c, + 0x25d8,0xcefb,0xe3bf,0x089c,0xb937,0x5214,0x7f50,0x9473, + 0xf825,0x1306,0x3e42,0xd561,0x64ca,0x8fe9,0xa2ad,0x498e, + 0xd1da,0x3af9,0x17bd,0xfc9e,0x4d35,0xa616,0x8b52,0x6071, + 0xabdb,0x40f8,0x6dbc,0x869f,0x3734,0xdc17,0xf153,0x1a70, + 0x8224,0x6907,0x4443,0xaf60,0x1ecb,0xf5e8,0xd8ac,0x338f, + 0xbfb2,0x5491,0x79d5,0x92f6,0x235d,0xc87e,0xe53a,0x0e19, + 0x964d,0x7d6e,0x502a,0xbb09,0x0aa2,0xe181,0xccc5,0x27e6, + 0xec4c,0x076f,0x2a2b,0xc108,0x70a3,0x9b80,0xb6c4,0x5de7, + 0xc5b3,0x2e90,0x03d4,0xe8f7,0x595c,0xb27f,0x9f3b,0x7418, + 0x184e,0xf36d,0xde29,0x350a,0x84a1,0x6f82,0x42c6,0xa9e5, + 0x31b1,0xda92,0xf7d6,0x1cf5,0xad5e,0x467d,0x6b39,0x801a, + 0x4bb0,0xa093,0x8dd7,0x66f4,0xd75f,0x3c7c,0x1138,0xfa1b, + 0x624f,0x896c,0xa428,0x4f0b,0xfea0,0x1583,0x38c7,0xd3e4, + 0xe06b,0x0b48,0x260c,0xcd2f,0x7c84,0x97a7,0xbae3,0x51c0, + 0xc994,0x22b7,0x0ff3,0xe4d0,0x557b,0xbe58,0x931c,0x783f, + 0xb395,0x58b6,0x75f2,0x9ed1,0x2f7a,0xc459,0xe91d,0x023e, + 0x9a6a,0x7149,0x5c0d,0xb72e,0x0685,0xeda6,0xc0e2,0x2bc1, + 0x4797,0xacb4,0x81f0,0x6ad3,0xdb78,0x305b,0x1d1f,0xf63c, + 0x6e68,0x854b,0xa80f,0x432c,0xf287,0x19a4,0x34e0,0xdfc3, + 0x1469,0xff4a,0xd20e,0x392d,0x8886,0x63a5,0x4ee1,0xa5c2, + 0x3d96,0xd6b5,0xfbf1,0x10d2,0xa179,0x4a5a,0x671e,0x8c3d, + + /* ninth byte LUT */ + 0x0000,0x6f45,0xde8a,0xb1cf,0xad35,0xc270,0x73bf,0x1cfa, + 0x4a4b,0x250e,0x94c1,0xfb84,0xe77e,0x883b,0x39f4,0x56b1, + 0x9496,0xfbd3,0x4a1c,0x2559,0x39a3,0x56e6,0xe729,0x886c, + 0xdedd,0xb198,0x0057,0x6f12,0x73e8,0x1cad,0xad62,0xc227, + 0x390d,0x5648,0xe787,0x88c2,0x9438,0xfb7d,0x4ab2,0x25f7, + 0x7346,0x1c03,0xadcc,0xc289,0xde73,0xb136,0x00f9,0x6fbc, + 0xad9b,0xc2de,0x7311,0x1c54,0x00ae,0x6feb,0xde24,0xb161, + 0xe7d0,0x8895,0x395a,0x561f,0x4ae5,0x25a0,0x946f,0xfb2a, + 0x721a,0x1d5f,0xac90,0xc3d5,0xdf2f,0xb06a,0x01a5,0x6ee0, + 0x3851,0x5714,0xe6db,0x899e,0x9564,0xfa21,0x4bee,0x24ab, + 0xe68c,0x89c9,0x3806,0x5743,0x4bb9,0x24fc,0x9533,0xfa76, + 0xacc7,0xc382,0x724d,0x1d08,0x01f2,0x6eb7,0xdf78,0xb03d, + 0x4b17,0x2452,0x959d,0xfad8,0xe622,0x8967,0x38a8,0x57ed, + 0x015c,0x6e19,0xdfd6,0xb093,0xac69,0xc32c,0x72e3,0x1da6, + 0xdf81,0xb0c4,0x010b,0x6e4e,0x72b4,0x1df1,0xac3e,0xc37b, + 0x95ca,0xfa8f,0x4b40,0x2405,0x38ff,0x57ba,0xe675,0x8930, + 0xe434,0x8b71,0x3abe,0x55fb,0x4901,0x2644,0x978b,0xf8ce, + 0xae7f,0xc13a,0x70f5,0x1fb0,0x034a,0x6c0f,0xddc0,0xb285, + 0x70a2,0x1fe7,0xae28,0xc16d,0xdd97,0xb2d2,0x031d,0x6c58, + 0x3ae9,0x55ac,0xe463,0x8b26,0x97dc,0xf899,0x4956,0x2613, + 0xdd39,0xb27c,0x03b3,0x6cf6,0x700c,0x1f49,0xae86,0xc1c3, + 0x9772,0xf837,0x49f8,0x26bd,0x3a47,0x5502,0xe4cd,0x8b88, + 0x49af,0x26ea,0x9725,0xf860,0xe49a,0x8bdf,0x3a10,0x5555, + 0x03e4,0x6ca1,0xdd6e,0xb22b,0xaed1,0xc194,0x705b,0x1f1e, + 0x962e,0xf96b,0x48a4,0x27e1,0x3b1b,0x545e,0xe591,0x8ad4, + 0xdc65,0xb320,0x02ef,0x6daa,0x7150,0x1e15,0xafda,0xc09f, + 0x02b8,0x6dfd,0xdc32,0xb377,0xaf8d,0xc0c8,0x7107,0x1e42, + 0x48f3,0x27b6,0x9679,0xf93c,0xe5c6,0x8a83,0x3b4c,0x5409, + 0xaf23,0xc066,0x71a9,0x1eec,0x0216,0x6d53,0xdc9c,0xb3d9, + 0xe568,0x8a2d,0x3be2,0x54a7,0x485d,0x2718,0x96d7,0xf992, + 0x3bb5,0x54f0,0xe53f,0x8a7a,0x9680,0xf9c5,0x480a,0x274f, + 0x71fe,0x1ebb,0xaf74,0xc031,0xdccb,0xb38e,0x0241,0x6d04, + + /* tenth byte LUT */ + 0x0000,0xd849,0xa0b3,0x78fa,0x5147,0x890e,0xf1f4,0x29bd, + 0xa28e,0x7ac7,0x023d,0xda74,0xf3c9,0x2b80,0x537a,0x8b33, + 0x553d,0x8d74,0xf58e,0x2dc7,0x047a,0xdc33,0xa4c9,0x7c80, + 0xf7b3,0x2ffa,0x5700,0x8f49,0xa6f4,0x7ebd,0x0647,0xde0e, + 0xaa7a,0x7233,0x0ac9,0xd280,0xfb3d,0x2374,0x5b8e,0x83c7, + 0x08f4,0xd0bd,0xa847,0x700e,0x59b3,0x81fa,0xf900,0x2149, + 0xff47,0x270e,0x5ff4,0x87bd,0xae00,0x7649,0x0eb3,0xd6fa, + 0x5dc9,0x8580,0xfd7a,0x2533,0x0c8e,0xd4c7,0xac3d,0x7474, + 0x44d5,0x9c9c,0xe466,0x3c2f,0x1592,0xcddb,0xb521,0x6d68, + 0xe65b,0x3e12,0x46e8,0x9ea1,0xb71c,0x6f55,0x17af,0xcfe6, + 0x11e8,0xc9a1,0xb15b,0x6912,0x40af,0x98e6,0xe01c,0x3855, + 0xb366,0x6b2f,0x13d5,0xcb9c,0xe221,0x3a68,0x4292,0x9adb, + 0xeeaf,0x36e6,0x4e1c,0x9655,0xbfe8,0x67a1,0x1f5b,0xc712, + 0x4c21,0x9468,0xec92,0x34db,0x1d66,0xc52f,0xbdd5,0x659c, + 0xbb92,0x63db,0x1b21,0xc368,0xead5,0x329c,0x4a66,0x922f, + 0x191c,0xc155,0xb9af,0x61e6,0x485b,0x9012,0xe8e8,0x30a1, + 0x89aa,0x51e3,0x2919,0xf150,0xd8ed,0x00a4,0x785e,0xa017, + 0x2b24,0xf36d,0x8b97,0x53de,0x7a63,0xa22a,0xdad0,0x0299, + 0xdc97,0x04de,0x7c24,0xa46d,0x8dd0,0x5599,0x2d63,0xf52a, + 0x7e19,0xa650,0xdeaa,0x06e3,0x2f5e,0xf717,0x8fed,0x57a4, + 0x23d0,0xfb99,0x8363,0x5b2a,0x7297,0xaade,0xd224,0x0a6d, + 0x815e,0x5917,0x21ed,0xf9a4,0xd019,0x0850,0x70aa,0xa8e3, + 0x76ed,0xaea4,0xd65e,0x0e17,0x27aa,0xffe3,0x8719,0x5f50, + 0xd463,0x0c2a,0x74d0,0xac99,0x8524,0x5d6d,0x2597,0xfdde, + 0xcd7f,0x1536,0x6dcc,0xb585,0x9c38,0x4471,0x3c8b,0xe4c2, + 0x6ff1,0xb7b8,0xcf42,0x170b,0x3eb6,0xe6ff,0x9e05,0x464c, + 0x9842,0x400b,0x38f1,0xe0b8,0xc905,0x114c,0x69b6,0xb1ff, + 0x3acc,0xe285,0x9a7f,0x4236,0x6b8b,0xb3c2,0xcb38,0x1371, + 0x6705,0xbf4c,0xc7b6,0x1fff,0x3642,0xee0b,0x96f1,0x4eb8, + 0xc58b,0x1dc2,0x6538,0xbd71,0x94cc,0x4c85,0x347f,0xec36, + 0x3238,0xea71,0x928b,0x4ac2,0x637f,0xbb36,0xc3cc,0x1b85, + 0x90b6,0x48ff,0x3005,0xe84c,0xc1f1,0x19b8,0x6142,0xb90b, + + /* eleventh byte LUT */ + 0x0000,0x0375,0x06ea,0x059f,0x0dd4,0x0ea1,0x0b3e,0x084b, + 0x1ba8,0x18dd,0x1d42,0x1e37,0x167c,0x1509,0x1096,0x13e3, + 0x3750,0x3425,0x31ba,0x32cf,0x3a84,0x39f1,0x3c6e,0x3f1b, + 0x2cf8,0x2f8d,0x2a12,0x2967,0x212c,0x2259,0x27c6,0x24b3, + 0x6ea0,0x6dd5,0x684a,0x6b3f,0x6374,0x6001,0x659e,0x66eb, + 0x7508,0x767d,0x73e2,0x7097,0x78dc,0x7ba9,0x7e36,0x7d43, + 0x59f0,0x5a85,0x5f1a,0x5c6f,0x5424,0x5751,0x52ce,0x51bb, + 0x4258,0x412d,0x44b2,0x47c7,0x4f8c,0x4cf9,0x4966,0x4a13, + 0xdd40,0xde35,0xdbaa,0xd8df,0xd094,0xd3e1,0xd67e,0xd50b, + 0xc6e8,0xc59d,0xc002,0xc377,0xcb3c,0xc849,0xcdd6,0xcea3, + 0xea10,0xe965,0xecfa,0xef8f,0xe7c4,0xe4b1,0xe12e,0xe25b, + 0xf1b8,0xf2cd,0xf752,0xf427,0xfc6c,0xff19,0xfa86,0xf9f3, + 0xb3e0,0xb095,0xb50a,0xb67f,0xbe34,0xbd41,0xb8de,0xbbab, + 0xa848,0xab3d,0xaea2,0xadd7,0xa59c,0xa6e9,0xa376,0xa003, + 0x84b0,0x87c5,0x825a,0x812f,0x8964,0x8a11,0x8f8e,0x8cfb, + 0x9f18,0x9c6d,0x99f2,0x9a87,0x92cc,0x91b9,0x9426,0x9753, + 0xaaa1,0xa9d4,0xac4b,0xaf3e,0xa775,0xa400,0xa19f,0xa2ea, + 0xb109,0xb27c,0xb7e3,0xb496,0xbcdd,0xbfa8,0xba37,0xb942, + 0x9df1,0x9e84,0x9b1b,0x986e,0x9025,0x9350,0x96cf,0x95ba, + 0x8659,0x852c,0x80b3,0x83c6,0x8b8d,0x88f8,0x8d67,0x8e12, + 0xc401,0xc774,0xc2eb,0xc19e,0xc9d5,0xcaa0,0xcf3f,0xcc4a, + 0xdfa9,0xdcdc,0xd943,0xda36,0xd27d,0xd108,0xd497,0xd7e2, + 0xf351,0xf024,0xf5bb,0xf6ce,0xfe85,0xfdf0,0xf86f,0xfb1a, + 0xe8f9,0xeb8c,0xee13,0xed66,0xe52d,0xe658,0xe3c7,0xe0b2, + 0x77e1,0x7494,0x710b,0x727e,0x7a35,0x7940,0x7cdf,0x7faa, + 0x6c49,0x6f3c,0x6aa3,0x69d6,0x619d,0x62e8,0x6777,0x6402, + 0x40b1,0x43c4,0x465b,0x452e,0x4d65,0x4e10,0x4b8f,0x48fa, + 0x5b19,0x586c,0x5df3,0x5e86,0x56cd,0x55b8,0x5027,0x5352, + 0x1941,0x1a34,0x1fab,0x1cde,0x1495,0x17e0,0x127f,0x110a, + 0x02e9,0x019c,0x0403,0x0776,0x0f3d,0x0c48,0x09d7,0x0aa2, + 0x2e11,0x2d64,0x28fb,0x2b8e,0x23c5,0x20b0,0x252f,0x265a, + 0x35b9,0x36cc,0x3353,0x3026,0x386d,0x3b18,0x3e87,0x3df2, + + /* twelfth byte LUT */ + 0x0000,0x4563,0x8ac6,0xcfa5,0x05ad,0x40ce,0x8f6b,0xca08, + 0x0b5a,0x4e39,0x819c,0xc4ff,0x0ef7,0x4b94,0x8431,0xc152, + 0x16b4,0x53d7,0x9c72,0xd911,0x1319,0x567a,0x99df,0xdcbc, + 0x1dee,0x588d,0x9728,0xd24b,0x1843,0x5d20,0x9285,0xd7e6, + 0x2d68,0x680b,0xa7ae,0xe2cd,0x28c5,0x6da6,0xa203,0xe760, + 0x2632,0x6351,0xacf4,0xe997,0x239f,0x66fc,0xa959,0xec3a, + 0x3bdc,0x7ebf,0xb11a,0xf479,0x3e71,0x7b12,0xb4b7,0xf1d4, + 0x3086,0x75e5,0xba40,0xff23,0x352b,0x7048,0xbfed,0xfa8e, + 0x5ad0,0x1fb3,0xd016,0x9575,0x5f7d,0x1a1e,0xd5bb,0x90d8, + 0x518a,0x14e9,0xdb4c,0x9e2f,0x5427,0x1144,0xdee1,0x9b82, + 0x4c64,0x0907,0xc6a2,0x83c1,0x49c9,0x0caa,0xc30f,0x866c, + 0x473e,0x025d,0xcdf8,0x889b,0x4293,0x07f0,0xc855,0x8d36, + 0x77b8,0x32db,0xfd7e,0xb81d,0x7215,0x3776,0xf8d3,0xbdb0, + 0x7ce2,0x3981,0xf624,0xb347,0x794f,0x3c2c,0xf389,0xb6ea, + 0x610c,0x246f,0xebca,0xaea9,0x64a1,0x21c2,0xee67,0xab04, + 0x6a56,0x2f35,0xe090,0xa5f3,0x6ffb,0x2a98,0xe53d,0xa05e, + 0xb5a0,0xf0c3,0x3f66,0x7a05,0xb00d,0xf56e,0x3acb,0x7fa8, + 0xbefa,0xfb99,0x343c,0x715f,0xbb57,0xfe34,0x3191,0x74f2, + 0xa314,0xe677,0x29d2,0x6cb1,0xa6b9,0xe3da,0x2c7f,0x691c, + 0xa84e,0xed2d,0x2288,0x67eb,0xade3,0xe880,0x2725,0x6246, + 0x98c8,0xddab,0x120e,0x576d,0x9d65,0xd806,0x17a3,0x52c0, + 0x9392,0xd6f1,0x1954,0x5c37,0x963f,0xd35c,0x1cf9,0x599a, + 0x8e7c,0xcb1f,0x04ba,0x41d9,0x8bd1,0xceb2,0x0117,0x4474, + 0x8526,0xc045,0x0fe0,0x4a83,0x808b,0xc5e8,0x0a4d,0x4f2e, + 0xef70,0xaa13,0x65b6,0x20d5,0xeadd,0xafbe,0x601b,0x2578, + 0xe42a,0xa149,0x6eec,0x2b8f,0xe187,0xa4e4,0x6b41,0x2e22, + 0xf9c4,0xbca7,0x7302,0x3661,0xfc69,0xb90a,0x76af,0x33cc, + 0xf29e,0xb7fd,0x7858,0x3d3b,0xf733,0xb250,0x7df5,0x3896, + 0xc218,0x877b,0x48de,0x0dbd,0xc7b5,0x82d6,0x4d73,0x0810, + 0xc942,0x8c21,0x4384,0x06e7,0xccef,0x898c,0x4629,0x034a, + 0xd4ac,0x91cf,0x5e6a,0x1b09,0xd101,0x9462,0x5bc7,0x1ea4, + 0xdff6,0x9a95,0x5530,0x1053,0xda5b,0x9f38,0x509d,0x15fe, + + /* thriteenth byte LUT */ + 0x0000,0x7b61,0xf6c2,0x8da3,0xfda5,0x86c4,0x0b67,0x7006, + 0xeb6b,0x900a,0x1da9,0x66c8,0x16ce,0x6daf,0xe00c,0x9b6d, + 0xc6f7,0xbd96,0x3035,0x4b54,0x3b52,0x4033,0xcd90,0xb6f1, + 0x2d9c,0x56fd,0xdb5e,0xa03f,0xd039,0xab58,0x26fb,0x5d9a, + 0x9dcf,0xe6ae,0x6b0d,0x106c,0x606a,0x1b0b,0x96a8,0xedc9, + 0x76a4,0x0dc5,0x8066,0xfb07,0x8b01,0xf060,0x7dc3,0x06a2, + 0x5b38,0x2059,0xadfa,0xd69b,0xa69d,0xddfc,0x505f,0x2b3e, + 0xb053,0xcb32,0x4691,0x3df0,0x4df6,0x3697,0xbb34,0xc055, + 0x2bbf,0x50de,0xdd7d,0xa61c,0xd61a,0xad7b,0x20d8,0x5bb9, + 0xc0d4,0xbbb5,0x3616,0x4d77,0x3d71,0x4610,0xcbb3,0xb0d2, + 0xed48,0x9629,0x1b8a,0x60eb,0x10ed,0x6b8c,0xe62f,0x9d4e, + 0x0623,0x7d42,0xf0e1,0x8b80,0xfb86,0x80e7,0x0d44,0x7625, + 0xb670,0xcd11,0x40b2,0x3bd3,0x4bd5,0x30b4,0xbd17,0xc676, + 0x5d1b,0x267a,0xabd9,0xd0b8,0xa0be,0xdbdf,0x567c,0x2d1d, + 0x7087,0x0be6,0x8645,0xfd24,0x8d22,0xf643,0x7be0,0x0081, + 0x9bec,0xe08d,0x6d2e,0x164f,0x6649,0x1d28,0x908b,0xebea, + 0x577e,0x2c1f,0xa1bc,0xdadd,0xaadb,0xd1ba,0x5c19,0x2778, + 0xbc15,0xc774,0x4ad7,0x31b6,0x41b0,0x3ad1,0xb772,0xcc13, + 0x9189,0xeae8,0x674b,0x1c2a,0x6c2c,0x174d,0x9aee,0xe18f, + 0x7ae2,0x0183,0x8c20,0xf741,0x8747,0xfc26,0x7185,0x0ae4, + 0xcab1,0xb1d0,0x3c73,0x4712,0x3714,0x4c75,0xc1d6,0xbab7, + 0x21da,0x5abb,0xd718,0xac79,0xdc7f,0xa71e,0x2abd,0x51dc, + 0x0c46,0x7727,0xfa84,0x81e5,0xf1e3,0x8a82,0x0721,0x7c40, + 0xe72d,0x9c4c,0x11ef,0x6a8e,0x1a88,0x61e9,0xec4a,0x972b, + 0x7cc1,0x07a0,0x8a03,0xf162,0x8164,0xfa05,0x77a6,0x0cc7, + 0x97aa,0xeccb,0x6168,0x1a09,0x6a0f,0x116e,0x9ccd,0xe7ac, + 0xba36,0xc157,0x4cf4,0x3795,0x4793,0x3cf2,0xb151,0xca30, + 0x515d,0x2a3c,0xa79f,0xdcfe,0xacf8,0xd799,0x5a3a,0x215b, + 0xe10e,0x9a6f,0x17cc,0x6cad,0x1cab,0x67ca,0xea69,0x9108, + 0x0a65,0x7104,0xfca7,0x87c6,0xf7c0,0x8ca1,0x0102,0x7a63, + 0x27f9,0x5c98,0xd13b,0xaa5a,0xda5c,0xa13d,0x2c9e,0x57ff, + 0xcc92,0xb7f3,0x3a50,0x4131,0x3137,0x4a56,0xc7f5,0xbc94, + + /* fourteenth byte LUT */ + 0x0000,0xaefc,0x4dd9,0xe325,0x9bb2,0x354e,0xd66b,0x7897, + 0x2745,0x89b9,0x6a9c,0xc460,0xbcf7,0x120b,0xf12e,0x5fd2, + 0x4e8a,0xe076,0x0353,0xadaf,0xd538,0x7bc4,0x98e1,0x361d, + 0x69cf,0xc733,0x2416,0x8aea,0xf27d,0x5c81,0xbfa4,0x1158, + 0x9d14,0x33e8,0xd0cd,0x7e31,0x06a6,0xa85a,0x4b7f,0xe583, + 0xba51,0x14ad,0xf788,0x5974,0x21e3,0x8f1f,0x6c3a,0xc2c6, + 0xd39e,0x7d62,0x9e47,0x30bb,0x482c,0xe6d0,0x05f5,0xab09, + 0xf4db,0x5a27,0xb902,0x17fe,0x6f69,0xc195,0x22b0,0x8c4c, + 0x2a09,0x84f5,0x67d0,0xc92c,0xb1bb,0x1f47,0xfc62,0x529e, + 0x0d4c,0xa3b0,0x4095,0xee69,0x96fe,0x3802,0xdb27,0x75db, + 0x6483,0xca7f,0x295a,0x87a6,0xff31,0x51cd,0xb2e8,0x1c14, + 0x43c6,0xed3a,0x0e1f,0xa0e3,0xd874,0x7688,0x95ad,0x3b51, + 0xb71d,0x19e1,0xfac4,0x5438,0x2caf,0x8253,0x6176,0xcf8a, + 0x9058,0x3ea4,0xdd81,0x737d,0x0bea,0xa516,0x4633,0xe8cf, + 0xf997,0x576b,0xb44e,0x1ab2,0x6225,0xccd9,0x2ffc,0x8100, + 0xded2,0x702e,0x930b,0x3df7,0x4560,0xeb9c,0x08b9,0xa645, + 0x5412,0xfaee,0x19cb,0xb737,0xcfa0,0x615c,0x8279,0x2c85, + 0x7357,0xddab,0x3e8e,0x9072,0xe8e5,0x4619,0xa53c,0x0bc0, + 0x1a98,0xb464,0x5741,0xf9bd,0x812a,0x2fd6,0xccf3,0x620f, + 0x3ddd,0x9321,0x7004,0xdef8,0xa66f,0x0893,0xebb6,0x454a, + 0xc906,0x67fa,0x84df,0x2a23,0x52b4,0xfc48,0x1f6d,0xb191, + 0xee43,0x40bf,0xa39a,0x0d66,0x75f1,0xdb0d,0x3828,0x96d4, + 0x878c,0x2970,0xca55,0x64a9,0x1c3e,0xb2c2,0x51e7,0xff1b, + 0xa0c9,0x0e35,0xed10,0x43ec,0x3b7b,0x9587,0x76a2,0xd85e, + 0x7e1b,0xd0e7,0x33c2,0x9d3e,0xe5a9,0x4b55,0xa870,0x068c, + 0x595e,0xf7a2,0x1487,0xba7b,0xc2ec,0x6c10,0x8f35,0x21c9, + 0x3091,0x9e6d,0x7d48,0xd3b4,0xab23,0x05df,0xe6fa,0x4806, + 0x17d4,0xb928,0x5a0d,0xf4f1,0x8c66,0x229a,0xc1bf,0x6f43, + 0xe30f,0x4df3,0xaed6,0x002a,0x78bd,0xd641,0x3564,0x9b98, + 0xc44a,0x6ab6,0x8993,0x276f,0x5ff8,0xf104,0x1221,0xbcdd, + 0xad85,0x0379,0xe05c,0x4ea0,0x3637,0x98cb,0x7bee,0xd512, + 0x8ac0,0x243c,0xc719,0x69e5,0x1172,0xbf8e,0x5cab,0xf257, + + /* fifteenth byte LUT */ + 0x0000,0xa824,0x4069,0xe84d,0x80d2,0x28f6,0xc0bb,0x689f, + 0x1185,0xb9a1,0x51ec,0xf9c8,0x9157,0x3973,0xd13e,0x791a, + 0x230a,0x8b2e,0x6363,0xcb47,0xa3d8,0x0bfc,0xe3b1,0x4b95, + 0x328f,0x9aab,0x72e6,0xdac2,0xb25d,0x1a79,0xf234,0x5a10, + 0x4614,0xee30,0x067d,0xae59,0xc6c6,0x6ee2,0x86af,0x2e8b, + 0x5791,0xffb5,0x17f8,0xbfdc,0xd743,0x7f67,0x972a,0x3f0e, + 0x651e,0xcd3a,0x2577,0x8d53,0xe5cc,0x4de8,0xa5a5,0x0d81, + 0x749b,0xdcbf,0x34f2,0x9cd6,0xf449,0x5c6d,0xb420,0x1c04, + 0x8c28,0x240c,0xcc41,0x6465,0x0cfa,0xa4de,0x4c93,0xe4b7, + 0x9dad,0x3589,0xddc4,0x75e0,0x1d7f,0xb55b,0x5d16,0xf532, + 0xaf22,0x0706,0xef4b,0x476f,0x2ff0,0x87d4,0x6f99,0xc7bd, + 0xbea7,0x1683,0xfece,0x56ea,0x3e75,0x9651,0x7e1c,0xd638, + 0xca3c,0x6218,0x8a55,0x2271,0x4aee,0xe2ca,0x0a87,0xa2a3, + 0xdbb9,0x739d,0x9bd0,0x33f4,0x5b6b,0xf34f,0x1b02,0xb326, + 0xe936,0x4112,0xa95f,0x017b,0x69e4,0xc1c0,0x298d,0x81a9, + 0xf8b3,0x5097,0xb8da,0x10fe,0x7861,0xd045,0x3808,0x902c, + 0x0871,0xa055,0x4818,0xe03c,0x88a3,0x2087,0xc8ca,0x60ee, + 0x19f4,0xb1d0,0x599d,0xf1b9,0x9926,0x3102,0xd94f,0x716b, + 0x2b7b,0x835f,0x6b12,0xc336,0xaba9,0x038d,0xebc0,0x43e4, + 0x3afe,0x92da,0x7a97,0xd2b3,0xba2c,0x1208,0xfa45,0x5261, + 0x4e65,0xe641,0x0e0c,0xa628,0xceb7,0x6693,0x8ede,0x26fa, + 0x5fe0,0xf7c4,0x1f89,0xb7ad,0xdf32,0x7716,0x9f5b,0x377f, + 0x6d6f,0xc54b,0x2d06,0x8522,0xedbd,0x4599,0xadd4,0x05f0, + 0x7cea,0xd4ce,0x3c83,0x94a7,0xfc38,0x541c,0xbc51,0x1475, + 0x8459,0x2c7d,0xc430,0x6c14,0x048b,0xacaf,0x44e2,0xecc6, + 0x95dc,0x3df8,0xd5b5,0x7d91,0x150e,0xbd2a,0x5567,0xfd43, + 0xa753,0x0f77,0xe73a,0x4f1e,0x2781,0x8fa5,0x67e8,0xcfcc, + 0xb6d6,0x1ef2,0xf6bf,0x5e9b,0x3604,0x9e20,0x766d,0xde49, + 0xc24d,0x6a69,0x8224,0x2a00,0x429f,0xeabb,0x02f6,0xaad2, + 0xd3c8,0x7bec,0x93a1,0x3b85,0x531a,0xfb3e,0x1373,0xbb57, + 0xe147,0x4963,0xa12e,0x090a,0x6195,0xc9b1,0x21fc,0x89d8, + 0xf0c2,0x58e6,0xb0ab,0x188f,0x7010,0xd834,0x3079,0x985d, }; uint16_t crc16(const char *buf, int len) { - int counter; + int counter = 0; uint16_t crc = 0; - for (counter = 0; counter < len; counter++) - crc = (crc<<8) ^ crc16tab[((crc>>8) ^ *buf++)&0x00FF]; + + for(; counter + 15 < len; counter += 16) { + /* explicitly get sixteen bytes */ + uint16_t a = (uint8_t)buf[counter]; + uint16_t b = (uint8_t)buf[counter + 1]; + + uint16_t c = (uint8_t)buf[counter + 2]; + uint16_t d = (uint8_t)buf[counter + 3]; + + uint16_t e = (uint8_t)buf[counter + 4]; + uint16_t f = (uint8_t)buf[counter + 5]; + + uint16_t g = (uint8_t)buf[counter + 6]; + uint16_t h = (uint8_t)buf[counter + 7]; + + uint16_t i = (uint8_t)buf[counter + 8]; + uint16_t j = (uint8_t)buf[counter + 9]; + + uint16_t k = (uint8_t)buf[counter + 10]; + uint16_t l = (uint8_t)buf[counter + 11]; + + uint16_t m = (uint8_t)buf[counter + 12]; + uint16_t n = (uint8_t)buf[counter + 13]; + + uint16_t o = (uint8_t)buf[counter + 14]; + uint16_t p = (uint8_t)buf[counter + 15]; + + + crc = crc16tab[15 * 256 + (uint8_t)(p)] ^ + crc16tab[14 * 256 + (uint8_t)(o)] ^ + crc16tab[13 * 256 + (uint8_t)(n)] ^ + crc16tab[12 * 256 + (uint8_t)(m)] ^ + crc16tab[11 * 256 + (uint8_t)(l)] ^ + crc16tab[10 * 256 + (uint8_t)(k)] ^ + crc16tab[9 * 256 + (uint8_t)(j)] ^ + crc16tab[8 * 256 + (uint8_t)(i)] ^ + crc16tab[7 * 256 + (uint8_t)(h)] ^ + crc16tab[6 * 256 + (uint8_t)(g)] ^ + crc16tab[5 * 256 + (uint8_t)(f)] ^ + crc16tab[4 * 256 + (uint8_t)(e)] ^ + crc16tab[3 * 256 + (uint8_t)(d)] ^ + crc16tab[2 * 256 + (uint8_t)(c)] ^ + crc16tab[1 * 256 + (uint8_t)(b ^ crc)] ^ + crc16tab[0 * 256 + (uint8_t)(a ^ (crc >> 8))]; + } + + for(; counter + 7 < len; counter += 8) { + /* explicitly get eight bytes */ + uint16_t a = (uint8_t)buf[counter]; + uint16_t b = (uint8_t)buf[counter + 1]; + + uint16_t c = (uint8_t)buf[counter + 2]; + uint16_t d = (uint8_t)buf[counter + 3]; + + uint16_t e = (uint8_t)buf[counter + 4]; + uint16_t f = (uint8_t)buf[counter + 5]; + + uint16_t g = (uint8_t)buf[counter + 6]; + uint16_t h = (uint8_t)buf[counter + 7]; + + crc = crc16tab[7 * 256 + (uint8_t)(h)] ^ + crc16tab[6 * 256 + (uint8_t)(g)] ^ + crc16tab[5 * 256 + (uint8_t)(f)] ^ + crc16tab[4 * 256 + (uint8_t)(e)] ^ + crc16tab[3 * 256 + (uint8_t)(d)] ^ + crc16tab[2 * 256 + (uint8_t)(c)] ^ + crc16tab[1 * 256 + (uint8_t)(b ^ crc)] ^ + crc16tab[0 * 256 + (uint8_t)(a ^ (crc >> 8))]; + } + + for(; counter + 3 < len; counter += 4) { + /* explicitly get four bytes */ + uint16_t a = (uint8_t)buf[counter]; + uint16_t b = (uint8_t)buf[counter + 1]; + uint16_t c = (uint8_t)buf[counter + 2]; + uint16_t d = (uint8_t)buf[counter + 3]; + + crc = crc16tab[3 * 256 + (uint8_t)(d)] ^ + crc16tab[2 * 256 + (uint8_t)(c)] ^ + crc16tab[1 * 256 + (uint8_t)(b ^ crc)] ^ + crc16tab[0 * 256 + (uint8_t)(a ^ (crc >> 8))]; + } + + for(; counter + 1 < len; counter += 2) { + /* explicitly get two bytes */ + uint16_t a = buf[counter]; + uint16_t b = buf[counter + 1]; + uint16_t tmp = ((a << 8) | b); + + crc ^= tmp; + // fit LITTLE-ENDIAN architecture + crc = crc16tab[1 * 256 + (uint8_t)(crc >> 8)] ^ crc16tab[0 * 256 + (uint8_t)(crc >> 0)]; + } + + // deal with leftover + for(; counter < len; counter++) + crc = (crc << 8) ^ crc16tab[((crc >> 8) ^ (uint8_t)buf[counter]) & 0x00FF]; return crc; } diff --git a/src/unit/test_crc16.c b/src/unit/test_crc16.c new file mode 100644 index 0000000000..3c97b1cc97 --- /dev/null +++ b/src/unit/test_crc16.c @@ -0,0 +1,85 @@ +#include +#include +#include "../crc16.c" + +#include "test_help.h" + +/* CRC16 implementation according to CCITT standards. + * + * Note by @antirez: this is actually the XMODEM CRC 16 algorithm, using the + * following parameters: + * + * Name : "XMODEM", also known as "ZMODEM", "CRC-16/ACORN" + * Width : 16 bit + * Poly : 1021 (That is actually x^16 + x^12 + x^5 + 1) + * Initialization : 0000 + * Reflect Input byte : False + * Reflect Output CRC : False + * Xor constant to output CRC : 0000 + * Output for "123456789" : 31C3 + */ + +static const uint16_t tbl[256] = { + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, + 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, + 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, + 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, + 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, + 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, + 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, + 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, + 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, + 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, + 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, + 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, + 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, + 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, + 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, + 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, + 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, + 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, + 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, + 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, + 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, + 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, + 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0}; + +uint16_t crc16_ref(const char *buf, int len) { + int counter; + uint16_t crc = 0; + for (counter = 0; counter < len; counter++) + crc = (crc << 8) ^ tbl[((crc >> 8) ^ *buf++) & 0x00FF]; + return crc; +} + +int test_crc16(int argc, char **argv, int flags) { + UNUSED(argc); + UNUSED(argv); + UNUSED(flags); + + const char *s = "123456789"; + int len = strlen(s); + TEST_ASSERT(crc16(s, len) == crc16_ref(s, len)); + + const char *twenty = "aeiouAEIOUbcdefBEEF"; + len = strlen(twenty); + TEST_ASSERT(crc16(twenty, len) == crc16_ref(twenty, len)); + + // Test all permutation of bits in a byte + for (uint16_t i = 0; i <= 0xff; i++) { + char input[1]; + input[0] = (char)i; + int sz = sizeof(input); + TEST_ASSERT(crc16(input, sz) == crc16_ref(input, sz)); + } + return 0; +} diff --git a/src/unit/test_files.h b/src/unit/test_files.h index ca557984be..6686245c3c 100644 --- a/src/unit/test_files.h +++ b/src/unit/test_files.h @@ -7,6 +7,7 @@ typedef struct unitTest { } unitTest; int test_popcount(int argc, char **argv, int flags); +int test_crc16(int argc, char **argv, int flags); int test_crc64(int argc, char **argv, int flags); int test_crc64combine(int argc, char **argv, int flags); int test_dictCreate(int argc, char **argv, int flags); @@ -256,6 +257,7 @@ int test_zmallocAllocReallocCallocAndFree(int argc, char **argv, int flags); int test_zmallocAllocZeroByteAndFree(int argc, char **argv, int flags); unitTest __test_bitops_c[] = {{"test_popcount", test_popcount}, {NULL, NULL}}; +unitTest __test_crc16_c[] = {{"test_crc16", test_crc16}, {NULL, NULL}}; unitTest __test_crc64_c[] = {{"test_crc64", test_crc64}, {NULL, NULL}}; unitTest __test_crc64combine_c[] = {{"test_crc64combine", test_crc64combine}, {NULL, NULL}}; unitTest __test_dict_c[] = {{"test_dictCreate", test_dictCreate}, {"test_dictAdd16Keys", test_dictAdd16Keys}, {"test_dictDisableResize", test_dictDisableResize}, {"test_dictAddOneKeyTriggerResize", test_dictAddOneKeyTriggerResize}, {"test_dictDeleteKeys", test_dictDeleteKeys}, {"test_dictDeleteOneKeyTriggerResize", test_dictDeleteOneKeyTriggerResize}, {"test_dictEmptyDirAdd128Keys", test_dictEmptyDirAdd128Keys}, {"test_dictDisableResizeReduceTo3", test_dictDisableResizeReduceTo3}, {"test_dictDeleteOneKeyTriggerResizeAgain", test_dictDeleteOneKeyTriggerResizeAgain}, {"test_dictBenchmark", test_dictBenchmark}, {NULL, NULL}}; @@ -285,6 +287,7 @@ struct unitTestSuite { unitTest *tests; } unitTestSuite[] = { {"test_bitops.c", __test_bitops_c}, + {"test_crc16.c", __test_crc16_c}, {"test_crc64.c", __test_crc64_c}, {"test_crc64combine.c", __test_crc64combine_c}, {"test_dict.c", __test_dict_c},