SNAP Library, User Reference  2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
md5.h File Reference

Go to the source code of this file.

Classes

class  TMd5Sig

Typedefs

typedef TB1Def::TB1 uint1
typedef TVec< TMd5SigTMd5SigV

Functions

void Init ()
void Transform (uint1 *buffer)
static void Encode (uint1 *Dst, uint4 *Src, uint4 Len)
static void Decode (uint4 *Dst, uint1 *Src, uint4 Len)
static void MemCpy (uint1 *Dst, uint1 *Src, uint4 Len)
static void MemSet (uint1 *Start, uint1 Val, uint4 Len)
static uint4 RotateLeft (uint4 x, uint4 n)
static uint4 F (uint4 x, uint4 y, uint4 z)
static uint4 G (uint4 x, uint4 y, uint4 z)
static uint4 H (uint4 x, uint4 y, uint4 z)
static uint4 I (uint4 x, uint4 y, uint4 z)
static void FF (uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static void GG (uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static void HH (uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static void II (uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
 UndefCopyAssign (TMd5)
 TMd5 ()
static PMd5 New ()
 TMd5 (const PSIn &SIn)
static PMd5 New (const PSIn &SIn)
 TMd5 (TSIn &)
static PMd5 Load (TSIn &SIn)
void Save (TSOut &)
void Add (uchar *InBf, const int &InBfL)
void Add (const PSIn &SIn)
void Def ()
void GetSigMem (TMem &Mem) const
TStr GetSigStr () const
static TStr GetMd5SigStr (const PSIn &SIn)
static TStr GetMd5SigStr (const TStr &Str)
static TStr GetMd5SigStr (const TMem &Mem)
static bool Check ()

Variables

ClassTP(TMd5, PMd5) private
typedef TB2Def::TB2 
uint2
uint4 state [4]
uint4 count [2]
uint1 buffer [64]
uint1 Sig [16]
bool DefP

Typedef Documentation

typedef TVec<TMd5Sig> TMd5SigV

Definition at line 113 of file md5.h.

typedef TB1Def::TB1 uint1

Definition at line 8 of file md5.h.


Function Documentation

void Add ( uchar InBf,
const int &  InBfL 
)
void Add ( const PSIn SIn)
static bool Check ( ) [static]
void TMd5::Decode ( uint4 *  Dst,
uint1 Src,
uint4  Len 
) [static]

Definition at line 140 of file md5.cpp.

                                                       {
  for (uint4 i=0, j=0; j<len; i++, j+=4){
    output[i]=
     ((uint4)input[j]) | (((uint4)input[j+1]) << 8) |
     (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24);
  }
}
void TMom::Def ( )

Definition at line 187 of file md5.cpp.

              {
  unsigned char bits[8];
  static uint1 PADDING[64]={
    0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

  IAssert(!DefP);
  Encode(bits, count, 8); // save number of bits

  // Pad out to 56 mod 64.
  uint index=uint4((count[0] >> 3) & 0x3f);
  uint padLen=(index<56) ? (56-index) : (120-index);
  Add(PADDING, padLen);

  Add(bits, 8); // append length (before padding)
  Encode(Sig, state, 16); // store state in digest
  MemSet(buffer, 0, sizeof(*buffer)); // zeroize sensitive information
  DefP=true;
}
void TMd5::Encode ( uint1 Dst,
uint4 *  Src,
uint4  Len 
) [static]

Definition at line 129 of file md5.cpp.

                                                       {
  for (uint4 i=0, j=0; j<len; i++, j+=4){
    output[j]=uint1(input[i] & 0xff);
    output[j+1]=uint1((input[i]>>8) & 0xff);
    output[j+2]=uint1((input[i]>>16) & 0xff);
    output[j+3]=uint1((input[i]>>24) & 0xff);
  }
}
static uint4 F ( uint4  x,
uint4  y,
uint4  z 
) [static]

Definition at line 30 of file md5.h.

{return (x&y)|(~x&z);}
static void FF ( uint4 &  a,
uint4  b,
uint4  c,
uint4  d,
uint4  x,
uint4  s,
uint4  ac 
) [static]

Definition at line 36 of file md5.h.

                                                                                 {
    a+=F(b, c, d)+x+ac; a=RotateLeft(a, s)+b;}
static uint4 G ( uint4  x,
uint4  y,
uint4  z 
) [static]

Definition at line 31 of file md5.h.

{return (x&z)|(y&~z);}
static TStr GetMd5SigStr ( const PSIn SIn) [static]

Definition at line 64 of file md5.h.

                                           {
    PMd5 Md5=TMd5::New(SIn); return Md5->GetSigStr();}
static TStr GetMd5SigStr ( const TStr Str) [static]

Definition at line 66 of file md5.h.

                                           {
    return GetMd5SigStr(TStrIn::New(Str));}
static TStr GetMd5SigStr ( const TMem Mem) [static]

Definition at line 68 of file md5.h.

                                           {
    return GetMd5SigStr(TMemIn::New(Mem));}
void TMd5::GetSigMem ( TMem Mem) const

Definition at line 208 of file md5.cpp.

                                    {
  IAssert(DefP);
  Mem.Gen(16);
  for (int CdN=0; CdN<16; CdN++){Mem+=Sig[CdN];}
}
TStr TMd5::GetSigStr ( ) const

Definition at line 214 of file md5.cpp.

                           {
  IAssert(DefP);
  TChA ChA(32);
  for (int CdN=0; CdN<16; CdN++){
    ChA+=TCh::GetHexCh(Sig[CdN]/16);
    ChA+=TCh::GetHexCh(Sig[CdN]%16);
  }
  return ChA;
}
static void GG ( uint4 &  a,
uint4  b,
uint4  c,
uint4  d,
uint4  x,
uint4  s,
uint4  ac 
) [static]

Definition at line 38 of file md5.h.

                                                                                 {
    a+=G(b, c, d)+x+ac; a=RotateLeft(a, s)+b;}
static uint4 H ( uint4  x,
uint4  y,
uint4  z 
) [static]

Definition at line 32 of file md5.h.

{return x^y^z;}
static void HH ( uint4 &  a,
uint4  b,
uint4  c,
uint4  d,
uint4  x,
uint4  s,
uint4  ac 
) [static]

Definition at line 40 of file md5.h.

                                                                                 {
    a+=H(b, c, d)+x+ac; a=RotateLeft(a, s)+b;}
static uint4 I ( uint4  x,
uint4  y,
uint4  z 
) [static]

Definition at line 33 of file md5.h.

{return y^(x|~z);}
static void II ( uint4 &  a,
uint4  b,
uint4  c,
uint4  d,
uint4  x,
uint4  s,
uint4  ac 
) [static]

Definition at line 42 of file md5.h.

                                                                                 {
    a+=I(b, c, d)+x+ac; a=RotateLeft(a, s)+b;}
void Init ( )
static PMd5 Load ( TSIn SIn) [static]

Definition at line 51 of file md5.h.

{return new TMd5(SIn);}
static void MemCpy ( uint1 Dst,
uint1 Src,
uint4  Len 
) [static]

Definition at line 22 of file md5.h.

                                                       {
    for (uint4 ChN=0; ChN<Len; ChN++){Dst[ChN]=Src[ChN];}}
static void MemSet ( uint1 Start,
uint1  Val,
uint4  Len 
) [static]

Definition at line 24 of file md5.h.

                                                        {
    for (uint4 ChN=0; ChN<Len; ChN++){Start[ChN]=Val;}}
static PMd5 New ( ) [static]

Definition at line 47 of file md5.h.

{return PMd5(new TMd5());}
static PMd5 New ( const PSIn SIn) [static]

Definition at line 49 of file md5.h.

{return PMd5(new TMd5(SIn));}
static uint4 RotateLeft ( uint4  x,
uint4  n 
) [static]

Definition at line 28 of file md5.h.

{return (x<<n)|(x>>(32-n));}
void Save ( TSOut )

Definition at line 52 of file md5.h.

{Fail;}
TMd5 ( )

Definition at line 46 of file md5.h.

{Init();}
TMd5 ( const PSIn SIn)

Definition at line 48 of file md5.h.

{Init(); Add(SIn); Def();}
TMd5 ( TSIn )

Definition at line 50 of file md5.h.

{Fail;}
void Transform ( uint1 buffer)

Variable Documentation

Definition at line 13 of file md5.h.

uint4 count[2]

Definition at line 12 of file md5.h.

bool DefP

Definition at line 15 of file md5.h.

uint1 Sig[16]

Definition at line 14 of file md5.h.

uint4 state[4]

Definition at line 11 of file md5.h.

ClassTP (TMd5, PMd5) private typedef TB2Def::TB2 uint2

Definition at line 3 of file md5.h.