pspsdk-1.0+beta2
sha1.c File Reference
#include <string.h>
#include <stdlib.h>
#include "sha1.h"
Include dependency graph for sha1.c:

Macros

#define BRG_LITTLE_ENDIAN   1234 /* byte 0 is least significant (i386) */
#define BRG_BIG_ENDIAN   4321 /* byte 0 is most significant (mc68k) */
#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)

Macro Definition Documentation

#define BRG_BIG_ENDIAN   4321 /* byte 0 is most significant (mc68k) */
#define BRG_LITTLE_ENDIAN   1234 /* byte 0 is least significant (i386) */
#define bsw_32 (   p,
 
)    { int _i = (n); while(_i--) ((sha1_32t*)p)[_i] = bswap_32(((sha1_32t*)p)[_i]); }

Referenced by sha1_end(), and sha1_hash().

#define bswap_32 (   x)    ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00))
#define ch (   x,
  y,
  z 
)    ((z) ^ ((x) & ((y) ^ (z))))
#define five_cycle (   v,
  f,
  k,
  i 
)
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))

Referenced by sha1_compile().

#define hf (   i)    w[i]

Referenced by sha1_compile().

#define hf (   i)
Value:
(w[(i) & 15] = rotl32( \
w[((i) + 13) & 15] ^ w[((i) + 8) & 15] \
^ w[((i) + 2) & 15] ^ w[(i) & 15], 1))
#define maj (   x,
  y,
  z 
)    (((x) & (y)) | ((z) & ((x) ^ (y))))

Referenced by sha1_compile().

#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)

Referenced by sha1_compile().

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

Referenced by sha1_compile().

#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)

Referenced by sha1_end(), and sha1_hash().

#define SWAP_BYTES

Function Documentation

void sha1 ( unsigned char  hval[],
const unsigned char  data[],
unsigned long  len 
)
void sha1_begin ( sha1_ctx  ctx[1])

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

Referenced by sha1().

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] 
)