The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
md4.c File Reference

A local MD4 implementation. More...

#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/md4.h>
+ Include dependency graph for md4.c:

Go to the source code of this file.

Data Structures

struct  fr_md4_ctx_local_t
 
struct  fr_md4_free_list_t
 

Macros

#define ARRAY_SIZE   (8)
 The thread local free list. More...
 
#define htole32_14(buf)   /* Nothing */
 
#define htole32_16(buf)   /* Nothing */
 
#define htole32_4(buf)   /* Nothing */
 
#define MD4_BLOCK_LENGTH   64
 
#define MD4_F1(x, y, z)   (z ^ (x & (y ^ z)))
 
#define MD4_F2(x, y, z)   ((x & y) | (x & z) | (y & z))
 
#define MD4_F3(x, y, z)   (x ^ y ^ z)
 
#define MD4STEP(f, w, x, y, z, data, s)   (w += f(x, y, z) + data, w = w << s | w >> (32 - s))
 

Functions

static int _md4_ctx_free_on_exit (void *arg)
 
void fr_md4_calc (uint8_t out[static MD4_DIGEST_LENGTH], uint8_t const *in, size_t inlen)
 Calculate the MD4 hash of the contents of a buffer. More...
 
fr_md4_ctx_tfr_md4_ctx_alloc_from_list (void)
 
void fr_md4_ctx_free_from_list (fr_md4_ctx_t **ctx)
 
static fr_md4_ctx_tfr_md4_local_ctx_alloc (void)
 
static void fr_md4_local_ctx_copy (fr_md4_ctx_t *dst, fr_md4_ctx_t const *src)
 
static void fr_md4_local_ctx_free (fr_md4_ctx_t **ctx)
 
static void fr_md4_local_ctx_reset (fr_md4_ctx_t *ctx)
 
static void fr_md4_local_final (uint8_t out[static MD4_DIGEST_LENGTH], fr_md4_ctx_t *ctx)
 
static void fr_md4_local_transform (uint32_t state[static 4], uint8_t const block[static MD4_BLOCK_LENGTH])
 The core of the MD4 algorithm. More...
 
static void fr_md4_local_update (fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen)
 

Variables

fr_md4_ctx_alloc_t fr_md4_ctx_alloc = fr_md4_local_ctx_alloc
 
fr_md4_ctx_copy_t fr_md4_ctx_copy = fr_md4_local_ctx_copy
 
fr_md4_ctx_free_t fr_md4_ctx_free = fr_md4_local_ctx_free
 
fr_md4_ctx_reset_t fr_md4_ctx_reset = fr_md4_local_ctx_reset
 
fr_md4_final_t fr_md4_final = fr_md4_local_final
 
fr_md4_update_t fr_md4_update = fr_md4_local_update
 
static _Thread_local fr_md4_free_list_tmd4_array
 
static const uint8_tzero = (uint8_t[]){ 0x00 }
 

Detailed Description

A local MD4 implementation.

Note
license is LGPL, but largely derived from a public domain source.

Definition in file md4.c.


Data Structure Documentation

◆ fr_md4_ctx_local_t

struct fr_md4_ctx_local_t

Definition at line 279 of file md4.c.

Data Fields
uint8_t buffer[MD4_BLOCK_LENGTH] Input buffer.
uint32_t count[2] Number of bits, mod 2^64.
uint32_t state[4] State.

◆ fr_md4_free_list_t

struct fr_md4_free_list_t

Definition at line 24 of file md4.c.

Data Fields
fr_md4_ctx_t * md_ctx
bool used

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE   (8)

The thread local free list.

Any entries remaining in the list will be freed when the thread is joined

Definition at line 23 of file md4.c.

◆ htole32_14

#define htole32_14 (   buf)    /* Nothing */

Definition at line 138 of file md4.c.

◆ htole32_16

#define htole32_16 (   buf)    /* Nothing */

Definition at line 139 of file md4.c.

◆ htole32_4

#define htole32_4 (   buf)    /* Nothing */

Definition at line 137 of file md4.c.

◆ MD4_BLOCK_LENGTH

#define MD4_BLOCK_LENGTH   64

