Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

CRC32Hash Class Reference

CRC32 checksum (POSIX.2; not a cryptographically secure hash). More...

#include <crc32hash.h>

Inheritance diagram for CRC32Hash:

Inheritance graph
[legend]
Collaboration diagram for CRC32Hash:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CRC32Hash ()
 Constructor for CRC32 checksum.

 ~CRC32Hash ()
 Destructor cleans up the hash state.

const Parameters * GetPar () const
 Get parameters of this hash algo; see base clas.

uint64 FedBytes () const
 Returns number of fed bytes; see base class.

void reset ()
 Reset has algo; see base class.

void feed (const char *buf, size_t len)
 Feed the hash algo with data; see base class.

void final ()
 Finish hash computation; see base class.

void GetHash (char *buf) const
 Get current has value; see base class.


Static Public Attributes

const Parameters par
 Parameters of the hash algo.


Private Member Functions

 CRC32Hash (const CRC32Hash &)
 Do not use these:.

void operator= (const CRC32Hash &)

Private Attributes

uint32 state
 hash status; hash value


Static Private Attributes

const uint32 crc32table [256]
 1kb CRC precomputed table. This is static and used read-only.


Detailed Description

CRC32 checksum (POSIX.2; not a cryptographically secure hash).

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
The CRC32 algorithm provides a quite good way for data modification checks when e.g. transmitting files over insecure lines. It is not cryptographically secure, i.e. a malicious party can quite easily create two data sets with the same CRC32 checksum but with 4 bytes of length and an enormous speed (compared to the crypto hashes) it provides a nice way to check data against "non-malicious", "random" modifications.

This implementation of the class uses an internal CRC32 hash table of the size 1024 bytes. However, the table is const and static (compiled-in) [i.e. thread-safe].

NOTE: This class is NOT "C++-safe" and you should generally be careful with cryptographic data, so it is best to manage (de)allocation of these objects in a higher order.

Definition at line 52 of file crc32hash.h.


Constructor & Destructor Documentation

CRC32Hash::CRC32Hash const CRC32Hash  )  [private]
 

Do not use these:.

CRC32Hash::CRC32Hash  )  [inline]
 

Constructor for CRC32 checksum.

Definition at line 70 of file crc32hash.h.

References reset().

CRC32Hash::~CRC32Hash  )  [inline]
 

Destructor cleans up the hash state.

Definition at line 73 of file crc32hash.h.

References reset().


Member Function Documentation

uint64 CRC32Hash::FedBytes  )  const [inline, virtual]
 

Returns number of fed bytes; see base class.

Reimplemented from SecureHashBase.

Definition at line 81 of file crc32hash.h.

References uint64.

void CRC32Hash::feed const char *  buf,
size_t  len
[virtual]
 

Feed the hash algo with data; see base class.

Reimplemented from SecureHashBase.

Definition at line 136 of file crc32hash.cc.

References state, and uint32.

void CRC32Hash::final  )  [virtual]
 

Finish hash computation; see base class.

Reimplemented from SecureHashBase.

Definition at line 148 of file crc32hash.cc.

References state, and uint64.

void CRC32Hash::GetHash char *  buf  )  const [virtual]
 

Get current has value; see base class.

Reimplemented from SecureHashBase.

Definition at line 115 of file crc32hash.cc.

References state, and uint32.

const Parameters* CRC32Hash::GetPar  )  const [inline, virtual]
 

Get parameters of this hash algo; see base clas.

Reimplemented from SecureHashBase.

Definition at line 77 of file crc32hash.h.

References par.

void CRC32Hash::operator= const CRC32Hash  )  [private]
 

void CRC32Hash::reset  )  [virtual]
 

Reset has algo; see base class.

Reimplemented from SecureHashBase.

Definition at line 126 of file crc32hash.cc.

References Assert, crc32table, and state.

Referenced by CRC32Hash(), and ~CRC32Hash().


Member Data Documentation

const uint32 CRC32Hash::crc32table [static, private]
 

1kb CRC precomputed table. This is static and used read-only.

Definition at line 35 of file crc32hash.cc.

Referenced by reset().

const SecureHashBase::Parameters CRC32Hash::par [static]
 

Initial value:

{
    INIT_FIELD(hash_size) 4,
    INIT_FIELD(block_size) 4,
    INIT_FIELD(hash_ID) 0x3000,
    INIT_FIELD(name) "CRC32"
}
Parameters of the hash algo.

Reimplemented from SecureHashBase.

Definition at line 27 of file crc32hash.cc.

Referenced by GetPar().

uint32 CRC32Hash::state [private]
 

hash status; hash value

Definition at line 59 of file crc32hash.h.

Referenced by feed(), final(), GetHash(), and reset().


The documentation for this class was generated from the following files:
Generated on Sat Feb 19 22:35:24 2005 for Ray by doxygen 1.3.5