sha2 Class Reference

#include <sha2.h>

List of all members.

Public Types

enum  SHA_TYPE {
  enuSHA_NONE, enuSHA1, enuSHA160 = enuSHA1,
  enuSHA224, enuSHA256, enuSHA384,
  enuSHA512, enuSHA_LAST
}

Public Member Functions

 sha2 ()
SHA_TYPE GetEnumType ()
bool IsBigEndian ()
const char * GetTypeString ()
void Init (SHA_TYPE type)
void Update (const sha_byte *data, size_t len)
void End ()
const std::stringGetHash (SHA_TYPE type, const sha_byte *data, size_t len)
const char * HexHash ()
const std::stringStringHash ()
const char * RawHash (int &length)

Private Member Functions

void SHA256_Internal_Last (bool isSha1=false)
void SHA512_Internal_Last ()
void SHA1_Internal_Transform (const sha_word32 *data)
void SHA256_Internal_Transform (const sha_word32 *data)
 * SHA-256: ********************************************************
void SHA512_Internal_Transform (const sha_word64 *)
void SHA32bit_Update (const sha_byte *data, size_t len, bool isSha1=false)
void SHA64bit_Update (const sha_byte *data, size_t len)
void MEMSET_BZERO (void *p, size_t l)
void MEMCPY_BCOPY (void *d, const void *s, size_t l)
void ADDINC128 (sha_word64 *w, sha_word32 n)
sha_word32 SHR (sha_word32 b, sha_word32 x)
sha_word64 SHR (sha_word64 b, sha_word64 x)
sha_word32 ROTR32 (sha_word32 b, sha_word32 x)
sha_word64 ROTR64 (sha_word64 b, sha_word64 x)
sha_word32 ROTL32 (sha_word32 b, sha_word32 x)
sha_word32 Ch (sha_word32 x, sha_word32 y, sha_word32 z)
sha_word64 Ch (sha_word64 x, sha_word64 y, sha_word64 z)
sha_word32 Maj (sha_word32 x, sha_word32 y, sha_word32 z)
sha_word64 Maj (sha_word64 x, sha_word64 y, sha_word64 z)
sha_word32 Parity (sha_word32 x, sha_word32 y, sha_word32 z)
sha_word32 Sigma0_256 (sha_word32 x)
sha_word32 Sigma1_256 (sha_word32 x)
sha_word32 sigma0_256 (sha_word32 x)
sha_word32 sigma1_256 (sha_word32 x)
sha_word64 Sigma0_512 (sha_word64 x)
sha_word64 Sigma1_512 (sha_word64 x)
sha_word64 sigma0_512 (sha_word64 x)
sha_word64 sigma1_512 (sha_word64 x)
void REVERSE32 (sha_word32 w, sha_word32 &x)
void REVERSE64 (sha_word64 w, sha_word64 &x)

Private Attributes

SHA_TYPE m_Type
std::string m_strHash
bool m_boolEnded
bool m_boolIsBigEndian
char m_chrRawHash [SHA512_DIGESTC_LENGTH]
char m_chrHexHash [SHA512_DIGESTC_STRING_LENGTH]
sha_byte m_digest [SHA512_DIGESTC_LENGTH]
struct sha2::SHA_CTX ctx

Classes

struct  SHA_CTX


Detailed Description

Definition at line 72 of file sha2.h.


Member Enumeration Documentation

enum sha2::SHA_TYPE

Enumerator:
enuSHA_NONE 
enuSHA1 
enuSHA160 
enuSHA224 
enuSHA256 
enuSHA384 
enuSHA512 
enuSHA_LAST 

Definition at line 74 of file sha2.h.


Constructor & Destructor Documentation

sha2::sha2 (  )  [inline]

Definition at line 85 of file sha2.h.

References enuSHA_NONE, m_boolEnded, m_boolIsBigEndian, m_chrHexHash, m_chrRawHash, m_digest, m_Type, SHA512_DIGESTC_LENGTH, and SHA512_DIGESTC_STRING_LENGTH.


Member Function Documentation

SHA_TYPE sha2::GetEnumType (  )  [inline]

Definition at line 106 of file sha2.h.

References m_Type.

bool sha2::IsBigEndian (  )  [inline]

