crc32.h File Reference

#include <stdint.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
u32 crc32_le (u32 seed, const void *data, size_t len)
 Calculate 32-bit little-endian CRC checksum.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

u32 crc32_le ( u32  seed,
const void *  data,
size_t  len 
)

Calculate 32-bit little-endian CRC checksum.

Parameters:
seed Initial value
data Data to checksum
len Length of data
Usually seed is initially zero or all one bits, depending on the protocol. To continue a CRC checksum over multiple calls, pass the return value from one call as the seed parameter to the next.

Definition at line 38 of file crc32.c.

References CRCPOLY, src, u32, and u8.

Referenced by tkip_decrypt(), tkip_encrypt(), wep_decrypt(), and wep_encrypt().

00039 {
00040         u32 crc = seed;
00041         const u8 *src = data;
00042         u32 mult;
00043         int i;
00044 
00045         while ( len-- ) {
00046                 crc ^= *src++;
00047                 for ( i = 0; i < 8; i++ ) {
00048                         mult = ( crc & 1 ) ? CRCPOLY : 0;
00049                         crc = ( crc >> 1 ) ^ mult;
00050                 }
00051         }
00052 
00053         return crc;
00054 }


Generated on Tue Apr 6 20:01:48 2010 for gPXE by  doxygen 1.5.7.1