STANAG 5066 DTS will follow when it passes review, just trying to make the patch more manageable.

svn path=/trunk/; revision=52774
This commit is contained in:
Michael Mann 2013-10-22 23:30:26 +00:00
parent 02a8e72b43
commit cbd3194bcf
8 changed files with 186 additions and 0 deletions

View File

@ -114,3 +114,13 @@ guint16 crc16_plain_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guin
return crc16_plain_finalize(crc);
}
guint16 crc16_0x9949_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 seed)
{
const guint8 *buf;
tvb_ensure_bytes_exist(tvb, offset, len); /* len == -1 not allowed */
buf = tvb_get_ptr(tvb, offset, len);
return crc16_0x9949_seed(buf, len, seed);
}

View File

@ -105,6 +105,18 @@ WS_DLL_PUBLIC guint16 crc16_plain_tvb_offset(tvbuff_t *tvb, guint offset, guint
@return The CRC16 checksum. */
WS_DLL_PUBLIC guint16 crc16_plain_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 crc);
/** Compute CRC16 checksum of a tv buffer using the parameters
* Width = 16 bits
* Poly = 0x9949
* Reflection = true
* Algorithm = table-driven
@param tvb The tv buffer containing the data.
@param offset The offset into the tv buffer.
@param len The number of bytes to include in the computation.
@param seed The seed to use.
@return The CRC16 checksum. */
WS_DLL_PUBLIC guint16 crc16_0x9949_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 seed);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -131,3 +131,14 @@ crc32_mpeg2_tvb_seed(tvbuff_t *tvb, guint len, guint32 seed)
{
return ( crc32_mpeg2_tvb_offset_seed(tvb, 0, len, seed) );
}
guint32 crc32_0x0AA725CF_tvb_offset_seed(tvbuff_t *tvb,
guint offset, guint len, guint32 seed)
{
const guint8 *buf;
tvb_ensure_bytes_exist(tvb, offset, len); /* len == -1 not allowed */
buf = tvb_get_ptr(tvb, offset, len);
return crc32_0x0AA725CF_seed(buf, len, seed);
}

View File

