All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
md5.c File Reference

md5 digest functions. More...

#include <freeradius-devel/libradius.h>
#include <freeradius-devel/md5.h>
+ Include dependency graph for md5.c:

Go to the source code of this file.

Macros

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

Functions

void fr_md5_calc (uint8_t *out, uint8_t const *in, size_t inlen)
 Calculate the MD5 hash of the contents of a buffer. More...
 
void fr_md5_final (uint8_t out[MD5_DIGEST_LENGTH], FR_MD5_CTX *ctx)
 Finalise the MD5 context and write out the hash. More...
 
void fr_md5_init (FR_MD5_CTX *ctx)
 Initialise a new MD5 context. More...
 
void fr_md5_transform (uint32_t state[4], uint8_t const block[MD5_BLOCK_LENGTH])
 The core of the MD5 algorithm. More...
 
void fr_md5_update (FR_MD5_CTX *ctx, uint8_t const *in, size_t inlen)
 Feed additional data into the MD5 hashing function. More...
 

Variables

static const uint8_t PADDING [MD5_BLOCK_LENGTH]
 

Detailed Description

md5 digest functions.

Id:
0445be8754726bedf279b923f01871e54824d0f4
Note
license is LGPL, but largely derived from a public domain source.

Definition in file md5.c.

Macro Definition Documentation

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

Definition at line 170 of file md5.c.

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

Definition at line 171 of file md5.c.

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

Definition at line 172 of file md5.c.

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

Definition at line 173 of file md5.c.

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

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

Definition at line 65 of file md5.c.

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

Definition at line 54 of file md5.c.

Function Documentation

void fr_md5_calc ( uint8_t *  out,
uint8_t const *  in,
size_t  inlen 
)

Calculate the MD5 hash of the contents of a buffer.

Parameters
[out]outWhere to write the MD5 digest. Must be a minimum of MD5_DIGEST_LENGTH.
[in]inData to hash.
[in]inlenLength of the data.

Definition at line 28 of file md5.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_md5_final ( uint8_t  out[MD5_DIGEST_LENGTH],
FR_MD5_CTX ctx 
)

Finalise the MD5 context and write out the hash.

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

Parameters
[out]outWhere to write the MD5 digest. Minimum length of MD5_DIGEST_LENGTH.
[in,out]ctxto finalise.

Definition at line 145 of file md5.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_md5_init ( FR_MD5_CTX ctx)

Initialise a new MD5 context.

Set bit count to 0 and buffer to mysterious initialization constants.

Parameters
[out]ctxto initialise.

Definition at line 84 of file md5.c.

+ Here is the caller graph for this function:

void fr_md5_transform ( uint32_t  state[4],
uint8_t const  block[MD5_BLOCK_LENGTH] 
)

The core of the MD5 algorithm.

This alters an existing MD5 hash to reflect the addition of 16 longwords of new data. fr_md5_update blocks the data and converts bytes into longwords for this routine.

Parameters
[in]state16 bytes of data to feed into the hashing function.
[in,out]blockMD5 digest block to update.

Definition at line 187 of file md5.c.

+ Here is the caller graph for this function:

void fr_md5_update ( FR_MD5_CTX ctx,
uint8_t const *  in,
size_t  inlen 
)

Feed additional data into the MD5 hashing function.

Parameters
[in,out]ctxto update.
[in]inData to hash.
[in]inlenLength of the data.

Definition at line 100 of file md5.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const uint8_t PADDING[MD5_BLOCK_LENGTH]
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 72 of file md5.c.