GNU libmicrohttpd  0.9.63
md5.c File Reference
#include "md5.h"
#include "mhd_byteorder.h"
Include dependency graph for md5.c:

Go to the source code of this file.

Macros

#define PUT_64BIT_LE(cp, value)
 
#define PUT_32BIT_LE(cp, value)
 
#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 )
 

Functions

void MD5Init (void *ctx_)
 
static void MD5Pad (struct MD5Context *ctx)
 
void MD5Final (void *ctx_, unsigned char digest[MD5_DIGEST_SIZE])
 
static void MD5Transform (uint32_t state[4], const uint8_t block[MD5_BLOCK_SIZE])
 
void MD5Update (void *ctx_, const uint8_t *input, size_t len)
 

Variables

static uint8_t PADDING [MD5_BLOCK_SIZE]
 

Macro Definition Documentation

◆ F1

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

Definition at line 119 of file md5.c.

◆ F2

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

Definition at line 120 of file md5.c.

◆ F3

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

Definition at line 121 of file md5.c.

◆ F4

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

Definition at line 122 of file md5.c.

◆ MD5STEP

#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 125 of file md5.c.

◆ PUT_32BIT_LE

#define PUT_32BIT_LE (   cp,
  value 
)
Value:
do { \
(cp)[3] = (uint8_t)((value) >> 24); \
(cp)[2] = (uint8_t)((value) >> 16); \
(cp)[1] = (uint8_t)((value) >> 8); \
(cp)[0] = (uint8_t)((value)); } while (0)

Definition at line 33 of file md5.c.

◆ PUT_64BIT_LE

#define PUT_64BIT_LE (   cp,
  value 
)
Value:
do { \
(cp)[7] = (uint8_t)((value) >> 56); \
(cp)[6] = (uint8_t)((value) >> 48); \
(cp)[5] = (uint8_t)((value) >> 40); \
(cp)[4] = (uint8_t)((value) >> 32); \
(cp)[3] = (uint8_t)((value) >> 24); \
(cp)[2] = (uint8_t)((value) >> 16); \
(cp)[1] = (uint8_t)((value) >> 8); \
(cp)[0] = (uint8_t)((value)); } while (0)

Definition at line 23 of file md5.c.

Function Documentation

◆ MD5Final()

void MD5Final ( void *  ctx_,
unsigned char  digest[MD5_DIGEST_SIZE] 
)

Final wrapup–call MD5Pad, fill in digest and zero out ctx.

Parameters
ctxmust be a struct MD5Context *

Definition at line 99 of file md5.c.

References MD5Pad(), PUT_32BIT_LE, and MD5Context::state.

Here is the call graph for this function:

◆ MD5Init()

void MD5Init ( void *  ctx_)

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

Parameters
ctxmust be a struct MD5Context *

Definition at line 53 of file md5.c.

References MD5Context::count, and MD5Context::state.

◆ MD5Pad()

static void MD5Pad ( struct MD5Context ctx)
static

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

Definition at line 72 of file md5.c.

References MD5Context::count, MD5_BLOCK_SIZE, MD5Update(), PADDING, and PUT_64BIT_LE.

Referenced by MD5Final().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MD5Transform()

static void MD5Transform ( uint32_t  state[4],
const uint8_t  block[MD5_BLOCK_SIZE] 
)
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 134 of file md5.c.

References F1, F2, F3, F4, MD5_BLOCK_SIZE, MD5STEP, and MD5Context::state.

Referenced by MD5Update().

Here is the caller graph for this function:

◆ MD5Update()

void MD5Update ( void *  ctx_,
const uint8_t *  input,
size_t  len 
)

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

Definition at line 237 of file md5.c.

References MD5Context::buffer, MD5Context::count, MD5_BLOCK_SIZE, MD5Transform(), and MD5Context::state.

Referenced by MD5Pad().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ PADDING

uint8_t PADDING[MD5_BLOCK_SIZE]
static
Initial value:
= {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 39 of file md5.c.

Referenced by MD5Pad().