DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
mdfour.h File Reference
#include <stdint.h>
+ Include dependency graph for mdfour.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mdfour_s
 

Functions

void mdfour (unsigned char *out, const unsigned char *in, int n)
 
void mdfour_begin (struct mdfour_s *md)
 
void mdfour_result (struct mdfour_s *md, unsigned char *out)
 
void mdfour_update (struct mdfour_s *md, const unsigned char *in, int n)
 

Function Documentation

◆ mdfour()

void mdfour ( unsigned char * out,
const unsigned char * in,
int n )

Definition at line 182 of file mdfour.c.

183{
184 struct mdfour_s md;
185 mdfour_begin(&md);
186 mdfour_update(&md, in, n);
187 mdfour_result(&md, out);
188}
#define n(x, y)
void mdfour_update(struct mdfour_s *md, const unsigned char *in, int n)
Definition mdfour.c:152
void mdfour_begin(struct mdfour_s *md)
Definition mdfour.c:115
void mdfour_result(struct mdfour_s *md, unsigned char *out)
Definition mdfour.c:173

References mdfour_begin(), mdfour_result(), mdfour_update(), and n.

Referenced by Com_BlockChecksum(), Com_BlockFullChecksum(), and VM_digest_hex().

◆ mdfour_begin()

void mdfour_begin ( struct mdfour_s * md)

Definition at line 115 of file mdfour.c.

116{
117 md->A = 0x67452301;
118 md->B = 0xefcdab89;
119 md->C = 0x98badcfe;
120 md->D = 0x10325476;
121 md->totalN = 0;
122}
uint32_t C
Definition mdfour.h:34
uint32_t B
Definition mdfour.h:34
uint32_t totalN
Definition mdfour.h:35
uint32_t D
Definition mdfour.h:34
uint32_t A
Definition mdfour.h:34

References mdfour_s::A, mdfour_s::B, mdfour_s::C, mdfour_s::D, and mdfour_s::totalN.

Referenced by mdfour().

◆ mdfour_result()

void mdfour_result ( struct mdfour_s * md,
unsigned char * out )

Definition at line 173 of file mdfour.c.

174{
175 copy4(out, md->A);
176 copy4(out+4, md->B);
177 copy4(out+8, md->C);
178 copy4(out+12, md->D);
179}
static void copy4(unsigned char *out, uint32_t x)
Definition mdfour.c:107

References mdfour_s::A, mdfour_s::B, mdfour_s::C, copy4(), and mdfour_s::D.

Referenced by mdfour().

◆ mdfour_update()

void mdfour_update ( struct mdfour_s * md,
const unsigned char * in,
int n )

Definition at line 152 of file mdfour.c.

153{
154 uint32_t M[16];
155
156// start of edit by Ashley Rose Hale (LadyHavoc)
157// commented out to prevent crashing when length is 0
158// if (n == 0) mdfour_tail(in, n);
159// end of edit by Ashley Rose Hale (LadyHavoc)
160
161 while (n >= 64) {
162 copy64(M, in);
163 mdfour64(md, M);
164 in += 64;
165 n -= 64;
166 md->totalN += 64;
167 }
168
169 mdfour_tail(md, in, n);
170}
#define M
static void mdfour64(struct mdfour_s *md, uint32_t *M)
Definition mdfour.c:49
static void copy64(uint32_t *M, const unsigned char *in)
Definition mdfour.c:97
static void mdfour_tail(struct mdfour_s *md, const unsigned char *in, int n)
Definition mdfour.c:125

References copy64(), M, mdfour64(), mdfour_tail(), n, and mdfour_s::totalN.

Referenced by mdfour().