CRC Class Reference

#include <crc.h>

Inheritance diagram for CRC:

Inheritance graph
Collaboration diagram for CRC:

Collaboration graph

Detailed Description

Implementation of the IEEE 32-bit CRC.

Usage flow:
  CRC()      // construct CRC object                             
  add()      // call as many times as necessary to process data
  final()    // finalize computation
  sum()      // obtain 32-bit CRC value

Recommendations for strict FIPS 140-1 compliance:
  CRC-32 is not a FIPS approved algorithm, so the CRC class should
  *NOT* be used for cryptographic operations.

Sample code illustrating the use of this class appears in the Cookbook section Using the Message Digest Functions.

Technical Information and References

The generator polynomial used for this implementation is:

x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1

as specified in the following standards: Autodin II, IEEE 802.3 (Ethernet), ISO/IEC-3309 (HDLC), RFC 1662 (PPP), and RFC 1952 (GZIP).


Public Member Functions

 CRC (int v=1)
 Constructor.
 ~CRC ()
 Destructor. Calls clear().
void add (int count, const char *s)
 Update CRC with contents of buffer.
void add (char c)
 Update CRC with a single byte.
void final (void)
 Perform final masking operation.
unsigned int sum () const
 Get final CRC value.
int length () const
 Get size of CRC value in bytes.
template<class T>
to () const
 Convert 32-bit CRC value to type T.
str tostr () const
 Convert 32-bit CRC value to a str.
void clear (void)
 Clear CRC object.
void reset (void)
 Reset CRC object. Alias for clear().


Constructor & Destructor Documentation

CRC ( int  v = 1  )  [inline]

Constructor.

Parameters:
v unused, but facilitates the use of templates.
Remarks:
Modifies: a = mask, byte count = 0; i.e., the object is reset to its initial state.


Member Function Documentation

void add ( char  c  )  [inline]

Update CRC with a single byte.

Parameters:
c byte to include in the CRC value being computed
Remarks:
This call updates the internal CRC value.

void add ( int  count,
const char *  s 
)

Update CRC with contents of buffer.

Parameters:
count length of input buffer in bytes
s pointer to input buffer
Remarks:
This call updates the internal CRC value.

void clear ( void   )  [inline]

Clear CRC object.

Remarks:
Modifies: a = mask, byte count = 0; i.e., the object is reset to its initial state.

void final ( void   )  [inline]

Perform final masking operation.

Remarks:
CRC value is updated by xoring with the mask.

void reset ( void   )  [inline]

Reset CRC object. Alias for clear().

Remarks:
Modifies: a = mask, byte count = 0; i.e., the object is reset to its initial state.

unsigned int sum (  )  const [inline]

Get final CRC value.

Returns:
the CRC value as an unsigned int.

T to (  )  const [inline]

Convert 32-bit CRC value to type T.

Returns:
an object of type T representing the 32-bit CRC value.

str tostr (  )  const

Convert 32-bit CRC value to a str.

Returns:
a str containing a string representation of the 32-bit CRC value.


The documentation for this class was generated from the following file:
ISC Cryptographic Development Kit - User's Guide
ISC website
Questions? E-mail ISC technical support
Copyright© 2002-2006 Information Security Corp. All rights reserved.