Definition at line 107 of file sha2.h.

References m_boolIsBigEndian.

const char* sha2::GetTypeString (  )  [inline]

Definition at line 108 of file sha2.h.

References enuSHA1, enuSHA224, enuSHA256, enuSHA384, enuSHA512, and m_Type.

void sha2::Init ( SHA_TYPE  type  ) 

Definition at line 559 of file sha2.cpp.

References ctx, enuSHA1, enuSHA224, enuSHA256, enuSHA384, enuSHA512, m_boolEnded, m_Type, MEMCPY_BCOPY(), MEMSET_BZERO(), sha1_initial_hash_value, sha224_initial_hash_value, sha256_initial_hash_value, sha384_initial_hash_value, sha512_initial_hash_value, and sha2::SHA_CTX::state.

Referenced by GetHash().

void sha2::Update ( const sha_byte data,
size_t  len 
)

Definition at line 574 of file sha2.cpp.

References enuSHA1, enuSHA224, enuSHA256, enuSHA384, enuSHA512, m_Type, SHA32bit_Update(), and SHA64bit_Update().

Referenced by GetHash().

void sha2::End (  ) 

Definition at line 586 of file sha2.cpp.

References ctx, enuSHA1, enuSHA224, enuSHA256, enuSHA384, enuSHA512, m_boolEnded, m_boolIsBigEndian, m_chrHexHash, m_digest, m_strHash, m_Type, MEMCPY_BCOPY(), SHA1_DIGESTC_LENGTH, SHA224_DIGESTC_LENGTH, SHA256_DIGESTC_LENGTH, SHA256_Internal_Last(), SHA384_DIGESTC_LENGTH, SHA512_DIGESTC_LENGTH, SHA512_Internal_Last(), sha_hex_digits, and sha2::SHA_CTX::state.

Referenced by GetHash().

const string & sha2::GetHash ( SHA_TYPE  type,
const sha_byte data,
size_t  len 
)

Definition at line 646 of file sha2.cpp.

References End(), Init(), m_strHash, and Update().

Referenced by SecureID::MakeID().

const char * sha2::HexHash (  ) 

Definition at line 655 of file sha2.cpp.

References m_boolEnded, and m_strHash.

const string & sha2::StringHash (  ) 

Definition at line 659 of file sha2.cpp.

References m_boolEnded, and m_strHash.

const char * sha2::RawHash ( int &  length  ) 

Definition at line 663 of file sha2.cpp.

References enuSHA1, enuSHA224, enuSHA256, enuSHA384, enuSHA512, m_boolEnded, m_digest, m_Type, SHA1_DIGESTC_LENGTH, SHA224_DIGESTC_LENGTH, SHA256_DIGESTC_LENGTH, SHA384_DIGESTC_LENGTH, and SHA512_DIGESTC_LENGTH.

void sha2::SHA256_Internal_Last ( bool  isSha1 = false  )  [private]

Definition at line 419 of file sha2.cpp.

References sha2::SHA_CTX::bitcount, sha2::SHA_CTX::buffer, ctx, m_boolIsBigEndian, MEMSET_BZERO(), REVERSE64(), SHA1_Internal_Transform(), and SHA256_Internal_Transform().

Referenced by End().

void sha2::SHA512_Internal_Last (  )  [private]

Definition at line 447 of file sha2.cpp.

References sha2::SHA_CTX::bitcount, sha2::SHA_CTX::buffer, ctx, m_boolIsBigEndian, MEMSET_BZERO(), REVERSE64(), and SHA512_Internal_Transform().

Referenced by End().

void sha2::SHA1_Internal_Transform ( const sha_word32 data  )  [private]

Definition at line 221 of file sha2.cpp.

References sha2::SHA_CTX::buffer, Ch(), ctx, K1_0_TO_19, K1_20_TO_39, K1_40_TO_59, K1_60_TO_79, m_boolIsBigEndian, Maj(), Parity(), REVERSE32(), ROTL32(), and sha2::SHA_CTX::state.

Referenced by SHA256_Internal_Last(), and SHA32bit_Update().

void sha2::SHA256_Internal_Transform ( const sha_word32 data  )  [private]

* SHA-256: ********************************************************

Definition at line 272 of file sha2.cpp.

