stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256 Class Reference

SHA-256 Message Digest implementation class. More...

#include <stx-cbtreedb.h>

List of all members.

Public Member Functions

 SHA256 ()
 SHA_256 / MDx_HashFunction Constructor.
void clear () throw ()
 Clear memory of sensitive data.
SHA256update (const void *input, uint32_t length)
 Update this SHA256 calculation with new data.
void final (byte output[OUTPUT_LENGTH])
 Return final SHA256 digest of this object in the buffer.
std::string final ()
 Return final SHA256 digest of this object as a string.
bool final_equals (byte compare[OUTPUT_LENGTH])
 Returns true if the final SHA256 digest of this object equals the given data.
std::string final_hex ()
 Return final SHA256 digest of this object as a string encoded in hexadecimal.

Static Public Member Functions

static std::string digest_bin (const void *input, uint32_t length)
 Calculate SHA256 digest of bytes in the given range.
static std::string digest_bin (const std::string &input)
 Calculate SHA256 digest of a string.
static std::string digest_hex (const void *input, uint32_t length)
 Calculate SHA256 digest of bytes in the given range.
static std::string digest_hex (const std::string &input)
 Calculate SHA256 digest of a string.

Protected Member Functions

void add_data (const byte input[], u32bit length)
 Update the hash.
void write_count (byte out[])
 Write the count bits to the buffer.
void final_result (byte output[OUTPUT_LENGTH])
 Finalize a Hash.

Private Types

typedef uint8_t byte
 local typedef from Botan library
typedef uint32_t u32bit
 local typedef from Botan library
typedef uint64_t u64bit
 local typedef from Botan library

Private Member Functions

template<typename T >
rotate_left (T input, u32bit rot)
 Rotation Functions.
template<typename T >
rotate_right (T input, u32bit rot)
 Rotation Functions.
template<typename T >
byte get_byte (u32bit byte_num, T input)
 Byte Extraction Function.
u32bit make_u32bit (byte input0, byte input1, byte input2, byte input3)
 Byte to Word Conversions.
u32bit rho (u32bit X, u32bit rot1, u32bit rot2, u32bit rot3)
 SHA-256 Rho Function.
u32bit sigma (u32bit X, u32bit rot1, u32bit rot2, u32bit shift)
 SHA-256 Sigma Function.
void F1 (u32bit A, u32bit B, u32bit C, u32bit &D, u32bit E, u32bit F, u32bit G, u32bit &H, u32bit msg, u32bit magic)
 SHA-256 F1 Function.
void hash (const byte input[])
 SHA-256 Compression Function.
void copy_out (byte output[])
 Copy out the digest.

Private Attributes

u32bit W [64]
u32bit digest [8]
byte buffer [HASH_BLOCK_SIZE]
u64bit count
u32bit position

Static Private Attributes

static const u32bit OUTPUT_LENGTH = 32
 length of the resulting digest
static const u32bit HASH_BLOCK_SIZE = 64
 block of bytes to process in hash function
static const u32bit COUNT_SIZE = 8
 length of size suffix hashed during finalization

Detailed Description

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
class stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256

SHA-256 Message Digest implementation class.

Copied from the Botan-1.6.4 cryptography library.

Definition at line 453 of file stx-cbtreedb.h.


Member Typedef Documentation

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
typedef uint8_t stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::byte [private]

local typedef from Botan library

Definition at line 457 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
typedef uint32_t stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::u32bit [private]

local typedef from Botan library

Definition at line 460 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
typedef uint64_t stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::u64bit [private]

local typedef from Botan library

Definition at line 463 of file stx-cbtreedb.h.


Constructor & Destructor Documentation

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::SHA256 (  )  [inline]

SHA_256 / MDx_HashFunction Constructor.

Definition at line 678 of file stx-cbtreedb.h.


Member Function Documentation

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::add_data ( const byte  input[],
u32bit  length 
) [inline, protected]

Update the hash.

Definition at line 618 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::clear (  )  throw () [inline]

Clear memory of sensitive data.

Definition at line 684 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::copy_out ( byte  output[]  )  [inline, private]

Copy out the digest.

