md5.c File Reference

An implementation of MD5. More...

#include "common.h"
Include dependency graph for md5.c:

Go to the source code of this file.

Data Structures

struct  MD5Context

Defines

#define byteReverse(buf, len)
#define F1(x, y, z)   (z ^ (x & (y ^ z)))
#define F2(x, y, z)   F1(z, x, y)
#define F3(x, y, z)   (x ^ y ^ z)
#define F4(x, y, z)   (y ^ (x | ~z))
#define MD5STEP(f, w, x, y, z, data, s)   ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )

Typedefs

typedef struct MD5Context MD5_CTX

Functions

static void MD5Init (struct MD5Context *ctx)
 Start MD5 accumulation. Set bit count to 0 and buffer to mysterious initialization constants.
static void MD5Transform (uint32_t buf[4], uint32_t const in[16])
 The core of the MD5 algorithm, this alters an existing MD5 hash to reflect the addition of 16 longwords of new data. MD5Update blocks the data and converts bytes into longwords for this routine.
static void MD5Update (struct MD5Context *ctx, unsigned char const *buf, unsigned len)
 Update context to reflect the concatenation of another buffer full of bytes.
static void MD5Final (struct MD5Context *ctx, unsigned char *digest)
 Final wrapup - pad to 64-byte boundary with the bit pattern 1 0* (64-bit count of bits processed, MSB-first).
char * Com_MD5File (const char *fn, int length)
 Compute the md5sum of a given file.

Detailed Description

An implementation of MD5.

Definition in file md5.c.


Define Documentation

#define byteReverse ( buf,
len   ) 

Definition at line 32 of file md5.c.

Referenced by MD5Final(), and MD5Update().

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

Definition at line 69 of file md5.c.

Referenced by MD5Transform().

#define F2 ( x,
y,
 )     F1(z, x, y)

Definition at line 70 of file md5.c.

Referenced by MD5Transform().

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

Definition at line 71 of file md5.c.

Referenced by MD5Transform().

#define F4 ( x,
y,
 )     (y ^ (x | ~z))

Definition at line 72 of file md5.c.

Referenced by MD5Transform().

#define MD5STEP ( f,
w,
x,
y,
z,
data,
 )     ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )

Definition at line 75 of file md5.c.

Referenced by MD5Transform().


Typedef Documentation

typedef struct MD5Context MD5_CTX

Function Documentation

char* Com_MD5File ( const char *  fn,
int  length 
)

Compute the md5sum of a given file.

Parameters:
[in] fn Filename to compute the md5 of
[in] length Compute the md5 of the first 'length' bytes (if 0 - complete file)
Returns:
the md5 sum buffer (char*)

Definition at line 268 of file md5.c.

References f, FILE_READ, FS_CloseFile(), FS_OpenFile(), FS_Read(), i, MD5Final(), MD5Init(), MD5Update(), Q_strcat(), and va().

static void MD5Final ( struct MD5Context ctx,
unsigned char *  digest 
) [static]

Final wrapup - pad to 64-byte boundary with the bit pattern 1 0* (64-bit count of bits processed, MSB-first).

Definition at line 219 of file md5.c.

References MD5Context::bits, MD5Context::buf, byteReverse, count, MD5Context::in, and MD5Transform().

Referenced by Com_MD5File().

static void MD5Init ( struct MD5Context ctx  )  [static]

Start MD5 accumulation. Set bit count to 0 and buffer to mysterious initialization constants.

Definition at line 56 of file md5.c.

References MD5Context::bits, and MD5Context::buf.

Referenced by Com_MD5File().

static void MD5Transform ( uint32_t  buf[4],
uint32_t const   in[16] 
) [static]

The core of the MD5 algorithm, this alters an existing MD5 hash to reflect the addition of 16 longwords of new data. MD5Update blocks the data and converts bytes into longwords for this routine.

Definition at line 83 of file md5.c.

References F1, F2, F3, F4, and MD5STEP.

Referenced by MD5Final(), and MD5Update().

static void MD5Update ( struct MD5Context ctx,
unsigned char const *  buf,
unsigned  len 
) [static]

Update context to reflect the concatenation of another buffer full of bytes.

Definition at line 170 of file md5.c.

References MD5Context::bits, MD5Context::buf, byteReverse, MD5Context::in, and MD5Transform().

Referenced by Com_MD5File().


Generated by  doxygen 1.6.2