References sha2::SHA_CTX::buffer, Ch(), ctx, K256, m_boolIsBigEndian, Maj(), REVERSE32(), sigma0_256(), Sigma0_256(), sigma1_256(), Sigma1_256(), and sha2::SHA_CTX::state.

Referenced by SHA256_Internal_Last(), and SHA32bit_Update().

void sha2::SHA512_Internal_Transform ( const sha_word64 data  )  [private]

Definition at line 343 of file sha2.cpp.

References sha2::SHA_CTX::buffer, Ch(), ctx, K512, m_boolIsBigEndian, Maj(), REVERSE64(), sigma0_512(), Sigma0_512(), sigma1_512(), Sigma1_512(), and sha2::SHA_CTX::state.

Referenced by SHA512_Internal_Last(), and SHA64bit_Update().

void sha2::SHA32bit_Update ( const sha_byte data,
size_t  len,
bool  isSha1 = false 
) [private]

Definition at line 480 of file sha2.cpp.

References sha2::SHA_CTX::bitcount, sha2::SHA_CTX::buffer, ctx, MEMCPY_BCOPY(), SHA1_Internal_Transform(), and SHA256_Internal_Transform().

Referenced by Update().

void sha2::SHA64bit_Update ( const sha_byte data,
size_t  len 
) [private]

Definition at line 516 of file sha2.cpp.

References ADDINC128(), sha2::SHA_CTX::bitcount, sha2::SHA_CTX::buffer, ctx, MEMCPY_BCOPY(), and SHA512_Internal_Transform().

Referenced by Update().

void sha2::MEMSET_BZERO ( void *  p,
size_t  l 
) [inline, private]

Definition at line 162 of file sha2.h.

Referenced by Init(), SHA256_Internal_Last(), and SHA512_Internal_Last().

void sha2::MEMCPY_BCOPY ( void *  d,
const void *  s,
size_t  l 
) [inline, private]

Definition at line 163 of file sha2.h.

Referenced by End(), Init(), SHA32bit_Update(), and SHA64bit_Update().

void sha2::ADDINC128 ( sha_word64 w,
sha_word32  n 
) [inline, private]

Definition at line 168 of file sha2.h.

Referenced by SHA64bit_Update().

sha_word32 sha2::SHR ( sha_word32  b,
sha_word32  x 
) [inline, private]

Definition at line 174 of file sha2.h.

Referenced by sigma0_256(), sigma0_512(), sigma1_256(), and sigma1_512().

sha_word64 sha2::SHR ( sha_word64  b,
sha_word64  x 
) [inline, private]

Definition at line 175 of file sha2.h.

sha_word32 sha2::ROTR32 ( sha_word32  b,
sha_word32  x 
) [inline, private]

Definition at line 177 of file sha2.h.

Referenced by sigma0_256(), Sigma0_256(), sigma1_256(), and Sigma1_256().

sha_word64 sha2::ROTR64 ( sha_word64  b,
sha_word64  x 
) [inline, private]

Definition at line 179 of file sha2.h.

Referenced by sigma0_512(), Sigma0_512(), sigma1_512(), and Sigma1_512().

sha_word32 sha2::ROTL32 ( sha_word32  b,
sha_word32  x 
) [inline, private]

Definition at line 181 of file sha2.h.

Referenced by SHA1_Internal_Transform().

sha_word32 sha2::Ch ( sha_word32  x,
sha_word32  y,
sha_word32  z 
) [inline, private]

Definition at line 184 of file sha2.h.

Referenced by SHA1_Internal_Transform(), SHA256_Internal_Transform(), and SHA512_Internal_Transform().

sha_word64 sha2::Ch ( sha_word64  x,
sha_word64  y,
sha_word64  z 
) [inline, private]

Definition at line 185 of file sha2.h.

sha_word32 sha2::Maj ( sha_word32  x,
sha_word32  y,
sha_word32  z 
) [inline, private]

Definition at line 186 of file sha2.h.

Referenced by SHA1_Internal_Transform(), SHA256_Internal_Transform(), and SHA512_Internal_Transform().

sha_word64 sha2::Maj ( sha_word64  x,
sha_word64  y,
sha_word64  z 
) [inline, private]

Definition at line 187 of file sha2.h.