Definition at line 609 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
static std::string stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::digest_bin ( const std::string &  input  )  [inline, static]

Calculate SHA256 digest of a string.

Definition at line 760 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
static std::string stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::digest_bin ( const void *  input,
uint32_t  length 
) [inline, static]

Calculate SHA256 digest of bytes in the given range.

Definition at line 754 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
static std::string stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::digest_hex ( const std::string &  input  )  [inline, static]

Calculate SHA256 digest of a string.

Result is encoded in hexadecimal.

Definition at line 774 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
static std::string stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::digest_hex ( const void *  input,
uint32_t  length 
) [inline, static]

Calculate SHA256 digest of bytes in the given range.

Result is encoded in hexadecimal.

Definition at line 767 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::F1 ( u32bit  A,
u32bit  B,
u32bit  C,
u32bit D,
u32bit  E,
u32bit  F,
u32bit  G,
u32bit H,
u32bit  msg,
u32bit  magic 
) [inline, private]

SHA-256 F1 Function.

Definition at line 516 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
std::string stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::final (  )  [inline]

Return final SHA256 digest of this object as a string.

Definition at line 714 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::final ( byte  output[OUTPUT_LENGTH]  )  [inline]

Return final SHA256 digest of this object in the buffer.

Definition at line 708 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
bool stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::final_equals ( byte  compare[OUTPUT_LENGTH]  )  [inline]

Returns true if the final SHA256 digest of this object equals the given data.

Definition at line 723 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
std::string stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::final_hex (  )  [inline]

Return final SHA256 digest of this object as a string encoded in hexadecimal.

Definition at line 732 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::final_result ( byte  output[OUTPUT_LENGTH]  )  [inline, protected]

Finalize a Hash.

Definition at line 659 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
template<typename T >
byte stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::get_byte ( u32bit  byte_num,
input 
) [inline, private]

Byte Extraction Function.

Definition at line 493 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::hash ( const byte  input[]  )  [inline, private]

SHA-256 Compression Function.

Definition at line 526 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
u32bit stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::make_u32bit ( byte  input0,
byte  input1,
byte  input2,
byte  input3 
) [inline, private]

Byte to Word Conversions.

Definition at line 497 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
u32bit stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::rho ( u32bit  X,
u32bit  rot1,
u32bit  rot2,
u32bit  rot3 
) [inline, private]

SHA-256 Rho Function.

Definition at line 503 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
template<typename T >
T stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::rotate_left ( input,
u32bit  rot 
) [inline, private]

Rotation Functions.

Definition at line 485 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
template<typename T >
T stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::rotate_right ( input,
u32bit  rot 
) [inline, private]

Rotation Functions.

Definition at line 489 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
u32bit stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::sigma ( u32bit  X,
u32bit  rot1,
u32bit  rot2,
u32bit  shift 
) [inline, private]

SHA-256 Sigma Function.

Definition at line 510 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
SHA256& stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::update ( const void *  input,
uint32_t  length 
) [inline]

Update this SHA256 calculation with new data.

Definition at line 701 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::write_count ( byte  out[]  )  [inline, protected]

Write the count bits to the buffer.

Definition at line 650 of file stx-cbtreedb.h.


Member Data Documentation

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
byte stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::buffer[HASH_BLOCK_SIZE] [private]

Definition at line 478 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
u64bit stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::count [private]

Definition at line 480 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
const u32bit stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::COUNT_SIZE = 8 [static, private]

length of size suffix hashed during finalization

Definition at line 472 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
u32bit stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::digest[8] [private]

Definition at line 476 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
const u32bit stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::HASH_BLOCK_SIZE = 64 [static, private]

block of bytes to process in hash function

Definition at line 469 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
const u32bit stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::OUTPUT_LENGTH = 32 [static, private]

length of the resulting digest

Definition at line 466 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
u32bit stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::position [private]

Definition at line 481 of file stx-cbtreedb.h.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
u32bit stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::SHA256::W[64] [private]

Definition at line 475 of file stx-cbtreedb.h.


The documentation for this class was generated from the following file:
Generated on Wed Apr 14 13:43:42 2010 for stx-cbtreedb by  doxygen 1.6.3