The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
md4.h
Go to the documentation of this file.
1#pragma once
2/** Structures and prototypes for our local MD4 implementation
3 *
4 * @note license is LGPL, but largely derived from a public domain source.
5 *
6 * @file src/lib/util/md4.h
7 * @brief Structures and declarations for md4.
8 */
9RCSIDH(md4_h, "$Id: 94ed5698a6d67176048b24235829f1bc8f6221ea $")
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include <freeradius-devel/build.h>
16#include <freeradius-devel/missing.h>
17
18#include <inttypes.h>
19#include <sys/types.h>
20#include <stdint.h>
21#include <stdbool.h>
22#include <string.h>
23
24#ifndef MD4_DIGEST_LENGTH
25# define MD4_DIGEST_LENGTH 16
26#endif
27
28typedef void fr_md4_ctx_t;
29
30/* md4.c */
31
32typedef void (*fr_md4_ctx_reset_t)(fr_md4_ctx_t *ctx);
33typedef void (*fr_md4_ctx_copy_t)(fr_md4_ctx_t *dst, fr_md4_ctx_t const *src);
34typedef fr_md4_ctx_t *(*fr_md4_ctx_alloc_t)(void);
35typedef void (*fr_md4_ctx_free_t)(fr_md4_ctx_t **ctx);
36typedef void (*fr_md4_update_t)(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen);
38
47
48/** Swap a single pointer, so all functions get swapped as an atomic operation
49 */
50extern fr_md4_funcs_t const *fr_md4_funcs;
51
52/** Reset the ctx to allow reuse
53 *
54 * @param[in] ctx To reuse.
55 */
56#define fr_md4_ctx_reset(_ctx) fr_md4_funcs->reset(_ctx)
57
58/** Copy the contents of a ctx
59 *
60 * @param[in] dst Where to copy the context to.
61 * @param[in] src Where to copy the context from.
62 */
63#define fr_md4_ctx_copy(_dst, _src) fr_md4_funcs->copy(_dst, _src)
64
65/** Allocation function for MD4 digest context
66 *
67 * @return
68 * - An MD4 ctx.
69 * - NULL if out of memory.
70 */
71#define fr_md4_ctx_alloc() fr_md4_funcs->alloc()
72
73/** Free function for MD4 digest ctx
74 *
75 * @param[in] ctx MD4 ctx to free. If the shared ctx is passed in
76 * then the ctx is reset but not freed.
77 */
78#define fr_md4_ctx_free(_ctx) fr_md4_funcs->free(_ctx)
79
80/** Ingest plaintext into the digest
81 *
82 * @param[in] ctx To ingest data into.
83 * @param[in] in Data to ingest.
84 * @param[in] inlen Length of data to ingest.
85 */
86#define fr_md4_update(_ctx, _in, _inlen) fr_md4_funcs->update(_ctx, _in, _inlen)
87
88/** Finalise the ctx, producing the digest
89 *
90 * @param[out] out The MD4 digest.
91 * @param[in] ctx To finalise.
92 */
93#define fr_md4_final(_out, _ctx) fr_md4_funcs->final(_out, _ctx)
94
95/** Perform a single digest operation on a single input buffer
96 *
97 */
98void fr_md4_calc(uint8_t out[static MD4_DIGEST_LENGTH], uint8_t const *in, size_t inlen);
99
100/** Allocate an md4 context from a free list
101 *
102 */
104
105/** Release an md4 context back to a free list
106 *
107 */
109#ifdef __cplusplus
110}
111#endif
#define RCSIDH(h, id)
Definition build.h:486
static fr_slen_t in
Definition dict.h:861
fr_md4_ctx_reset_t reset
Definition md4.h:40
void(* fr_md4_final_t)(uint8_t out[static MD4_DIGEST_LENGTH], fr_md4_ctx_t *ctx)
Definition md4.h:37
fr_md4_ctx_t *(* fr_md4_ctx_alloc_t)(void)
Definition md4.h:34
void fr_md4_calc(uint8_t out[static MD4_DIGEST_LENGTH], uint8_t const *in, size_t inlen)
Perform a single digest operation on a single input buffer.
Definition md4.c:515
fr_md4_ctx_copy_t copy
Definition md4.h:41
fr_md4_ctx_t * fr_md4_ctx_alloc_from_list(void)
Allocate an md4 context from a free list.
Definition md4.c:541
fr_md4_ctx_alloc_t alloc
Definition md4.h:42
fr_md4_ctx_free_t free
Definition md4.h:43
void(* fr_md4_ctx_free_t)(fr_md4_ctx_t **ctx)
Definition md4.h:35
void(* fr_md4_ctx_copy_t)(fr_md4_ctx_t *dst, fr_md4_ctx_t const *src)
Definition md4.h:33
#define MD4_DIGEST_LENGTH
Definition md4.h:25
fr_md4_update_t update
Definition md4.h:44
void(* fr_md4_ctx_reset_t)(fr_md4_ctx_t *ctx)
Definition md4.h:32
void fr_md4_ctx_t
Definition md4.h:28
void fr_md4_ctx_free_from_list(fr_md4_ctx_t **ctx)
Release an md4 context back to a free list.
Definition md4.c:586
void(* fr_md4_update_t)(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen)
Definition md4.h:36
fr_md4_funcs_t const * fr_md4_funcs
Swap a single pointer, so all functions get swapped as an atomic operation.
Definition md4.c:53
unsigned char uint8_t
static size_t char fr_sbuff_t size_t inlen
Definition value.h:1023
static size_t char ** out
Definition value.h:1023