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>
Go to the source code of this file.
|
| #define | ARRAY_SIZE (8) |
| | The thread local free list.
|
| |
| #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)) |
| |
A local MD4 implementation.
- Note
- license is LGPL, but largely derived from a public domain source.
Definition in file md4.c.
◆ fr_md4_ctx_local_t
| struct fr_md4_ctx_local_t |
◆ fr_md4_free_list_t
| struct fr_md4_free_list_t |
Definition at line 24 of file md4.c.
◆ ARRAY_SIZE
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 */ |
◆ htole32_16
| #define htole32_16 |
( |
|
buf | ) |
/* Nothing */ |
◆ htole32_4
| #define htole32_4 |
( |
|
buf | ) |
/* Nothing */ |
◆ MD4_BLOCK_LENGTH
◆ MD4_F1
| #define MD4_F1 |
( |
|
x, |
|
|
|
y, |
|
|
|
z |
|
) |
| (z ^ (x & (y ^ z))) |
◆ MD4_F2
| #define MD4_F2 |
( |
|
x, |
|
|
|
y, |
|
|
|
z |
|
) |
| ((x & y) | (x & z) | (y & z)) |
◆ MD4_F3
| #define MD4_F3 |
( |
|
x, |
|
|
|
y, |
|
|
|
z |
|
) |
| (x ^ y ^ z) |
◆ MD4STEP
| #define MD4STEP |
( |
|
f, |
|
|
|
w, |
|
|
|
x, |
|
|
|
y, |
|
|
|
z, |
|
|
|
data, |
|
|
|
s |
|
) |
| (w += f(x, y, z) + data, w = w << s | w >> (32 - s)) |
◆ _md4_ctx_free_on_exit()
| static int _md4_ctx_free_on_exit |
( |
void * |
arg | ) |
|
|
static |
◆ fr_md4_calc()
Calculate the MD4 hash of the contents of a buffer.
Perform a single digest operation on a single input buffer.
- Parameters
-
| [out] | out | Where to write the MD4 digest. Must be a minimum of MD4_DIGEST_LENGTH. |
| [in] | in | Data to hash. |
| [in] | inlen | Length of the data. |
Definition at line 471 of file md4.c.
◆ fr_md4_ctx_alloc_from_list()
Allocation function for MD4 digest context.
Allocate an md4 context from a free list.
- Returns
- An MD4 ctx.
- NULL if out of memory.
Definition at line 497 of file md4.c.
◆ fr_md4_ctx_free_from_list()
Free function for MD4 digest ctx.
Release an md4 context back to a free list.
- Parameters
-
| [in] | ctx | MD4 ctx to free. If the shared ctx is passed in then the ctx is reset but not freed. |
Definition at line 542 of file md4.c.
◆ fr_md4_local_ctx_alloc()
Allocation function for MD4 digest context.
- Returns
- An MD4 ctx.
- NULL if out of memory.
Definition at line 336 of file md4.c.
◆ fr_md4_local_ctx_copy()
Copy the contents of a ctx.
- Parameters
-
| [in] | dst | Where to copy the context to. |
| [in] | src | Where to copy the context from. |
Definition at line 325 of file md4.c.
◆ fr_md4_local_ctx_free()
Free function for MD4 digest ctx.
- Parameters
-
| [in] | ctx | MD4 ctx to free. If the shared ctx is passed in then the ctx is reset but not freed. |
Definition at line 351 of file md4.c.
◆ fr_md4_local_ctx_reset()
Reset the ctx to allow reuse.
- Parameters
-
Definition at line 310 of file md4.c.
◆ fr_md4_local_final()
Finalise the ctx, producing the digest.
- Parameters
-
| [out] | out | The MD4 digest. |
| [in] | ctx | To finalise. |
Definition at line 421 of file md4.c.
◆ 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] | state | 16 bytes of data to feed into the hashing function. |
| [in,out] | block | MD4 digest block to update. |
Definition at line 234 of file md4.c.
◆ fr_md4_local_update()
Ingest plaintext into the digest.
- Parameters
-
| [in] | ctx | To ingest data into. |
| [in] | in | Data to ingest. |
| [in] | inlen | Length of data to ingest. |
Definition at line 362 of file md4.c.
◆ fr_md4_funcs
Swap a single pointer, so all functions get swapped as an atomic operation.
Definition at line 45 of file md4.c.
◆ md4_array
Definition at line 28 of file md4.c.
◆ md4_local_funcs
Initial value:= {
}
static void fr_md4_local_ctx_free(fr_md4_ctx_t **ctx)
Free function for MD4 digest ctx.
static fr_md4_ctx_t * fr_md4_local_ctx_alloc(void)
Allocation function for MD4 digest context.
static void fr_md4_local_update(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen)
Ingest plaintext into the digest.
static void fr_md4_local_ctx_copy(fr_md4_ctx_t *dst, fr_md4_ctx_t const *src)
Copy the contents of a ctx.
static void fr_md4_local_final(uint8_t out[static MD4_DIGEST_LENGTH], fr_md4_ctx_t *ctx)
Finalise the ctx, producing the digest.
static void fr_md4_local_ctx_reset(fr_md4_ctx_t *ctx)
Reset the ctx to allow reuse.
Definition at line 37 of file md4.c.
◆ zero