UFO: Alien Invasion
Loading...
Searching...
No Matches
md5.cpp File Reference

An implementation of MD5. More...

#include "common.h"
#include <SDL_endian.h>
Include dependency graph for md5.cpp:

Go to the source code of this file.

Data Structures

struct  MD5_CTX

Macros

#define byteReverse(buf, len)
#define F1(x, y, z)
#define F2(x, y, z)
#define F3(x, y, z)
#define F4(x, y, z)
#define MD5STEP(f, w, x, y, z, data, s)

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).
const char * Com_MD5File (const char *fn, int length)
 Compute the md5sum of a given file.
const char * Com_MD5Buffer (const byte *buf, size_t len)
 Compute the md5sum of the given buffer.

Detailed Description

An implementation of MD5.

Definition in file md5.cpp.

Macro Definition Documentation

◆ byteReverse

#define byteReverse ( buf,
len )
Value:
{} /* Nothing */

Definition at line 33 of file md5.cpp.

Referenced by MD5Final(), and MD5Update().

◆ F1

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

Definition at line 65 of file md5.cpp.

Referenced by MD5Transform().

◆ F2

#define F2 ( x,
y,
z )
Value:
F1(z, x, y)
#define F1(x, y, z)
Definition md5.cpp:65

Definition at line 66 of file md5.cpp.

Referenced by MD5Transform().

◆ F3

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

Definition at line 67 of file md5.cpp.

Referenced by MD5Transform().

◆ F4

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

Definition at line 68 of file md5.cpp.

Referenced by MD5Transform().

◆ MD5STEP

#define MD5STEP ( f,
w,
x,
y,
z,
data,
s )
Value:
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
QGL_EXTERN GLsizei const GLvoid * data
Definition r_gl.h:89
QGL_EXTERN GLfloat f
Definition r_gl.h:114

Definition at line 71 of file md5.cpp.

Referenced by MD5Transform().

Function Documentation

◆ Com_MD5Buffer()

const char * Com_MD5Buffer ( const byte * buf,
size_t len )

Compute the md5sum of the given buffer.

Parameters
[in]bufData to compute the md5 of
[in]lenBuffer length in bytes
Returns
the md5 sum buffer (char*)

Definition at line 300 of file md5.cpp.

References i, len, MD5Final(), MD5Init(), MD5Update(), and Q_strcat().

Referenced by TEST_F().

◆ Com_MD5File()

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

Compute the md5sum of a given file.

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

Definition at line 257 of file md5.cpp.

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

Referenced by TEST_F().

◆ MD5Final()

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 211 of file md5.cpp.

References byteReverse, count, MD5Transform(), and OBJZERO.

Referenced by Com_MD5Buffer(), and Com_MD5File().

◆ MD5Init()

void MD5Init ( struct MD5Context * ctx)
static

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

Definition at line 52 of file md5.cpp.

Referenced by Com_MD5Buffer(), and Com_MD5File().

◆ MD5Transform()

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 79 of file md5.cpp.

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

Referenced by MD5Final(), and MD5Update().

◆ MD5Update()

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 165 of file md5.cpp.

References byteReverse, len, and MD5Transform().

Referenced by Com_MD5Buffer(), and Com_MD5File().