GNU libmicrohttpd 0.9.77
Loading...
Searching...
No Matches
md5.c File Reference
#include "md5.h"
#include <string.h>
#include "mhd_bithelpers.h"
#include "mhd_assert.h"

Go to the source code of this file.

Macros

#define MD5_BYTES_IN_WORD   (32 / 8)
 
#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 = _MHD_ROTL32(w, s), w += x)
 

Functions

void MHD_MD5Init (void *ctx_)
 
static void MD5Transform (uint32_t state[4], const uint8_t block[MD5_BLOCK_SIZE])
 
void MHD_MD5Final (void *ctx_, uint8_t digest[MD5_DIGEST_SIZE])
 
void MHD_MD5Update (void *ctx_, const uint8_t *input, size_t len)
 

Macro Definition Documentation

◆ F1

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

Definition at line 130 of file md5.c.

◆ F2

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

Definition at line 131 of file md5.c.

◆ F3

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

Definition at line 132 of file md5.c.

◆ F4

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

Definition at line 133 of file md5.c.

◆ MD5_BYTES_IN_WORD

#define MD5_BYTES_IN_WORD   (32 / 8)

Number of bytes in single MD5 word used to process data

Definition at line 33 of file md5.c.

◆ MD5STEP

#define MD5STEP (   f,
  w,
  x,
  y,
  z,
  data,
  s 
)     (w += f (x, y, z) + data, w = _MHD_ROTL32(w, s), w += x)

Definition at line 136 of file md5.c.

Function Documentation

◆ 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. MHD_MD5Update blocks the data and converts bytes into longwords for this routine.

Definition at line 145 of file md5.c.

References _MHD_GET_32BIT_LE, _MHD_UINT32_ALIGN, F1, F2, F3, F4, MD5_BLOCK_SIZE, MD5_BYTES_IN_WORD, MD5STEP, MHD_HTTP_OK, and MD5Context::state.

Referenced by MHD_MD5Final(), and MHD_MD5Update().

◆ MHD_MD5Final()

void MHD_MD5Final ( void ctx_,
uint8_t  digest[MD5_DIGEST_SIZE] 
)

Final wrapup, fill in digest and zero out ctx.

Parameters
ctxmust be a struct MD5Context *

Definition at line 67 of file md5.c.

References _MHD_PUT_32BIT_LE, _MHD_PUT_64BIT_LE_SAFE(), _MHD_UINT32_ALIGN, MD5Context::buffer, MD5Context::count, MD5_BLOCK_SIZE, MD5_BYTES_IN_WORD, MD5_DIGEST_SIZE, MD5Transform(), mhd_assert, MHD_HTTP_OK, NULL, and MD5Context::state.

◆ MHD_MD5Init()

void MHD_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 43 of file md5.c.

References MD5Context::count, mhd_assert, MHD_HTTP_OK, NULL, and MD5Context::state.

◆ MHD_MD5Update()

void MHD_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 269 of file md5.c.

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