Index of /pub/users/uss/ohs/crc32

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory   -  
[TXT]INSTALL.html 2003-11-17 16:58 1.4K 
[   ]chksum32.tar.gz 2003-11-17 17:01 20K 
[   ]chksum32.zip.OLD 2003-11-05 12:33 28K 

Checksum32 README

Checksum32 README

This package includes a C implementation of the CRC32 algorithm used by P2PP to check the integrity of parameter (PAF) files. Its results are compatible with those generated by the methods in class java.util.zip.CRC32 of the Java Runtime Environment.

To include a checksum in a parameter file:
  1. Read the file into a buffer. The file should contain an empty checksum line, i.e.:
        PAF.CHCK.CHECKSUM    ""	
  2. Pass the buffer to function crc32(), defined in crc32.c. The function's return value is the needed checksum value. See the following example:
        #define ONEMEGA (1024*1024) 
    
        int fd;
        uLong chksum;
        char buffer[ ONEMEGA ];
        ssize_t len = 0;
    
        fd = open( "file.paf", O_RDONLY );
        len = read( fd, buffer, ONEMEGA );
        chksum = crc32( 0, buffer, len ); /* first arg is always zero */
  3. Convert the checksum value to a string (remember that the checksum is unsigned!), and edit the checksum line to include it; e.g.
        PAF.CHCK.CHECKSUM    "482575795"	
  4. Save the buffer to a disk file.
When the user tries to attach a parameter file to a Template parameter, P2PP performs the opposite procedure; if the (re)computed value does not match the value of the PAF.CHCK.CHECKSUM keyword in the parameter file, P2PP will assume the file was corrupted and reject it.

Note: the CRC32 algorithm is platform-independent, but is indeed sensitive to whitespace. If a parameter file is transfered across platforms the line termination characters may change; this will happen for instance when transferring files between Linux and Windows via FTP, using ASCII mode. In that case CRC recomputation may fail although the user may think they didn't "edit" the file.
User Support Systems team
Last modified: Mon Nov 17 17:56:27 MET 2003