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

SecureHashBase Class Reference

Hash algorithm base class. More...

#include <shashbase.h>

Inheritance diagram for SecureHashBase:

Inheritance graph
[legend]
Collaboration diagram for SecureHashBase:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SecureHashBase ()
 Constructor; a no-op here.

virtual ~SecureHashBase ()
 Destructor must clean up the hash state.

virtual const ParametersGetPar () const
 Returns a pointer to the (normally static) parameters of this hash algorithm.

virtual uint64 FedBytes () const
 Returns how many bytes were already fed (using feed()) since the last reset().

virtual void reset ()
 Reset the hash; delete the current hash value (as returned by GetHash()).

virtual void feed (const char *buf, size_t len)
 Feed the hash algo with data.

virtual void final ()
 Do the final computing of the hash value (padding...).

virtual void GetHash (char *buf) const
 Query the (current) hash value /message digest.


Static Public Attributes

const Parameters par

Protected Attributes

uint64 length
 length of hashed data in BYTES.


Private Member Functions

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

void operator= (const SecureHashBase &)

Detailed Description

Hash algorithm base class.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
This is a base class for (mostly cryptographic) hash / message digest algorithms.

If no derived class is used but this class itself, a null-hash (which is always 0) is used.

How to compute a message digest / hash value:

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 51 of file shashbase.h.


Constructor & Destructor Documentation

SecureHashBase::SecureHashBase const SecureHashBase  )  [private]
 

Do not use these:.

SecureHashBase::SecureHashBase  )  [inline]
 

Constructor; a no-op here.

Definition at line 77 of file shashbase.h.

References length.

virtual SecureHashBase::~SecureHashBase  )  [inline, virtual]
 

Destructor must clean up the hash state.

Definition at line 79 of file shashbase.h.


Member Function Documentation

uint64 SecureHashBase::FedBytes  )  const [virtual]
 

Returns how many bytes were already fed (using feed()) since the last reset().

Reimplemented in CRC32Hash, RMD160Hash, SHA0Hash, and SHA1Hash.

Definition at line 29 of file shashbase.cc.

References length, and uint64.

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

Feed the hash algo with data.

Input the passed data into the hash algorithm and go on computing the hash value.

buf does not have to be aligned.

Note:
Things are normally faster, if (len%GetPar()->block_size)=0, i.e. the length is always a multiple of the block size.

Reimplemented in CRC32Hash, RMD160Hash, SHA0Hash, and SHA1Hash.

Definition at line 41 of file shashbase.cc.

References length.

Referenced by test_hash().

void SecureHashBase::final  )  [virtual]
 

Do the final computing of the hash value (padding...).

This needs to be done before querying the has value using GetHash().

Reimplemented in CRC32Hash, RMD160Hash, SHA0Hash, and SHA1Hash.

Definition at line 47 of file shashbase.cc.

Referenced by test_hash().

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

Query the (current) hash value /message digest.

Should call final() before doing this; otherwise there may be some not-yet-processed input bytes pending.

Make sure that your buffer can hold enough (hash_size) bytes. buf does not have to be aligned.

Reimplemented in CRC32Hash, RMD160Hash, SHA0Hash, and SHA1Hash.

Definition at line 52 of file shashbase.cc.

Referenced by test_hash().

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

Returns a pointer to the (normally static) parameters of this hash algorithm.

The returned pointer may only be used in read-only manner.

It may point to memory allocated by the hash class as the pointer may not be used after the class was destroyed.

Reimplemented in CRC32Hash, RMD160Hash, SHA0Hash, and SHA1Hash.

Definition at line 90 of file shashbase.h.

References par.

Referenced by test_hash().

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

void SecureHashBase::reset  )  [virtual]
 

Reset the hash; delete the current hash value (as returned by GetHash()).

Reimplemented in CRC32Hash, RMD160Hash, SHA0Hash, and SHA1Hash.

Definition at line 35 of file shashbase.cc.

References length.

Referenced by test_hash().


Member Data Documentation

uint64 SecureHashBase::length [protected]
 

length of hashed data in BYTES.

Definition at line 69 of file shashbase.h.

Referenced by FedBytes(), feed(), reset(), and SecureHashBase().

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

Initial value:

 
{
    INIT_FIELD(hash_size) 1,
    INIT_FIELD(block_size) 1,
    INIT_FIELD(hash_ID) 0x0000,
    INIT_FIELD(name) "null"
}
Parameters of the hash algo; every derived class must provide its own _static_ parameter description.

Reimplemented in CRC32Hash, RMD160Hash, SHA0Hash, and SHA1Hash.

Definition at line 20 of file shashbase.cc.

Referenced by GetPar().


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