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: a69ffcce52004b7f77fd8113e063207bad340b79 $")
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
21#ifndef MD4_DIGEST_LENGTH
22# define MD4_DIGEST_LENGTH 16
23#endif
24
25typedef void fr_md4_ctx_t;
26
27/* md4.c */
28
29typedef void (*fr_md4_ctx_reset_t)(fr_md4_ctx_t *ctx);
30typedef void (*fr_md4_ctx_copy_t)(fr_md4_ctx_t *dst, fr_md4_ctx_t const *src);
31typedef fr_md4_ctx_t *(*fr_md4_ctx_alloc_t)(void);
32typedef void (*fr_md4_ctx_free_t)(fr_md4_ctx_t **ctx);
33typedef void (*fr_md4_update_t)(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen);
35
44
45/** Swap a single pointer, so all functions get swapped as an atomic operation
46 */
47extern fr_md4_funcs_t const *fr_md4_funcs;
48
49/** Reset the ctx to allow reuse
50 *
51 * @param[in] ctx To reuse.
52 */
53#define fr_md4_ctx_reset(_ctx) fr_md4_funcs->reset(_ctx)
54
55/** Copy the contents of a ctx
56 *
57 * @param[in] dst Where to copy the context to.
58 * @param[in] src Where to copy the context from.
59 */
60#define fr_md4_ctx_copy(_dst, _src) fr_md4_funcs->copy(_dst, _src)
61
62/** Allocation function for MD4 digest context
63 *
64 * @return
65 * - An MD4 ctx.
66 * - NULL if out of memory.
67 */
68#define fr_md4_ctx_alloc() fr_md4_funcs->alloc()
69
70/** Free function for MD4 digest ctx
71 *
72 * @param[in] ctx MD4 ctx to free. If the shared ctx is passed in
73 * then the ctx is reset but not freed.
74 */
75#define fr_md4_ctx_free(_ctx) fr_md4_funcs->free(_ctx)
76
77/** Ingest plaintext into the digest
78 *
79 * @param[in] ctx To ingest data into.
80 * @param[in] in Data to ingest.
81 * @param[in] inlen Length of data to ingest.
82 */
83#define fr_md4_update(_ctx, _in, _inlen) fr_md4_funcs->update(_ctx, _in, _inlen)
84
85/** Finalise the ctx, producing the digest
86 *
87 * @param[out] out The MD4 digest.
88 * @param[in] ctx To finalise.
89 */
90#define fr_md4_final(_out, _ctx) fr_md4_funcs->final(_out, _ctx)
91
92/** Perform a single digest operation on a single input buffer
93 *
94 */
95void fr_md4_calc(uint8_t out[static MD4_DIGEST_LENGTH], uint8_t const *in, size_t inlen);
96
97/** Allocate an md4 context from a free list
98 *
99 */
101
102/** Release an md4 context back to a free list
103 *
104 */
106
107#ifdef HAVE_OPENSSL_EVP_H
108void fr_md4_openssl_init(void);
109void fr_md4_openssl_free(void);
110#endif
111
112#ifdef __cplusplus
113}
114#endif
#define RCSIDH(h, id)
Definition build.h:507
static fr_slen_t in
Definition dict.h:882
fr_md4_ctx_reset_t reset
Definition md4.h:37
void(* fr_md4_final_t)(uint8_t out[static MD4_DIGEST_LENGTH], fr_md4_ctx_t *ctx)
Definition md4.h:34
fr_md4_ctx_t *(* fr_md4_ctx_alloc_t)(void)
Definition md4.h:31
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:473
fr_md4_ctx_copy_t copy
Definition md4.h:38
fr_md4_ctx_t * fr_md4_ctx_alloc_from_list(void)
Allocate an md4 context from a free list.
Definition md4.c:503
fr_md4_ctx_alloc_t alloc
Definition md4.h:39
fr_md4_ctx_free_t free
Definition md4.h:40
void(* fr_md4_ctx_free_t)(fr_md4_ctx_t **ctx)
Definition md4.h:32
void(* fr_md4_ctx_copy_t)(fr_md4_ctx_t *dst, fr_md4_ctx_t const *src)
Definition md4.h:30
#define MD4_DIGEST_LENGTH
Definition md4.h:22
fr_md4_update_t update
Definition md4.h:41
void(* fr_md4_ctx_reset_t)(fr_md4_ctx_t *ctx)
Definition md4.h:29
void fr_md4_ctx_t
Definition md4.h:25
void fr_md4_ctx_free_from_list(fr_md4_ctx_t **ctx)
Release an md4 context back to a free list.
Definition md4.c:548
void(* fr_md4_update_t)(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen)
Definition md4.h:33
fr_md4_funcs_t const * fr_md4_funcs
Swap a single pointer, so all functions get swapped as an atomic operation.
Definition md4.c:45
unsigned char uint8_t
static size_t char fr_sbuff_t size_t inlen
Definition value.h:1030
static size_t char ** out
Definition value.h:1030