sha_word32 sha2::Parity ( sha_word32  x,
sha_word32  y,
sha_word32  z 
) [inline, private]

Definition at line 190 of file sha2.h.

Referenced by SHA1_Internal_Transform().

sha_word32 sha2::Sigma0_256 ( sha_word32  x  )  [inline, private]

Definition at line 193 of file sha2.h.

References ROTR32().

Referenced by SHA256_Internal_Transform().

sha_word32 sha2::Sigma1_256 ( sha_word32  x  )  [inline, private]

Definition at line 194 of file sha2.h.

References ROTR32().

Referenced by SHA256_Internal_Transform().

sha_word32 sha2::sigma0_256 ( sha_word32  x  )  [inline, private]

Definition at line 195 of file sha2.h.

References ROTR32(), and SHR().

Referenced by SHA256_Internal_Transform().

sha_word32 sha2::sigma1_256 ( sha_word32  x  )  [inline, private]

Definition at line 196 of file sha2.h.

References ROTR32(), and SHR().

Referenced by SHA256_Internal_Transform().

sha_word64 sha2::Sigma0_512 ( sha_word64  x  )  [inline, private]

Definition at line 199 of file sha2.h.

References ROTR64().

Referenced by SHA512_Internal_Transform().

sha_word64 sha2::Sigma1_512 ( sha_word64  x  )  [inline, private]

Definition at line 200 of file sha2.h.

References ROTR64().

Referenced by SHA512_Internal_Transform().

sha_word64 sha2::sigma0_512 ( sha_word64  x  )  [inline, private]

Definition at line 201 of file sha2.h.

References ROTR64(), and SHR().

Referenced by SHA512_Internal_Transform().

sha_word64 sha2::sigma1_512 ( sha_word64  x  )  [inline, private]

Definition at line 202 of file sha2.h.

References ROTR64(), and SHR().

Referenced by SHA512_Internal_Transform().

void sha2::REVERSE32 ( sha_word32  w,
sha_word32 x 
) [inline, private]

Definition at line 204 of file sha2.h.

Referenced by SHA1_Internal_Transform(), and SHA256_Internal_Transform().

void sha2::REVERSE64 ( sha_word64  w,
sha_word64 x 
) [inline, private]

Definition at line 217 of file sha2.h.

Referenced by SHA256_Internal_Last(), SHA512_Internal_Last(), and SHA512_Internal_Transform().


Member Data Documentation

SHA_TYPE sha2::m_Type [private]

Definition at line 136 of file sha2.h.

Referenced by End(), GetEnumType(), GetTypeString(), Init(), RawHash(), sha2(), and Update().

std::string sha2::m_strHash [private]

Definition at line 137 of file sha2.h.

Referenced by End(), GetHash(), HexHash(), and StringHash().

bool sha2::m_boolEnded [private]

Definition at line 138 of file sha2.h.

Referenced by End(), HexHash(), Init(), RawHash(), sha2(), and StringHash().

bool sha2::m_boolIsBigEndian [private]

Definition at line 138 of file sha2.h.

Referenced by End(), IsBigEndian(), SHA1_Internal_Transform(), sha2(), SHA256_Internal_Last(), SHA256_Internal_Transform(), SHA512_Internal_Last(), and SHA512_Internal_Transform().

char sha2::m_chrRawHash[SHA512_DIGESTC_LENGTH] [private]

Definition at line 139 of file sha2.h.

Referenced by sha2().

char sha2::m_chrHexHash[SHA512_DIGESTC_STRING_LENGTH] [private]

Definition at line 139 of file sha2.h.

Referenced by End(), and sha2().

sha_byte sha2::m_digest[SHA512_DIGESTC_LENGTH] [private]

Definition at line 140 of file sha2.h.

Referenced by End(), RawHash(), and sha2().

struct sha2::SHA_CTX sha2::ctx [private]

Referenced by End(), Init(), SHA1_Internal_Transform(), SHA256_Internal_Last(), SHA256_Internal_Transform(), SHA32bit_Update(), SHA512_Internal_Last(), SHA512_Internal_Transform(), and SHA64bit_Update().


The documentation for this class was generated from the following files:
Generated on Mon Feb 16 15:15:06 2009 for Scorched3D by  doxygen 1.5.3