Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

sha1.c File Reference

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

Include dependency graph for sha1.c:


Defines

#define BRG_LITTLE_ENDIAN   1234
#define BRG_BIG_ENDIAN   4321
#define PLATFORM_BYTE_ORDER   BRG_LITTLE_ENDIAN
#define rotl32(x, n)   (((x) << n) | ((x) >> (32 - n)))
#define rotr32(x, n)   (((x) >> n) | ((x) << (32 - n)))
#define bswap_32(x)   ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00))
#define SWAP_BYTES
#define bsw_32(p, n)   { int _i = (n); while(_i--) ((sha1_32t*)p)[_i] = bswap_32(((sha1_32t*)p)[_i]); }
#define SHA1_MASK   (SHA1_BLOCK_SIZE - 1)
#define ch(x, y, z)   ((z) ^ ((x) & ((y) ^ (z))))
#define parity(x, y, z)   ((x) ^ (y) ^ (z))
#define maj(x, y, z)   (((x) & (y)) | ((z) & ((x) ^ (y))))
#define q(v, n)   v##n
#define one_cycle(v, a, b, c, d, e, f, k, h)
#define five_cycle(v, f, k, i)
#define hf(i)   w[i]
#define hf(i)

Functions

void sha1_compile (sha1_ctx ctx[1])
void sha1_begin (sha1_ctx ctx[1])
void sha1_hash (const unsigned char data[], unsigned long 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 long len)

Define Documentation

#define BRG_BIG_ENDIAN   4321
 

#define BRG_LITTLE_ENDIAN   1234
 

#define bsw_32 p,
 )     { int _i = (n); while(_i--) ((sha1_32t*)p)[_i] = bswap_32(((sha1_32t*)p)[_i]); }
 

#define bswap_32  )     ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00))
 

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

#define five_cycle v,
f,
k,
 ) 
 

Value:

one_cycle(v, 0,1,2,3,4, f,k,hf(i  ));   \
    one_cycle(v, 4,0,1,2,3, f,k,hf(i+1));   \
    one_cycle(v, 3,4,0,1,2, f,k,hf(i+2));   \
    one_cycle(v, 2,3,4,0,1, f,k,hf(i+3));   \
    one_cycle(v, 1,2,3,4,0, f,k,hf(i+4))

#define hf  ) 
 

Value:

(w[(i) & 15] = rotl32(                    \
                 w[((i) + 13) & 15] ^ w[((i) + 8) & 15] \
               ^ w[((i) +  2) & 15] ^ w[(i) & 15], 1))

#define hf  )     w[i]
 

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

#define one_cycle v,
a,
b,
c,
d,
e,
f,
k,
 ) 
 

Value:

q(v,e) += rotr32(q(v,a),27) +               \
              f(q(v,b),q(v,c),q(v,d)) + k + h;  \
    q(v,b)  = rotr32(q(v,b), 2)

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

#define PLATFORM_BYTE_ORDER   BRG_LITTLE_ENDIAN
 

#define q v,
 )     v##n
 

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

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

#define SHA1_MASK   (SHA1_BLOCK_SIZE - 1)
 

#define SWAP_BYTES
 


Function Documentation

void sha1 unsigned char  hval[],
const unsigned char  data[],
unsigned long  len
 

void sha1_begin sha1_ctx  ctx[1]  ) 
 

void sha1_compile sha1_ctx  ctx[1]  ) 
 

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

void sha1_hash const unsigned char  data[],
unsigned long  len,
sha1_ctx  ctx[1]
 


Generated on Wed Sep 28 07:54:38 2005 for pspsdk-1.0+beta by  doxygen 1.4.4