@ -99,6 +99,20 @@ WS_DLL_PUBLIC guint32 crc32_mpeg2_tvb_seed(tvbuff_t *tvb, guint len, guint32 see
@return The CRC32 MPEG-2 checksum (using the given seed). */
WS_DLL_PUBLIC guint32 crc32_mpeg2_tvb_offset_seed(tvbuff_t *tvb, guint offset,
guint len, guint32 seed);
/** Compute CRC32 checksum of a tv buffer using the parameters
* Width = 32 bits
* Poly = 0x0AA725CF
* Reflection = true
* Algorithm = table-driven
@param tvb The tv buffer containing the data.
@param offset The offset into the tv buffer.
@param len The number of bytes to include in the computation.
@param seed The seed to use.
@return The CRC32 checksum. */
WS_DLL_PUBLIC guint32 crc32_0x0AA725CF_tvb_offset_seed(tvbuff_t *tvb,
guint offset, guint len, guint32 seed);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -222,6 +222,43 @@ static const guint crc16_precompiled_755B[] =
0x9bc5, 0xee9e, 0x7173, 0x0428, 0x3bf2, 0x4ea9, 0xd144, 0xa41f /* 0xF8 */
};
/* This table was compiled using the polynom: 0x9949 */
static const guint crc16_precompiled_9949_reverse[] =
{
0x0000, 0x0ED2, 0x1DA4, 0x1376, 0x3B48, 0x359A, 0x26EC, 0x283E,
0x7690, 0x7842, 0x6B34, 0x65E6, 0x4DD8, 0x430A, 0x507C, 0x5EAE,
0xED20, 0xE3F2, 0xF084, 0xFE56, 0xD668, 0xD8BA, 0xCBCC, 0xC51E,
0x9BB0, 0x9562, 0x8614, 0x88C6, 0xA0F8, 0xAE2A, 0xBD5C, 0xB38E,
0xFF73, 0xF1A1, 0xE2D7, 0xEC05, 0xC43B, 0xCAE9, 0xD99F, 0xD74D,
0x89E3, 0x8731, 0x9447, 0x9A95, 0xB2AB, 0xBC79, 0xAF0F, 0xA1DD,
0x1253, 0x1C81, 0x0FF7, 0x0125, 0x291B, 0x27C9, 0x34BF, 0x3A6D,
0x64C3, 0x6A11, 0x7967, 0x77B5, 0x5F8B, 0x5159, 0x422F, 0x4CFD,
0xDBD5, 0xD507, 0xC671, 0xC8A3, 0xE09D, 0xEE4F, 0xFD39, 0xF3EB,
0xAD45, 0xA397, 0xB0E1, 0xBE33, 0x960D, 0x98DF, 0x8BA9, 0x857B,
0x36F5, 0x3827, 0x2B51, 0x2583, 0x0DBD, 0x036F, 0x1019, 0x1ECB,
0x4065, 0x4EB7, 0x5DC1, 0x5313, 0x7B2D, 0x75FF, 0x6689, 0x685B,
0x24A6, 0x2A74, 0x3902, 0x37D0, 0x1FEE, 0x113C, 0x024A, 0x0C98,
0x5236, 0x5CE4, 0x4F92, 0x4140, 0x697E, 0x67AC, 0x74DA, 0x7A08,
0xC986, 0xC754, 0xD422, 0xDAF0, 0xF2CE, 0xFC1C, 0xEF6A, 0xE1B8,
0xBF16, 0xB1C4, 0xA2B2, 0xAC60, 0x845E, 0x8A8C, 0x99FA, 0x9728,
0x9299, 0x9C4B, 0x8F3D, 0x81EF, 0xA9D1, 0xA703, 0xB475, 0xBAA7,
0xE409, 0xEADB, 0xF9AD, 0xF77F, 0xDF41, 0xD193, 0xC2E5, 0xCC37,
0x7FB9, 0x716B, 0x621D, 0x6CCF, 0x44F1, 0x4A23, 0x5955, 0x5787,
0x0929, 0x07FB, 0x148D, 0x1A5F, 0x3261, 0x3CB3, 0x2FC5, 0x2117,
0x6DEA, 0x6338, 0x704E, 0x7E9C, 0x56A2, 0x5870, 0x4B06, 0x45D4,
0x1B7A, 0x15A8, 0x06DE, 0x080C, 0x2032, 0x2EE0, 0x3D96, 0x3344,
0x80CA, 0x8E18, 0x9D6E, 0x93BC, 0xBB82, 0xB550, 0xA626, 0xA8F4,
0xF65A, 0xF888, 0xEBFE, 0xE52C, 0xCD12, 0xC3C0, 0xD0B6, 0xDE64,
0x494C, 0x479E, 0x54E8, 0x5A3A, 0x7204, 0x7CD6, 0x6FA0, 0x6172,
0x3FDC, 0x310E, 0x2278, 0x2CAA, 0x0494, 0x0A46, 0x1930, 0x17E2,
0xA46C, 0xAABE, 0xB9C8, 0xB71A, 0x9F24, 0x91F6, 0x8280, 0x8C52,
0xD2FC, 0xDC2E, 0xCF58, 0xC18A, 0xE9B4, 0xE766, 0xF410, 0xFAC2,
0xB63F, 0xB8ED, 0xAB9B, 0xA549, 0x8D77, 0x83A5, 0x90D3, 0x9E01,
0xC0AF, 0xCE7D, 0xDD0B, 0xD3D9, 0xFBE7, 0xF535, 0xE643, 0xE891,
0x5B1F, 0x55CD, 0x46BB, 0x4869, 0x6057, 0x6E85, 0x7DF3, 0x7321,
0x2D8F, 0x235D, 0x302B, 0x3EF9, 0x16C7, 0x1815, 0x0B63, 0x05B1
};
static const guint16 crc16_ccitt_start = 0xFFFF;
static const guint16 crc16_ccitt_xorout = 0xFFFF;
@ -285,3 +322,7 @@ guint16 crc16_0x755B(const guint8 *buf, guint32 len, guint16 seed)
return crc16_unreflected(buf, len, seed, crc16_precompiled_755B);
}
guint16 crc16_0x9949_seed(const guint8 *buf, guint len, guint16 seed)
{
return crc16_reflected(buf, len, seed, crc16_precompiled_9949_reverse);
}

View File

