sha1.cc File Reference

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

Go to the source code of this file.

Defines

#define GET_UINT32(n, b, i)
#define PUT_UINT32(n, b, i)
#define S(x, n)   ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
#define R(t)
#define P(a, b, c, d, e, x)
#define F(x, y, z)   (z ^ (x & (y ^ z)))
#define K   0x5A827999
#define F(x, y, z)   (x ^ y ^ z)
#define K   0x6ED9EBA1
#define F(x, y, z)   ((x & y) | (z & (x | y)))
#define K   0x8F1BBCDC
#define F(x, y, z)   (x ^ y ^ z)
#define K   0xCA62C1D6

Functions

void sha1_starts (sha1_context *ctx)
void sha1_process (sha1_context *ctx, uint8 data[64])
void sha1_update (sha1_context *ctx, uint8 *input, uint32 length)
void sha1_finish (sha1_context *ctx, uint8 digest[20])

Variables

static uint8 sha1_padding [64]


Define Documentation

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

#define F ( x,
y,
 )     ((x & y) | (z & (x | y)))

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

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

#define GET_UINT32 ( n,
b,
 ) 

Value:

{                                               \
    (n) = ( (uint32) (b)[(i)    ] << 24 )       \
        | ( (uint32) (b)[(i) + 1] << 16 )       \
        | ( (uint32) (b)[(i) + 2] <<  8 )       \
        | ( (uint32) (b)[(i) + 3]       );      \
}

Definition at line 25 of file sha1.cc.

Referenced by sha1_process().

#define K   0xCA62C1D6

#define K   0x8F1BBCDC

#define K   0x6ED9EBA1

#define K   0x5A827999

#define P ( a,
b,
c,
d,
e,
 ) 

Value:

{                                                       \
    e += S(a,5) + F(b,c,d) + K + x; b = S(b,30);        \
}

Referenced by sha1_process().

#define PUT_UINT32 ( n,
b,
 ) 

Value:

{                                               \
    (b)[(i)    ] = (uint8) ( (n) >> 24 );       \
    (b)[(i) + 1] = (uint8) ( (n) >> 16 );       \
    (b)[(i) + 2] = (uint8) ( (n) >>  8 );       \
    (b)[(i) + 3] = (uint8) ( (n)       );       \
}

Definition at line 33 of file sha1.cc.

Referenced by sha1_finish().

#define R (  ) 

Value:

(                                                       \
    temp = W[(t -  3) & 0x0F] ^ W[(t - 8) & 0x0F] ^     \
           W[(t - 14) & 0x0F] ^ W[ t      & 0x0F],      \
    ( W[t & 0x0F] = S(temp,1) )                         \
)

Referenced by sha1_process().

#define S ( x,
 )     ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))


Function Documentation

void sha1_finish ( sha1_context ctx,
uint8  digest[20] 
)

Definition at line 256 of file sha1.cc.

References PUT_UINT32, sha1_padding, sha1_update(), sha1_context::total, uint32, and uint8.

Referenced by hash().

void sha1_process ( sha1_context ctx,
uint8  data[64] 
)

Definition at line 53 of file sha1.cc.

References GET_UINT32, P, R, sha1_context::state, and uint32.

Referenced by sha1_update().

void sha1_starts ( sha1_context ctx  ) 

Definition at line 41 of file sha1.cc.

References sha1_context::state, and sha1_context::total.

Referenced by hash().

void sha1_update ( sha1_context ctx,
uint8 *  input,
uint32  length 
)

Definition at line 209 of file sha1.cc.

References sha1_context::buffer, sha1_process(), sha1_context::total, and uint32.

Referenced by hash(), and sha1_finish().


Variable Documentation

uint8 sha1_padding[64] [static]

Initial value:

{
 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
}

Definition at line 248 of file sha1.cc.

Referenced by sha1_finish().


Generated on Thu Jun 7 16:56:54 2007 for DTN Reference Implementation by  doxygen 1.5.1