D:/opendownloadmanager/ODM-1.x/Hash/sha1.cpp File Reference

#include <string.h>
#include <stdlib.h>
#include "sha1.h"

Go to the source code of this file.

Defines

#define SHA_LITTLE_ENDIAN   1234
#define SHA_BIG_ENDIAN   4321
#define rotl32(x, n)   (((x) << n) | ((x) >> (32 - n)))
#define swap_b32(x)   ((rotl32((x), 8) & 0x00ff00ff) | (rotl32((x), 24) & 0xff00ff00))
#define SHA1_MASK   (SHA1_BLOCK_SIZE - 1)
#define ch(x, y, z)   (((x) & (y)) ^ (~(x) & (z)))
#define parity(x, y, z)   ((x) ^ (y) ^ (z))
#define maj(x, y, z)   (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
#define rnd(f, k)

Functions

void sha1_compile (sha1_ctx ctx[1])
void sha1_begin (sha1_ctx ctx[1])
void sha1_hash (const unsigned char data[], unsigned int len, sha1_ctx ctx[1])
void sha1_end (unsigned char hval[], sha1_ctx ctx[1])
void sha1 (unsigned char hval[], const unsigned char data[], unsigned int len)

Variables

static sha1_32t mask [4]
static sha1_32t bits [4]


Define Documentation

#define ch ( x,
y,
 )     (((x) & (y)) ^ (~(x) & (z)))

#define maj ( x,
y,
 )     (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))

Definition at line 76 of file sha1.cpp.

Referenced by sha1_compile().

#define parity ( x,
y,
 )     ((x) ^ (y) ^ (z))

Definition at line 75 of file sha1.cpp.

Referenced by sha1_compile().

#define rnd ( f,
 ) 

Value:

t = a; a = rotl32(a,5) + f(b,c,d) + e + k + w[i]; \
    e = d; d = c; c = rotl32(b, 30); b = t

Definition at line 78 of file sha1.cpp.

Referenced by sha1_compile().

#define rotl32 ( x,
n   )     (((x) << n) | ((x) >> (32 - n)))

Definition at line 62 of file sha1.cpp.

Referenced by sha1_compile().

#define SHA1_MASK   (SHA1_BLOCK_SIZE - 1)

Definition at line 72 of file sha1.cpp.

Referenced by sha1_end(), and sha1_hash().

#define SHA_BIG_ENDIAN   4321

Definition at line 16 of file sha1.cpp.

#define SHA_LITTLE_ENDIAN   1234

Definition at line 15 of file sha1.cpp.

#define swap_b32 (  )     ((rotl32((x), 8) & 0x00ff00ff) | (rotl32((x), 24) & 0xff00ff00))

Definition at line 69 of file sha1.cpp.

Referenced by sha1_compile(), and sha1_end().


Function Documentation

void sha1 ( unsigned char  hval[],
const unsigned char  data[],
unsigned int  len 
)

Definition at line 206 of file sha1.cpp.

References sha1_begin(), sha1_end(), and sha1_hash().

Referenced by vmsHash::Hash_SHA1().

void sha1_begin ( sha1_ctx  ctx[1]  ) 

Definition at line 127 of file sha1.cpp.

References sha1_ctx::count, and sha1_ctx::hash.

Referenced by vmsHash::Hash_SHA1(), and sha1().

void sha1_compile ( sha1_ctx  ctx[1]  ) 

Definition at line 82 of file sha1.cpp.

References a, b, c, ch, simple_client::e, sha1_ctx::hash, maj, parity, rnd, rotl32, SHA1_BLOCK_SIZE, swap_b32, and sha1_ctx::wbuf.

Referenced by sha1_end(), and sha1_hash().

void sha1_end ( unsigned char  hval[],
sha1_ctx  ctx[1] 
)

void sha1_hash ( const unsigned char  data[],
unsigned int  len,
sha1_ctx  ctx[1] 
)

Definition at line 137 of file sha1.cpp.

References sha1_ctx::count, pos(), SHA1_BLOCK_SIZE, sha1_compile(), SHA1_MASK, and sha1_ctx::wbuf.

Referenced by vmsHash::Hash_SHA1(), main(), and sha1().


Variable Documentation

sha1_32t bits[4] [static]

Initial value:

 
        {   0x80000000, 0x00800000, 0x00008000, 0x00000080 }

Definition at line 163 of file sha1.cpp.

Referenced by CreateConnection(), fixedtables(), gen_bitlen(), gen_codes(), inflate(), inflate_fast(), inflateBack(), MD5_Final(), libtorrent::aux::piece_checker_data::parse_resume_data(), sha1_end(), and tr_static_init().

sha1_32t mask[4] [static]

Initial value:

 
        {   0x00000000, 0xff000000, 0xffff0000, 0xffffff00 }

Definition at line 161 of file sha1.cpp.

Referenced by inflate_table(), libtorrent::dht::node_impl::refresh_bucket(), and sha1_end().


Generated on Sun May 25 00:19:43 2008 by  doxygen 1.5.6