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

AxPipe::Stock::CPipeSHA1 Class Reference

A pass-through strainer, calculating an SHA1 on-the-fly. More...

#include <CPipeSHA1.h>

Inheritance diagram for AxPipe::Stock::CPipeSHA1:

Inheritance graph
[legend]
Collaboration diagram for AxPipe::Stock::CPipeSHA1:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CPipeSHA1 ()
 Initialize crypto context etc.

virtual ~CPipeSHA1 ()
unsigned __int64 CountBytes ()
 Get total number of bytes processed for the hash.

unsigned char * GetHash ()
 Get a pointer to the hash itself, 20 bytes.


Protected Member Functions

void Out (AxPipe::CSeg *pSeg)
 Consume the given segment, guaranteed to be non-NULL and non-zero-length.

bool OutOpen ()
 Create and initialize the hash.

bool OutClose ()
 Finalize the hash.


Protected Attributes

HCRYPTPROV m_hCryptProv
 Provider handle, init in constructor.

HCRYPTHASH m_hHash
 Handle to the hash, init in OutOpen.

TBits< 160 > m_Hash
 SHA1 is 160 bits long.


Private Attributes

unsigned __int64 m_cb
 Total bytes process in the hash.


Detailed Description

A pass-through strainer, calculating an SHA1 on-the-fly.

You get the checksum by calling the GetHash() and the length of data hashed by calling CountBytes(). It can be used to calculate hashes for different parts of the stream by opening and closing with Open() and Close() respectively.

The Windows CryptoAPI implementation is actually quite a bit faster than the common public domain C implementation, it also occupies less space, so its used here.

Definition at line 47 of file CPipeSHA1.h.


Constructor & Destructor Documentation

AxPipe::Stock::CPipeSHA1::CPipeSHA1  ) 
 

Initialize crypto context etc.

Acquire a Crypto Context to use

Definition at line 38 of file CPipeSHA1.cpp.

AxPipe::Stock::CPipeSHA1::~CPipeSHA1  )  [virtual]
 

Destroy the hash, if any and release the Crypto Context, if any.

Definition at line 47 of file CPipeSHA1.cpp.


Member Function Documentation

unsigned __int64 AxPipe::Stock::CPipeSHA1::CountBytes  ) 
 

Get total number of bytes processed for the hash.

Returns:
The number of bytes hashed.

Definition at line 67 of file CPipeSHA1.cpp.

References m_cb.

unsigned char * AxPipe::Stock::CPipeSHA1::GetHash  ) 
 

Get a pointer to the hash itself, 20 bytes.

Returns:
A pointer to the resulting hash, always 160 bits/20 bytes for SHA1.

Definition at line 74 of file CPipeSHA1.cpp.

References AxPipe::Stock::TBits< 160 >::GetLeft(), and m_Hash.

void AxPipe::Stock::CPipeSHA1::Out AxPipe::CSeg pSeg  )  [protected, virtual]
 

Consume the given segment, guaranteed to be non-NULL and non-zero-length.

Add the contents of the segment to the hash, count the bytes, and send the data onwards, unchanged.

Parameters:
pSeg The segment to hash.

Implements AxPipe::CPipe.

Reimplemented in AxPipe::Stock::CPipeHMAC_SHA1< iBits >.

Definition at line 56 of file CPipeSHA1.cpp.

References _T, AxPipe::CSeg::Len(), m_cb, m_hHash, AxPipe::CSeg::PtrRd(), AxPipe::CPipe::Pump(), and AxPipe::CError::SetError().

bool AxPipe::Stock::CPipeSHA1::OutClose void   )  [protected, virtual]
 

Finalize the hash.

Finalize and get the hash data into the buffer, and destroy the hash context.

Returns:
true if the Close() call should be propagated.

Reimplemented from AxPipe::CPipe.

Reimplemented in AxPipe::Stock::CPipeHMAC_SHA1< iBits >.

Definition at line 94 of file CPipeSHA1.cpp.

References _T, ASSAPI, m_Hash, m_hHash, and AxPipe::CError::SetError().

bool AxPipe::Stock::CPipeSHA1::OutOpen  )  [protected, virtual]
 

Create and initialize the hash.

Create the hash.

Returns:
true, if we see no reason not to propagate the Open() call

Reimplemented from AxPipe::CPipe.

Reimplemented in AxPipe::Stock::CPipeHMAC_SHA1< iBits >.

Definition at line 81 of file CPipeSHA1.cpp.

References _T, m_cb, m_hCryptProv, m_hHash, and AxPipe::CError::SetError().


The documentation for this class was generated from the following files:
Generated on Mon Feb 2 13:19:30 2004 for AxPipe by doxygen 1.3.5