@ -81,6 +81,15 @@ WS_DLL_PUBLIC guint16 crc16_0x5935(const guint8 *buf, guint32 len, guint16 seed)
*/
WS_DLL_PUBLIC guint16 crc16_0x755B(const guint8 *buf, guint32 len, guint16 seed);
/** Computes CRC16 checksum for the given data with the polynom 0x9949 using
* precompiled CRC table
* @param buf a pointer to a buffer of the given length
* @param len the length of the given buffer
* @param seed The seed to use.
* @return the CRC16 checksum for the buffer
*/
WS_DLL_PUBLIC guint16 crc16_0x9949_seed(const guint8 *buf, guint len, guint16 seed);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -224,6 +224,74 @@ static const guint32 crc32_mpeg2_table[256] = {
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
};
/* This table was compiled using the polynom: 0x0AA725CF*/
static const guint crc32_0AA725CF_reverse[] = {
0x00000000L, 0xCEAA95CEL, 0x7A1CE13DL, 0xB4B674F3L,
0xF439C27AL, 0x3A9357B4L, 0x8E252347L, 0x408FB689L,
0x0F3A4E55L, 0xC190DB9BL, 0x7526AF68L, 0xBB8C3AA6L,
0xFB038C2FL, 0x35A919E1L, 0x811F6D12L, 0x4FB5F8DCL,
0x1E749CAAL, 0xD0DE0964L, 0x64687D97L, 0xAAC2E859L,
0xEA4D5ED0L, 0x24E7CB1EL, 0x9051BFEDL, 0x5EFB2A23L,
0x114ED2FFL, 0xDFE44731L, 0x6B5233C2L, 0xA5F8A60CL,
0xE5771085L, 0x2BDD854BL, 0x9F6BF1B8L, 0x51C16476L,
0x3CE93954L, 0xF243AC9AL, 0x46F5D869L, 0x885F4DA7L,
0xC8D0FB2EL, 0x067A6EE0L, 0xB2CC1A13L, 0x7C668FDDL,
0x33D37701L, 0xFD79E2CFL, 0x49CF963CL, 0x876503F2L,
0xC7EAB57BL, 0x094020B5L, 0xBDF65446L, 0x735CC188L,
0x229DA5FEL, 0xEC373030L, 0x588144C3L, 0x962BD10DL,
0xD6A46784L, 0x180EF24AL, 0xACB886B9L, 0x62121377L,
0x2DA7EBABL, 0xE30D7E65L, 0x57BB0A96L, 0x99119F58L,
0xD99E29D1L, 0x1734BC1FL, 0xA382C8ECL, 0x6D285D22L,
0x79D272A8L, 0xB778E766L, 0x03CE9395L, 0xCD64065BL,
0x8DEBB0D2L, 0x4341251CL, 0xF7F751EFL, 0x395DC421L,
0x76E83CFDL, 0xB842A933L, 0x0CF4DDC0L, 0xC25E480EL,
0x82D1FE87L, 0x4C7B6B49L, 0xF8CD1FBAL, 0x36678A74L,
0x67A6EE02L, 0xA90C7BCCL, 0x1DBA0F3FL, 0xD3109AF1L,
0x939F2C78L, 0x5D35B9B6L, 0xE983CD45L, 0x2729588BL,
0x689CA057L, 0xA6363599L, 0x1280416AL, 0xDC2AD4A4L,
0x9CA5622DL, 0x520FF7E3L, 0xE6B98310L, 0x281316DEL,
0x453B4BFCL, 0x8B91DE32L, 0x3F27AAC1L, 0xF18D3F0FL,
0xB1028986L, 0x7FA81C48L, 0xCB1E68BBL, 0x05B4FD75L,
0x4A0105A9L, 0x84AB9067L, 0x301DE494L, 0xFEB7715AL,
0xBE38C7D3L, 0x7092521DL, 0xC42426EEL, 0x0A8EB320L,
0x5B4FD756L, 0x95E54298L, 0x2153366BL, 0xEFF9A3A5L,
0xAF76152CL, 0x61DC80E2L, 0xD56AF411L, 0x1BC061DFL,
0x54759903L, 0x9ADF0CCDL, 0x2E69783EL, 0xE0C3EDF0L,
0xA04C5B79L, 0x6EE6CEB7L, 0xDA50BA44L, 0x14FA2F8AL,
0xF3A4E550L, 0x3D0E709EL, 0x89B8046DL, 0x471291A3L,
0x079D272AL, 0xC937B2E4L, 0x7D81C617L, 0xB32B53D9L,
0xFC9EAB05L, 0x32343ECBL, 0x86824A38L, 0x4828DFF6L,
0x08A7697FL, 0xC60DFCB1L, 0x72BB8842L, 0xBC111D8CL,
0xEDD079FAL, 0x237AEC34L, 0x97CC98C7L, 0x59660D09L,
0x19E9BB80L, 0xD7432E4EL, 0x63F55ABDL, 0xAD5FCF73L,
0xE2EA37AFL, 0x2C40A261L, 0x98F6D692L, 0x565C435CL,
0x16D3F5D5L, 0xD879601BL, 0x6CCF14E8L, 0xA2658126L,
0xCF4DDC04L, 0x01E749CAL, 0xB5513D39L, 0x7BFBA8F7L,
0x3B741E7EL, 0xF5DE8BB0L, 0x4168FF43L, 0x8FC26A8DL,
0xC0779251L, 0x0EDD079FL, 0xBA6B736CL, 0x74C1E6A2L,
0x344E502BL, 0xFAE4C5E5L, 0x4E52B116L, 0x80F824D8L,
0xD13940AEL, 0x1F93D560L, 0xAB25A193L, 0x658F345DL,
0x250082D4L, 0xEBAA171AL, 0x5F1C63E9L, 0x91B6F627L,
0xDE030EFBL, 0x10A99B35L, 0xA41FEFC6L, 0x6AB57A08L,
0x2A3ACC81L, 0xE490594FL, 0x50262DBCL, 0x9E8CB872L,
0x8A7697F8L, 0x44DC0236L, 0xF06A76C5L, 0x3EC0E30BL,
0x7E4F5582L, 0xB0E5C04CL, 0x0453B4BFL, 0xCAF92171L,
0x854CD9ADL, 0x4BE64C63L, 0xFF503890L, 0x31FAAD5EL,
0x71751BD7L, 0xBFDF8E19L, 0x0B69FAEAL, 0xC5C36F24L,
0x94020B52L, 0x5AA89E9CL, 0xEE1EEA6FL, 0x20B47FA1L,
0x603BC928L, 0xAE915CE6L, 0x1A272815L, 0xD48DBDDBL,
0x9B384507L, 0x5592D0C9L, 0xE124A43AL, 0x2F8E31F4L,
0x6F01877DL, 0xA1AB12B3L, 0x151D6640L, 0xDBB7F38EL,
0xB69FAEACL, 0x78353B62L, 0xCC834F91L, 0x0229DA5FL,
0x42A66CD6L, 0x8C0CF918L, 0x38BA8DEBL, 0xF6101825L,
0xB9A5E0F9L, 0x770F7537L, 0xC3B901C4L, 0x0D13940AL,
0x4D9C2283L, 0x8336B74DL, 0x3780C3BEL, 0xF92A5670L,
0xA8EB3206L, 0x6641A7C8L, 0xD2F7D33BL, 0x1C5D46F5L,
0x5CD2F07CL, 0x927865B2L, 0x26CE1141L, 0xE864848FL,
0xA7D17C53L, 0x697BE99DL, 0xDDCD9D6EL, 0x136708A0L,
0x53E8BE29L, 0x9D422BE7L, 0x29F45F14L, 0xE75ECADAL
};
guint32
crc32c_table_lookup (guchar pos)
{
@ -289,3 +357,15 @@ crc32_mpeg2_seed(const guint8 *buf, guint len, guint32 seed)
return ( crc32 );
}
guint32
crc32_0x0AA725CF_seed(const guint8 *buf, guint len, guint32 seed)
{
guint crc32;
crc32 = (guint)seed;
while( len-- != 0 )
crc32 = crc32_0AA725CF_reverse[(crc32 ^ *buf++) & 0xff] ^ (crc32 >> 8);
return (guint32)crc32;
}

View File

@ -89,6 +89,15 @@ WS_DLL_PUBLIC guint32 crc32_ccitt_seed(const guint8 *buf, guint len, guint32 see
@return The CRC32 MPEG-2 checksum (using the given seed). */
WS_DLL_PUBLIC guint32 crc32_mpeg2_seed(const guint8 *buf, guint len, guint32 seed);
/** Computes CRC32 checksum for the given data with the polynom 0x0AA725CF using
* precompiled CRC table
* @param buf a pointer to a buffer of the given length
* @param len the length of the given buffer
* @param seed The seed to use.
* @return the CRC32 checksum for the buffer
*/
WS_DLL_PUBLIC guint32 crc32_0x0AA725CF_seed(const guint8 *buf, guint len, guint32 seed);
WS_DLL_PUBLIC int AirPDcapWepDecrypt(
const guchar *seed,
const size_t seed_len,