diff options
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/airpdcap_wep.c | 2 | ||||
-rw-r--r-- | wsutil/crc32.c | 15 | ||||
-rw-r--r-- | wsutil/crc32.h | 16 | ||||
-rw-r--r-- | wsutil/libwsutil.def | 2 |
4 files changed, 24 insertions, 11 deletions
diff --git a/wsutil/airpdcap_wep.c b/wsutil/airpdcap_wep.c index 6689535885..29d7d44743 100644 --- a/wsutil/airpdcap_wep.c +++ b/wsutil/airpdcap_wep.c @@ -77,7 +77,7 @@ int AirPDcapWepDecrypt( j = (j + S[i]) & 0xff; S_SWAP(i, j); *cypher_text ^= S[(S[i] + S[j]) & 0xff]; - crc = crc32_ccitt_table[(crc ^ *cypher_text) & 0xff] ^ (crc >> 8); + crc = crc32_ccitt_table_lookup((crc ^ *cypher_text) & 0xff) ^ (crc >> 8); cypher_text++; } diff --git a/wsutil/crc32.c b/wsutil/crc32.c index c40047dffe..5882ba9f5c 100644 --- a/wsutil/crc32.c +++ b/wsutil/crc32.c @@ -53,6 +53,8 @@ /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ /* */ /*****************************************************************/ +#define CRC32C(c,d) (c=(c>>8)^crc32c_table[(c^(d))&0xFF]) + static const guint32 crc32c_table[256] = { 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, 0x8AD958CFL, 0x78B2DBCCL, @@ -115,7 +117,7 @@ static const guint32 crc32c_table[256] = { * x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^8 + x^7 + * x^5 + x^4 + x^2 + x + 1 */ -const guint32 crc32_ccitt_table[256] = { +static const guint32 crc32_ccitt_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, @@ -193,6 +195,17 @@ crc32c_calculate(const void *buf, int len, guint32 crc) return CRC32C_SWAP(crc); } +guint32 +crc32c_calculate_no_swap(const void *buf, int len, guint32 crc) +{ + const guint8 *p = (const guint8 *)buf; + while (len-- > 0) { + CRC32C(crc, *p++); + } + + return crc; +} + guint32 crc32_ccitt(const guint8 *buf, guint len) { diff --git a/wsutil/crc32.h b/wsutil/crc32.h index 514a437596..bb998d1c6e 100644 --- a/wsutil/crc32.h +++ b/wsutil/crc32.h @@ -41,14 +41,6 @@ extern "C" { ((crc32c_value & 0x0000ff00) << 8) | \ ((crc32c_value & 0x000000ff) << 24)) -#define CRC32C(c,d) (c=(c>>8)^crc32c_table_lookup((c^(d))&0xFF)) - -extern const guint32 crc32_ccitt_table[256]; - -/** Lookup the crc value in the crc32c_table - @param pos Position in the table. */ -extern guint32 crc32c_table_lookup (guchar pos); - /** Lookup the crc value in the crc32_ccitt_table @param pos Position in the table. */ extern guint32 crc32_ccitt_table_lookup (guchar pos); @@ -60,6 +52,14 @@ extern guint32 crc32_ccitt_table_lookup (guchar pos); @return The CRC32C checksum. */ extern guint32 crc32c_calculate(const void *buf, int len, guint32 crc); +/** Compute CRC32C checksum of a buffer of data without swapping seed crc + or completed checksum + @param buf The buffer containing the data. + @param len The number of bytes to include in the computation. + @param crc The preload value for the CRC32C computation. + @return The CRC32C checksum. */ +extern guint32 crc32c_calculate_no_swap(const void *buf, int len, guint32 crc); + /** Compute CRC32 CCITT checksum of a buffer of data. @param buf The buffer containing the data. @param len The number of bytes to include in the computation. diff --git a/wsutil/libwsutil.def b/wsutil/libwsutil.def index 70ef7bb78e..19f2e2b676 100644 --- a/wsutil/libwsutil.def +++ b/wsutil/libwsutil.def @@ -30,7 +30,7 @@ crc32_ccitt crc32_ccitt_seed crc32_ccitt_table_lookup crc32c_calculate -crc32c_table_lookup +crc32c_calculate_no_swap ; crcdrm.c crc_drm |