Classes | Macros | Functions
md5.h File Reference
#include "md5_loc.h"

Go to the source code of this file.

Classes

struct  MD5Context
 

Macros

#define md5byte   unsigned char
 

Functions

void MD5Init (struct MD5Context *context)
 
void MD5Update (struct MD5Context *context, md5byte const *buf, unsigned len)
 
void MD5Final (unsigned char digest[16], struct MD5Context *context)
 
void MD5Buffer (const unsigned char *buf, unsigned int len, unsigned char sig[16])
 
void MD5SigToString (unsigned char sig[16], char *str, int len)
 

Macro Definition Documentation

#define md5byte   unsigned char

Definition at line 32 of file md5.h.

Function Documentation

void MD5Buffer ( const unsigned char *  buf,
unsigned int  len,
unsigned char  sig[16] 
)

Definition at line 275 of file md5.c.

276 {
277  struct MD5Context md5;
278  MD5Init(&md5);
279  MD5Update(&md5,buf,len);
280  MD5Final(sig,&md5);
281 }
void MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
Definition: md5.c:99
void MD5Init(struct MD5Context *ctx)
Definition: md5.c:81
Definition: md5.h:41
void MD5Final(md5byte digest[16], struct MD5Context *ctx)
Definition: md5.c:139
UWORD32 buf[4]
Definition: md5.h:42
void MD5Final ( unsigned char  digest[16],
struct MD5Context context 
)
void MD5Init ( struct MD5Context context)

Definition at line 81 of file md5.c.

82 {
84 
85  ctx->buf[0] = 0x67452301;
86  ctx->buf[1] = 0xefcdab89;
87  ctx->buf[2] = 0x98badcfe;
88  ctx->buf[3] = 0x10325476;
89 
90  ctx->bytes[0] = 0;
91  ctx->bytes[1] = 0;
92 }
static void detectEndianess()
Definition: md5.c:35
void MD5SigToString ( unsigned char  sig[16],
char *  str,
int  len 
)

Definition at line 285 of file md5.c.

286 {
287  unsigned char *sig_p;
288  char *str_p, *max_p;
289  unsigned int high, low;
290 
291  str_p = str;
292  max_p = str + len;
293 
294  for (sig_p = (unsigned char *)signature;
295  sig_p < (unsigned char *)signature + 16;
296  sig_p++)
297  {
298  high = *sig_p / 16;
299  low = *sig_p % 16;
300  /* account for 2 chars */
301  if (str_p + 1 >= max_p) {
302  break;
303  }
304  *str_p++ = HEX_STRING[high];
305  *str_p++ = HEX_STRING[low];
306  }
307  /* account for 2 chars */
308  if (str_p < max_p) {
309  *str_p++ = '\0';
310  }
311 }
static QCString str
#define HEX_STRING
Definition: md5.c:283
void MD5Update ( struct MD5Context context,
md5byte const *  buf,
unsigned  len 
)

Definition at line 99 of file md5.c.

100 {
101  UWORD32 t;
102 
103  /* Update byte count */
104 
105  t = ctx->bytes[0];
106  if ((ctx->bytes[0] = t + len) < t)
107  ctx->bytes[1]++; /* Carry from low to high */
108 
109  t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
110  if (t > len) {
111  memcpy((md5byte *)ctx->in + 64 - t, buf, len);
112  return;
113  }
114  /* First chunk is an odd size */
115  memcpy((md5byte *)ctx->in + 64 - t, buf, t);
116  byteSwap(ctx->in, 16);
117  MD5Transform(ctx->buf, ctx->in);
118  buf += t;
119  len -= t;
120 
121  /* Process data in 64-byte chunks */
122  while (len >= 64) {
123  memcpy(ctx->in, buf, 64);
124  byteSwap(ctx->in, 16);
125  MD5Transform(ctx->buf, ctx->in);
126  buf += 64;
127  len -= 64;
128  }
129 
130  /* Handle any remaining bytes of data. */
131  memcpy(ctx->in, buf, len);
132 }
void MD5Transform(UWORD32 buf[4], UWORD32 const in[16])
Definition: md5.c:190
static void byteSwap(UWORD32 *buf, unsigned words)
Definition: md5.c:61
UWORD32 buf[4]
Definition: md5.h:42
#define md5byte
Definition: md5.h:32
#define UWORD32
Definition: md5_loc.h:4