mux/src/sha1.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SHA1_CONTEXT

Functions

void SHA1_Init (SHA1_CONTEXT *p)
void SHA1_Compute (SHA1_CONTEXT *p, size_t n, const char *buf)
void SHA1_Final (SHA1_CONTEXT *p)


Function Documentation

void SHA1_Compute ( SHA1_CONTEXT p,
size_t  n,
const char *  buf 
)

Definition at line 99 of file sha1.cpp.

References SHA1_CONTEXT::block, SHA1_CONTEXT::nblock, SHA1_CONTEXT::nTotal, and SHA1_HashBlock().

Referenced by FUNCTION(), and mux_crypt().

00100 {
00101     while (n)
00102     {
00103         size_t m = sizeof(p->block) - p->nblock;
00104         if (n < m)
00105         {
00106             m = n;
00107         }
00108         memcpy(p->block + p->nblock, buf, m);
00109         buf += m;
00110         n -= m;
00111         p->nblock += m;
00112         p->nTotal += m;
00113 
00114         if (p->nblock == sizeof(p->block))
00115         {
00116             SHA1_HashBlock(p);
00117             p->nblock = 0;
00118         }
00119     }
00120 }

void SHA1_Final ( SHA1_CONTEXT p  ) 

Definition at line 122 of file sha1.cpp.

References SHA1_CONTEXT::block, SHA1_CONTEXT::nblock, SHA1_CONTEXT::nTotal, and SHA1_HashBlock().

Referenced by FUNCTION(), and mux_crypt().

00123 {
00124     p->block[p->nblock++] = 0x80;
00125     if (sizeof(p->block) - sizeof(UINT64) <= p->nblock)
00126     {
00127         memset(p->block + p->nblock, 0, sizeof(p->block) - p->nblock);
00128         SHA1_HashBlock(p);
00129         memset(p->block, 0, sizeof(p->block) - sizeof(UINT64));
00130     }
00131     else
00132     {
00133         memset(p->block + p->nblock, 0, sizeof(p->block) - p->nblock - sizeof(UINT64));
00134     }
00135     p->nTotal *= 8;
00136 
00137     p->block[sizeof(p->block) - 8] = (UINT8)(p->nTotal >> 56) & 0xFF;
00138     p->block[sizeof(p->block) - 7] = (UINT8)(p->nTotal >> 48) & 0xFF;
00139     p->block[sizeof(p->block) - 6] = (UINT8)(p->nTotal >> 40) & 0xFF;
00140     p->block[sizeof(p->block) - 5] = (UINT8)(p->nTotal >> 32) & 0xFF;
00141     p->block[sizeof(p->block) - 4] = (UINT8)(p->nTotal >> 24) & 0xFF;
00142     p->block[sizeof(p->block) - 3] = (UINT8)(p->nTotal >> 16) & 0xFF;
00143     p->block[sizeof(p->block) - 2] = (UINT8)(p->nTotal >>  8) & 0xFF;
00144     p->block[sizeof(p->block) - 1] = (UINT8)(p->nTotal      ) & 0xFF;
00145     SHA1_HashBlock(p);
00146 }

void SHA1_Init ( SHA1_CONTEXT p  ) 

Definition at line 7 of file sha1.cpp.

References SHA1_CONTEXT::H, SHA1_CONTEXT::nblock, and SHA1_CONTEXT::nTotal.

Referenced by FUNCTION(), and mux_crypt().

00008 {
00009     p->H[0] = 0x67452301;
00010     p->H[1] = 0xEFCDAB89;
00011     p->H[2] = 0x98BADCFE;
00012     p->H[3] = 0x10325476;
00013     p->H[4] = 0xC3D2E1F0;
00014     p->nTotal = 0;
00015     p->nblock = 0;
00016 }


Generated on Mon May 28 04:40:22 2007 for MUX by  doxygen 1.4.7