Definition at line 193 of file md4.c.

◆ MD4_F1

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

Definition at line 196 of file md4.c.

◆ MD4_F2

#define MD4_F2 (   x,
  y,
 
)    ((x & y) | (x & z) | (y & z))

Definition at line 197 of file md4.c.

◆ MD4_F3

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

Definition at line 198 of file md4.c.

◆ MD4STEP

#define MD4STEP (   f,
  w,
  x,
  y,
  z,
  data,
 
)    (w += f(x, y, z) + data, w = w << s | w >> (32 - s))

Definition at line 201 of file md4.c.

Function Documentation

◆ _md4_ctx_free_on_exit()

static int _md4_ctx_free_on_exit ( void *  arg)
static

Definition at line 499 of file md4.c.

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

◆ fr_md4_calc()

void fr_md4_calc ( uint8_t  out[static MD4_DIGEST_LENGTH],
uint8_t const *  in,
size_t  inlen 
)

Calculate the MD4 hash of the contents of a buffer.

Perform a single digest operation on a single input buffer.

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

Definition at line 489 of file md4.c.

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

◆ fr_md4_ctx_alloc_from_list()

fr_md4_ctx_t* fr_md4_ctx_alloc_from_list ( void  )

Allocate an md4 context from a free list.

Definition at line 515 of file md4.c.

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

◆ fr_md4_ctx_free_from_list()

void fr_md4_ctx_free_from_list ( fr_md4_ctx_t **  ctx)

Release an md4 context back to a free list.

Definition at line 560 of file md4.c.

+ Here is the caller graph for this function:

◆ fr_md4_local_ctx_alloc()

static fr_md4_ctx_t* fr_md4_local_ctx_alloc ( void  )
static

Definition at line 314 of file md4.c.

+ Here is the call graph for this function:

◆ fr_md4_local_ctx_copy()

static void fr_md4_local_ctx_copy ( fr_md4_ctx_t dst,
fr_md4_ctx_t const *  src 
)
static

Definition at line 303 of file md4.c.

◆ fr_md4_local_ctx_free()

static void fr_md4_local_ctx_free ( fr_md4_ctx_t **  ctx)
static

Definition at line 359 of file md4.c.

+ Here is the call graph for this function:

◆ fr_md4_local_ctx_reset()

static void fr_md4_local_ctx_reset ( fr_md4_ctx_t ctx)
static

Definition at line 288 of file md4.c.

+ Here is the caller graph for this function:

◆ fr_md4_local_final()

static void fr_md4_local_final ( uint8_t  out[static MD4_DIGEST_LENGTH],
fr_md4_ctx_t ctx 
)
static

Definition at line 429 of file md4.c.

+ Here is the call graph for this function:

◆ fr_md4_local_transform()

static void fr_md4_local_transform ( uint32_t  state[static 4],
uint8_t const  block[static MD4_BLOCK_LENGTH] 
)
static

The core of the MD4 algorithm.

This alters an existing MD4 hash to reflect the addition of 16 longwords of new data. fr_md4_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]blockMD4 digest block to update.

Definition at line 212 of file md4.c.

+ Here is the caller graph for this function:

◆ fr_md4_local_update()

static void fr_md4_local_update ( fr_md4_ctx_t ctx,
uint8_t const *  in,
size_t  inlen 
)
static

Definition at line 370 of file md4.c.

+ Here is the call graph for this function:

Variable Documentation

◆ fr_md4_ctx_alloc

Definition at line 478 of file md4.c.

◆ fr_md4_ctx_copy

Definition at line 477 of file md4.c.

◆ fr_md4_ctx_free

Definition at line 479 of file md4.c.

◆ fr_md4_ctx_reset

Definition at line 476 of file md4.c.

◆ fr_md4_final

Definition at line 481 of file md4.c.

◆ fr_md4_update

Definition at line 480 of file md4.c.

◆ md4_array

_Thread_local fr_md4_free_list_t* md4_array
static

Definition at line 28 of file md4.c.

◆ zero

const uint8_t* zero = (uint8_t[]){ 0x00 }
static

Definition at line 365 of file md4.c.