#include <CPipeSHA1.h>
Inheritance diagram for AxPipe::Stock::CPipeSHA1:
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. |
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.
|
Initialize crypto context etc. Acquire a Crypto Context to use Definition at line 38 of file CPipeSHA1.cpp. |
|
Destroy the hash, if any and release the Crypto Context, if any. Definition at line 47 of file CPipeSHA1.cpp. |
|
Get total number of bytes processed for the hash.
Definition at line 67 of file CPipeSHA1.cpp. References m_cb. |
|
Get a pointer to the hash itself, 20 bytes.
Definition at line 74 of file CPipeSHA1.cpp. References AxPipe::Stock::TBits< 160 >::GetLeft(), and m_Hash. |
|
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.
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(). |
|
Finalize the hash. Finalize and get the hash data into the buffer, and destroy the hash context.
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(). |
|
Create and initialize the hash. Create the hash.
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(). |